无法提供张量

时间:2017-09-05 12:14:05

标签: python tensorflow

我使用以下代码进行预测

roi = frame[t_y:t_y + t_h, t_x:t_x + t_w]


predictions = sess.run(classification_tensor, feed_dict={'age_model/input_1:0': roi})

然而我收到以下错误,

Traceback (most recent call last):
  File "C:/Users/R&D/Documents/Maxis_2/Maxis/src/dwell_time_maxis.py", line 207, in <module>
    predictions = sess.run(age_tensor, feed_dict={'age_model/input_1:0': roi})
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 789, in run
    run_metadata_ptr)
  File "C:\Program Files\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 975, in _run
    % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (64, 64, 3) for Tensor 'age_model/input_1:0', which has shape '(?, 64, 64, 3)' . 

虽然我已将其重新调整为64x64x3,但我仍然收到此错误。为什么呢?

1 个答案:

答案 0 :(得分:1)

问题在于您将三维值输入到4维值中(即使元素的数量相同)。

只需重新塑造您的Feed:

roi = np.reshape(roi, [1,64,64,3])
相关问题