Python 如何将图像重塑为特定的尺寸
我正在尝试向我的模型发送图像,但是图像的形状与模型的形状不同Python 如何将图像重塑为特定的尺寸,python,image,deep-learning,reshape,Python,Image,Deep Learning,Reshape,我正在尝试向我的模型发送图像,但是图像的形状与模型的形状不同 ValueError Traceback (most recent call last) <ipython-input-5-d3bd0e2a98e0> in <module>() 257 258 else: --> 259 model.fit({'input': X_train}, {'targets': y_train}, n_
ValueError Traceback (most recent call
last)
<ipython-input-5-d3bd0e2a98e0> in <module>()
257
258 else:
--> 259 model.fit({'input': X_train}, {'targets': y_train},
n_epoch=10,snapshot_step=500)
260 model.save('modelvgg.tfl')
261
ValueError: Cannot feed value of shape (64, 224, 224) for Tensor '
input/X:0', which has shape '(?, 224, 224, 3)'
我只想知道如何适应这些维度,但我不知道如何适应。您的输入缺少最后一个维度,这是通道数。该模型预计有3个通道-最有可能是RGB。您正在馈送的图像只有一个通道,它们很可能是灰度的。如果您没有RGB图像,请尝试使用np将通道尺寸复制3次。重复。但当我读取图像时,它会给出该形状。。它们是用rgb阅读的一种方式吗?注意:我使用了cv2.imread谢谢我这么做了,,我发现我使用了cv2.imreadimg,0,它提供了一个通道。我删除了0,它工作正常:thx获得帮助,很抱歉打扰您:♥