提交 5ceb373d authored 作者: Frederic's avatar Frederic

more OrderedDict.

上级 0d02e65e
...@@ -23,7 +23,7 @@ import theano ...@@ -23,7 +23,7 @@ import theano
from theano.compile import function, Param, Out from theano.compile import function, Param, Out
from theano import compile from theano import compile
from theano import gradient from theano import gradient
from theano.gof.python25 import any from theano.gof.python25 import any, OrderedDict
from theano.gof import PureOp, Apply from theano.gof import PureOp, Apply
from theano import gof from theano import gof
from theano.tensor import TensorType from theano.tensor import TensorType
...@@ -426,9 +426,9 @@ class Scan(PureOp): ...@@ -426,9 +426,9 @@ class Scan(PureOp):
if not type(self) == type(other): if not type(self) == type(other):
return False return False
if not 'destroy_map' in self.info: if not 'destroy_map' in self.info:
self.info['destroy_map'] = {} self.info['destroy_map'] = OrderedDict()
if not 'destroy_map' in other.info: if not 'destroy_map' in other.info:
other.info['destroy_map'] = {} other.info['destroy_map'] = OrderedDict()
keys_to_check = ['truncate_gradient', 'profile', keys_to_check = ['truncate_gradient', 'profile',
'n_seqs', 'tap_array', 'name', 'n_seqs', 'tap_array', 'name',
'as_while', 'n_mit_sot', 'destroy_map', 'as_while', 'n_mit_sot', 'destroy_map',
...@@ -472,7 +472,7 @@ class Scan(PureOp): ...@@ -472,7 +472,7 @@ class Scan(PureOp):
name = 'for' name = 'for'
aux_txt = '%s' aux_txt = '%s'
if getattr(self, 'destroy_map', None) is None: if getattr(self, 'destroy_map', None) is None:
self.destroy_map = {} self.destroy_map = OrderedDict()
if len(self.destroy_map.keys()) > 0: if len(self.destroy_map.keys()) > 0:
# Check if all outputs are inplace # Check if all outputs are inplace
if (sorted(self.destroy_map.keys()) == \ if (sorted(self.destroy_map.keys()) == \
...@@ -852,7 +852,7 @@ class Scan(PureOp): ...@@ -852,7 +852,7 @@ class Scan(PureOp):
pos = [(-self.mintaps[idx]) % store_steps[idx] for idx pos = [(-self.mintaps[idx]) % store_steps[idx] for idx
in xrange(self.n_outs + self.n_nit_sot)] in xrange(self.n_outs + self.n_nit_sot)]
if not getattr(self, 'destroy_map', None): if not getattr(self, 'destroy_map', None):
self.destroy_map = {} self.destroy_map = OrderedDict()
# 2.1 Create storage space for outputs # 2.1 Create storage space for outputs
for idx in xrange(self.n_outs): for idx in xrange(self.n_outs):
if idx in self.destroy_map: if idx in self.destroy_map:
...@@ -1138,7 +1138,7 @@ class Scan(PureOp): ...@@ -1138,7 +1138,7 @@ class Scan(PureOp):
# Non-sequences have a direct equivalent from self.inputs in # Non-sequences have a direct equivalent from self.inputs in
# node.inputs # node.inputs
inner_non_sequences = self.inputs[len(seqs_shape) + len(outs_shape):] inner_non_sequences = self.inputs[len(seqs_shape) + len(outs_shape):]
out_equivalent = {} out_equivalent = OrderedDict()
for in_ns, out_ns in izip(inner_non_sequences, node.inputs[offset:]): for in_ns, out_ns in izip(inner_non_sequences, node.inputs[offset:]):
out_equivalent[in_ns] = out_ns out_equivalent[in_ns] = out_ns
if self.as_while: if self.as_while:
...@@ -1257,7 +1257,7 @@ class Scan(PureOp): ...@@ -1257,7 +1257,7 @@ class Scan(PureOp):
def compute_gradient(y, g_y, diff_inputs): def compute_gradient(y, g_y, diff_inputs):
rval = [] rval = []
gmp = {} gmp = OrderedDict()
consider_inps = [x for x in theano.gof.graph.inputs([y]) consider_inps = [x for x in theano.gof.graph.inputs([y])
if x in diff_inputs] if x in diff_inputs]
for x in consider_inps: for x in consider_inps:
...@@ -1695,7 +1695,7 @@ class Scan(PureOp): ...@@ -1695,7 +1695,7 @@ class Scan(PureOp):
new_tap_array = mitmot_inp_taps + [[-1] for k in new_tap_array = mitmot_inp_taps + [[-1] for k in
xrange(n_sitsot_outs)] xrange(n_sitsot_outs)]
info = {} info = OrderedDict()
info['n_seqs'] = len(outer_inp_seqs) info['n_seqs'] = len(outer_inp_seqs)
info['n_mit_sot'] = 0 info['n_mit_sot'] = 0
info['tap_array'] = new_tap_array info['tap_array'] = new_tap_array
...@@ -1709,7 +1709,7 @@ class Scan(PureOp): ...@@ -1709,7 +1709,7 @@ class Scan(PureOp):
info['n_nit_sot'] = n_nit_sot info['n_nit_sot'] = n_nit_sot
info['as_while'] = False info['as_while'] = False
info['profile'] = self.profile info['profile'] = self.profile
info['destroy_map'] = {} info['destroy_map'] = OrderedDict()
if self.name: if self.name:
info['name'] = 'grad_of_' + self.name info['name'] = 'grad_of_' + self.name
else: else:
...@@ -1852,7 +1852,7 @@ class Scan(PureOp): ...@@ -1852,7 +1852,7 @@ class Scan(PureOp):
# The only exception is the eval point for the number of sequences, and # The only exception is the eval point for the number of sequences, and
# evan point for the number of nit_sot which I think should just be # evan point for the number of nit_sot which I think should just be
# ignored (?) # ignored (?)
info = {} info = OrderedDict()
info['n_seqs'] = self.n_seqs * 2 info['n_seqs'] = self.n_seqs * 2
info['n_mit_sot'] = self.n_mit_sot * 2 info['n_mit_sot'] = self.n_mit_sot * 2
info['n_sit_sot'] = self.n_sit_sot * 2 info['n_sit_sot'] = self.n_sit_sot * 2
...@@ -1869,7 +1869,7 @@ class Scan(PureOp): ...@@ -1869,7 +1869,7 @@ class Scan(PureOp):
info['name'] = None info['name'] = None
info['mode'] = self.mode info['mode'] = self.mode
info['mit_mot_out_slices'] = self.mit_mot_out_slices * 2 info['mit_mot_out_slices'] = self.mit_mot_out_slices * 2
info['destroy_map'] = {} info['destroy_map'] = OrderedDict()
new_tap_array = [] new_tap_array = []
b = 0 b = 0
e = self.n_mit_mot e = self.n_mit_mot
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论