name = './gugong.jpg'
img_string = tf.read_file(name)
img_decoded = tf.image.decode_image(img_string)
img_decoded = tf.reshape(img_decoded, [1, 365, 600, 3])
resize_img = tf.image.resize_bicubic(img_decoded, [730, 1200])
print('resize_img shape: ', resize_img.shape)
sess = tf.Session()
img_decoded_val = sess.run(resize_img)
img_decoded_val = img_decoded_val.reshape((730, 1200, 3))
img_decoded_val = np.asarray(img_decoded_val, np.uint8)
print(img_decoded_val.shape)
%matplotlib inline
imshow(img_decoded_val)
报错如下:
InvalidArgumentError Traceback (most recent call last)
<ipython-input-11-dc13c12d0cb2> in <module>()
12 print('resize_img shape: ', resize_img.shape)
13 sess = tf.Session()
---> 14 img_decoded_val = sess.run(resize_img)
15 img_decoded_val = img_decoded_val.reshape((730, 1200, 3))
16 img_decoded_val = np.asarray(img_decoded_val, np.uint8)
...
InvalidArgumentError: Input to reshape is a tensor with 2128680 values, but the requested shape has 657000
[[node Reshape_7 (defined at <ipython-input-11-dc13c12d0cb2>:9) ]]
跟你的代码一样,为啥会报这个错