TENSORFLOW。标签和logits不匹配,但我确信它们具有相同的形状

时间:2017-08-16 19:11:23

标签: machine-learning tensorflow neural-network computer-vision deep-learning

Traceback (most recent call last):
  File "CNN2.py", line 272, in <module>
    _, l, predictions = session.run([optimizer, cost, y_pred], feed_dict=feed_dict)
  File "/Users/Aldo/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 778, in run
    run_metadata_ptr)
  File "/Users/Aldo/tensorflow/lib/python3.5/site-packages/tensorflow/python/client/session.py", line 961, in _run
    % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (128,) for Tensor 'y_true:0', which has shape '(128, 1)'

1 个答案:

答案 0 :(得分:0)

您可以将标签值重新整形为(128, 1)

labels  = np.reshape(labels, (128, 1))
feed_dict = {..., y_true:labels}