1
我是一個新的theano-er ..我的代碼已成功運行,優化=無。但是,當mode = FAST_RUN時,我得到了幾次優化失敗,這讓我困擾了好幾天......儘管在這些失敗之後它仍然可以運行......但是它太慢了......我可以縮小這些失敗的範圍來掃描op ...錯誤信息在下面...任何人都可以有任何想法?TypeError:此操作的輸入的可廣播模式不正確。
ERROR (theano.gof.opt): SeqOptimizer apply <theano.gpuarray.opt.GraphToGPU object at 0xb788f2d0>
ERROR (theano.gof.opt): Traceback:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/theano/gof/opt.py", line 241, in apply
sub_prof = optimizer.optimize(fgraph)
File "/usr/lib/python2.7/site-packages/theano/gof/opt.py", line 87, in optimize
ret = self.apply(fgraph, *args, **kwargs)
File "/usr/lib/python2.7/site-packages/theano/gpuarray/opt.py", line 392, in apply
outputs = new_ops(*[mapping[i] for i in node.inputs], return_list=True)
File "/usr/lib/python2.7/site-packages/theano/gof/op.py", line 615, in __call__
node = self.make_node(*inputs, **kwargs)
File "/usr/lib/python2.7/site-packages/theano/gpuarray/elemwise.py", line 419, in make_node
res = DimShuffle.make_node(self, input)
File "/usr/lib/python2.7/site-packages/theano/tensor/elemwise.py", line 202, in make_node
% (self.input_broadcastable, ib)))
TypeError: The broadcastable pattern of the input is incorrect for this op. Expected (True, False, False, False, True, False), got (False, False, False, False, False, False).
ERROR (theano.gof.opt): Optimization failure due to: local_gpua_reshape
ERROR (theano.gof.opt): node: Reshape{6}(Elemwise{add,no_inplace}.0, HostFromGpu(gpuarray).0)
ERROR (theano.gof.opt): TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/theano/gof/opt.py", line 2036, in process_node
remove=remove)
File "/usr/lib/python2.7/site-packages/theano/gof/toolbox.py", line 569, in replace_all_validate_remove
chk = fgraph.replace_all_validate(replacements, reason)
File "/usr/lib/python2.7/site-packages/theano/gof/toolbox.py", line 518, in replace_all_validate
fgraph.replace(r, new_r, reason=reason, verbose=False)
File "/usr/lib/python2.7/site-packages/theano/gof/fg.py", line 486, in replace
". The type of the replacement must be the same.", old, new)
BadOptimization: BadOptimization Error
Variable: id 4166841488 HostFromGpu(gpuarray).0
Op HostFromGpu(gpuarray)(GpuReshape{6}.0)
Value Type: <type 'NoneType'>
Old Value: None
New Value: None
Reason: local_gpua_reshape. The type of the replacement must be the same.
Old Graph:
Reshape{6} [id A] <TensorType(float32, (True, False, False, False, True, False))> ''
|Elemwise{add,no_inplace} [id B] <TensorType(float32, 3D)> ''
| |Elemwise{mul} [id C] <TensorType(float32, 3D)> ''
| | |Elemwise{add,no_inplace} [id D] <TensorType(float32, (True, False, False))> ''
| | | |Elemwise{add,no_inplace} [id E] <TensorType(float32, (True, False, False))> ''
| | | | |Elemwise{mul} [id F] <TensorType(float32, (True, False, False))> ''
| | | | |Elemwise{mul} [id G] <TensorType(float32, (True, False, False))> ''
| | | |InplaceDimShuffle{x,0,1} [id H] <TensorType(float32, (True, False, False))> ''
| | | |Dot22 [id I] <TensorType(float32, matrix)> ''
| | |Elemwise{true_div,no_inplace} [id J] <TensorType(float32, (False, False, True))> ''
| | |InplaceDimShuffle{0,1,x} [id K] <TensorType(float32, (False, False, True))> ''
| | | |Elemwise{exp,no_inplace} [id L] <TensorType(float32, matrix)> ''
| | |InplaceDimShuffle{x,0,x} [id M] <TensorType(float32, (True, False, True))> ''
| | |Sum{axis=[0], acc_dtype=float64} [id N] <TensorType(float32, vector)> ''
| |Elemwise{mul} [id O] <TensorType(float32, 3D)> ''
| |Reshape{3} [id P] <TensorType(float32, 3D)> ''
| | |Dot22 [id Q] <TensorType(float32, matrix)> ''
| | | |Reshape{2} [id R] <TensorType(float32, matrix)> ''
| | | |HostFromGpu(gpuarray) [id S] <TensorType(float32, matrix)> ''
| | |HostFromGpu(gpuarray) [id T] <TensorType(int64, vector)> ''
| | |<GpuArrayType<None>(int64, vector)> [id U] <GpuArrayType<None>(int64, vector)>
| |HostFromGpu(gpuarray) [id V] <TensorType(float32, (True, True, True))> ''
| |<GpuArrayType<None>(float32, (True, True, True))> [id W] <GpuArrayType<None>(float32, (True, True, True))>
|HostFromGpu(gpuarray) [id X] <TensorType(int64, vector)> ''
|<GpuArrayType<None>(int64, vector)> [id Y] <GpuArrayType<None>(int64, vector)>
New Graph:
HostFromGpu(gpuarray) [id Z] <TensorType(float32, 6D)> ''
|GpuReshape{6} [id BA] <GpuArrayType<None>(float32, 6D)> ''
|GpuFromHost<None> [id BB] <GpuArrayType<None>(float32, 3D)> ''
| |Elemwise{add,no_inplace} [id B] <TensorType(float32, 3D)> ''
|HostFromGpu(gpuarray) [id X] <TensorType(int64, vector)> ''
Hint: relax the tolerance by setting tensor.cmp_sloppy=1
or even tensor.cmp_sloppy=2 for less-strict comparison
` ,這暗示有沒有幫助...
你有一個(理想情況下很小)代碼片段來重現此錯誤? – Kh40tiK
我已經發布了代碼作爲答案.. – annisamansa
您可以編輯您的問題,而不是發佈答案。 – Kh40tiK