[英]Incorrect dimension going into convolutional layer in tensorflow
I have 15 images with size 28x28.我有 15 张大小为 28x28 的图像。 Thus, my images.shape
is (15, 28, 28).因此,我的images.shape
是 (15, 28, 28)。 However, I get this error:但是,我收到此错误:
ValueError: Error when checking input: expected conv2d_22_input to have 4 dimensions, but got array with shape (15, 28, 28)
I have tried various reshaping techniques and can get this to work on one image of shape (1, 28, 28, 1).我尝试了各种重塑技术,并且可以将其应用于一张形状 (1, 28, 28, 1) 的图像。 What do I do for a list of images?我如何处理图像列表?
You need to add the channel dimension back into your batch.您需要将通道维度重新添加到您的批次中。 Reshape to (15,28,28,1)
or (15,1,28,28)
depending on your configuration (default is channels last in keras).根据您的配置(默认为 keras 中的最后一个通道(15,28,28,1)
重塑为(15,28,28,1)
或(15,1,28,28)
)。
numpy.expand_dims(images, axis=4)
对我numpy.expand_dims(images, axis=4)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.