本文整理汇总了Python中theano.compat.OrderedDict.iteritems方法的典型用法代码示例。如果您正苦于以下问题:Python OrderedDict.iteritems方法的具体用法?Python OrderedDict.iteritems怎么用?Python OrderedDict.iteritems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类theano.compat.OrderedDict
的用法示例。
在下文中一共展示了OrderedDict.iteritems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scan
# 需要导入模块: from theano.compat import OrderedDict [as 别名]
# 或者: from theano.compat.OrderedDict import iteritems [as 别名]
#.........这里部分代码省略.........
if (isinstance(arg.variable, SharedVariable) and not arg.update)
]
other_shared_inner_args = [
safe_new(arg.variable, "_copy")
for arg in dummy_f.maker.expanded_inputs
if (isinstance(arg.variable, SharedVariable) and not arg.update)
]
givens.update(dict(zip(other_shared_scan_args, other_shared_inner_args)))
##
# Step 6. Re-order the outputs and clone them replacing things
# using the givens
##
inner_inputs = (
inner_seqs
+ mit_mot_inner_inputs
+ mit_sot_inner_inputs
+ sit_sot_inner_inputs
+ shared_inner_inputs
+ other_shared_inner_args
+ other_inner_args
)
inner_outs = (
mit_mot_inner_outputs
+ mit_sot_inner_outputs
+ sit_sot_inner_outputs
+ nit_sot_inner_outputs
+ shared_inner_outputs
)
if condition is not None:
inner_outs.append(condition)
new_givens = OrderedDict()
for w, w_copy in givens.iteritems():
new_givens[w] = w.type.filter_variable(w_copy)
new_outs = scan_utils.clone(inner_outs, replace=new_givens)
##
# Step 7. Create the Scan Op
##
tap_array = mit_sot_tap_array + [[-1] for x in xrange(n_sit_sot)]
info = OrderedDict()
info["tap_array"] = tap_array
info["n_seqs"] = n_seqs
info["n_mit_mot"] = n_mit_mot
info["n_mit_mot_outs"] = n_mit_mot_outs
info["mit_mot_out_slices"] = mit_mot_out_slices
info["n_mit_sot"] = n_mit_sot
info["n_sit_sot"] = n_sit_sot
info["n_shared_outs"] = n_shared_outs
info["n_nit_sot"] = n_nit_sot
info["truncate_gradient"] = -1
info["name"] = name
info["mode"] = mode
info["destroy_map"] = OrderedDict()
info["inplace"] = False
info["gpu"] = False
info["as_while"] = as_while
info["profile"] = profile
info["_scan_savemem_visited"] = True
info["allow_gc"] = allow_gc
local_op = scan_op.Scan(inner_inputs, new_outs, info)
示例2: scan
# 需要导入模块: from theano.compat import OrderedDict [as 别名]
# 或者: from theano.compat.OrderedDict import iteritems [as 别名]
#.........这里部分代码省略.........
other_shared_inner_args)))
##
# Step 6. Re-order the outputs and clone them replacing things
# using the givens
##
inner_inputs = (inner_seqs +
mit_mot_inner_inputs +
mit_sot_inner_inputs +
sit_sot_inner_inputs +
shared_inner_inputs +
other_shared_inner_args +
other_inner_args)
inner_outs = (mit_mot_inner_outputs +
mit_sot_inner_outputs +
sit_sot_inner_outputs +
nit_sot_inner_outputs +
shared_inner_outputs)
if condition is not None:
inner_outs.append(condition)
# Cuda is imported here, instead of being imported on top of the file
# because forces on the user some dependencies that we might do not want
# to. Currently we are working on removing the dependencies on sandbox
# code completeley.
from theano.sandbox import cuda
if cuda.cuda_available:
# very often we end up in this situation when we want to
# replace w with w_copy, where w is CudaNdarray
# and w_copy is TensorType. This is caused because shared
# variables are put on GPU right aways >:| ,
new_givens = OrderedDict()
for w, w_copy in givens.iteritems():
if (isinstance(w.type, cuda.CudaNdarrayType)
and isinstance(w_copy.type, tensor.TensorType)):
for o in inner_outs:
new_givens = traverse(o, w, w_copy, new_givens)
else:
new_givens[w] = w_copy
else:
new_givens = givens
new_outs = scan_utils.clone(inner_outs, replace=new_givens)
##
# Step 7. Create the Scan Op
##
tap_array = mit_sot_tap_array + [[-1] for x in xrange(n_sit_sot)]
if allow_gc is None:
allow_gc = config.scan.allow_gc
info = OrderedDict()
info['tap_array'] = tap_array
info['n_seqs'] = n_seqs
info['n_mit_mot'] = n_mit_mot
info['n_mit_mot_outs'] = n_mit_mot_outs
info['mit_mot_out_slices'] = mit_mot_out_slices
info['n_mit_sot'] = n_mit_sot
info['n_sit_sot'] = n_sit_sot
info['n_shared_outs'] = n_shared_outs
info['n_nit_sot'] = n_nit_sot
info['truncate_gradient'] = truncate_gradient
info['name'] = name
info['mode'] = mode
示例3: OrderedDict
# 需要导入模块: from theano.compat import OrderedDict [as 别名]
# 或者: from theano.compat.OrderedDict import iteritems [as 别名]
shared_inner_outputs)
if condition is not None:
inner_outs.append(condition)
# Cuda is imported here, instead of being imported on top of the file
# because forces on the user some dependencies that we might do not want
# to. Currently we are working on removing the dependencies on sandbox
# code completeley.
from theano.sandbox import cuda
if cuda.cuda_available:
# very often we end up in this situation when we want to
# replace w with w_copy, where w is CudaNdarray
# and w_copy is TensorType. This is caused because shared
# variables are put on GPU right aways >:| ,
new_givens = OrderedDict()
for w, w_copy in givens.iteritems():
if (isinstance(w.type, cuda.CudaNdarrayType)
and isinstance(w_copy.type, tensor.TensorType)):
for o in inner_outs:
new_givens = traverse(o, w, w_copy, new_givens)
else:
new_givens[w] = w_copy
else:
new_givens = givens
new_outs = scan_utils.clone(inner_outs, replace=new_givens)
##
# Step 7. Create the Scan Op
##