简体   繁体   English

在张量流中进入卷积层的维度不正确

[英]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.

相关问题 TensorFlow中的自定义卷积层 - Customized convolutional layer in TensorFlow TensorFlow:卷积网络中的尺寸不兼容错误 - TensorFlow: Dimension not compatible error in convolutional network Tensorflow卷积网络-如何计算尺寸(形状)? - Tensorflow convolutional network - how the dimension (shape) is calculated? 更改卷积层 CNN 上的过滤器 - Python/TensorFlow - Change filter on convolutional layer CNN - Python/TensorFlow 如何在文本的卷积层中使用 tensorflow 集线器层嵌入? - How to use tensorflow hub layer embedding in convolutional layer for text? 在tensorflow js api 0.15.3中设置卷积层的配置 - Setting Configurations for convolutional layer in tensorflow js api 0.15.3 输入层的 TensorFlow Keras 维度错误 - TensorFlow Keras dimension error for input layer 为卷积神经网络生成客户层,但TypeError提醒:float()参数必须是字符串或数字,而不是'Dimension' - Generate a customer layer for Convolutional Neural Network, but TypeError remind: float() argument must be a string or a number, not 'Dimension' TensorFlow:如何为表格(一维)特征制作卷积层? - TensorFlow: How do I use make a convolutional layer for tabular (1-D) features? Tensorflow hub:从 Resnet50 的最顶层卷积层提取特征 - Tensorflow hub: Extracting features from the topmost convolutional layer of a Resnet50
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM