Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将图像重塑为特定的尺寸_Python_Image_Deep Learning_Reshape - Fatal编程技术网

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获得帮助,很抱歉打扰您:♥