在TensorFlow中运行会话时,我收到以下错误
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但错误仍然存在。
答案 0 :(得分:0)
实际上错误在某种程度上是显而易见的,如错误
中所述_DiagPartShape Invalid shape, shape[:mid] (?,) and shape[mid:] (?,) do not match
您提供了错误的尺寸。