0
當TensorFlow運行會話時,我收到以下錯誤Tensorflow:ValueError異常使用AdamOptimizer
optimizer = tf.train.AdamOptimizer(learning_rate=learning_rate).minimize(cost)
File "/local0/software/python/python_bleeding_edge/lib/python2.7/site-packages/tensorflow/python/training/optimizer.py", line 190, in minimize
colocate_gradients_with_ops=colocate_gradients_with_ops)
File "/local0/software/python/python_bleeding_edge/lib/python2.7/site-packages/tensorflow/python/training/optimizer.py", line 241, in compute_gradients
colocate_gradients_with_ops=colocate_gradients_with_ops)
File "/local0/software/python/python_bleeding_edge/lib/python2.7/site-packages/tensorflow/python/ops/gradients.py", line 481, in gradients
in_grads = _AsList(grad_fn(op, *out_grads))
File "/local0/software/python/python_bleeding_edge/lib/python2.7/site-packages/tensorflow/python/ops/array_grad.py", line 162, in _DiagGrad
return array_ops.diag_part(grad)
File "/local0/software/python/python_bleeding_edge/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 380, in diag_part
return _op_def_lib.apply_op("DiagPart", input=input, name=name)
File "/local0/software/python/python_bleeding_edge/lib/python2.7/site-packages/tensorflow/python/ops/op_def_library.py", line 655, in apply_op
op_def=op_def)
File "/local0/software/python/python_bleeding_edge/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2156, in create_op
set_shapes_for_outputs(ret)
File "/local0/software/python/python_bleeding_edge/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1612, in set_shapes_for_outputs
shapes = shape_func(op)
File "/local0/software/python/python_bleeding_edge/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 982, in _DiagPartShape
" do not match ")
ValueError: Invalid shape, shape[:mid] (?,) and shape[mid:] (?,) do not match
我不知道它從何而來,因爲它不會給模型建造任何錯誤指示。我也嘗試過不同的優化器,例如GradientDescentOptimizer,但錯誤仍然存在。
請顯示您的成本功能請 – nessuno