简体   繁体   English

卷积层和池化后的维度

[英]DImensions after convolution layer and pooling

I'm testing some things out with the MNIST dataset.我正在用 MNIST 数据集测试一些东西。 images are 28x28 and my x_train has dimensions (60000,28,28,1).图像为 28x28,我的 x_train 尺寸为 (60000,28,28,1)。 I'm using the following code and getting the following error,我正在使用以下代码并收到以下错误,

        keras.layers.Co`enter code here`nv2D(64,kernel_size = (10,10),activation = "relu",
                            input_shape = (28,28,1)),
        keras.layers.MaxPooling2D(pool_size = (8,8)),

        keras.layers.Conv2D(32,kernel_size = (4,4),activation = "relu"),
        keras.layers.MaxPooling2D(pool_size = (2,2)),

Negative dimension size caused by subtracting 4 from 2 for 'conv2d_47/Conv2D' (op: 'Conv2D') with input shapes: [?,2,2,64], [4,4,64,64]

By my calculations with no padding and a stride of 1, it looks like I should have something with width and height dimensions of 8 by the end.根据我没有填充和步幅为 1 的计算,看起来我最终应该有一些宽度和高度尺寸为 8 的东西。 I'm using the formula我正在使用公式

W_new = (W1-K+2P)/S where K is the size of the filter,P is the padding, and S is the stride. W_new = (W1-K+2P)/S 其中 K 是过滤器的大小,P 是填充,S 是步幅。

Any pointers on where I'm going wrong here would be greatly appreciated.任何关于我在这里出错的地方的指示将不胜感激。

Thank you谢谢

The formula is [W-K+2P/S]+1.公式为[W-K+2P/S]+1。 I guess after you calculate the correct dimensions after taking into account +1, you should be good.我想在考虑+1后计算出正确的尺寸后,你应该会很好。 Do let me know if it worked for you.如果它对你有用,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM