简体   繁体   English

卷积神经网络中密集层和输出层的尺寸如何计算?

[英]How to calculate dimensions of the dense and output layer in convolutional neural network?

Can someone please tell me that why the size of dense layer and the output layer is 256 and 10 respectively? 有人可以告诉我为什么密集层和输出层的大小分别为256和10吗?

input = 1x28x28                      
conv2d1   (28-(5-1))=24 -> 32x24x24   
maxpool1                    32x12x12                           
conv2d2   (12-(3-1))=10 ->  32x10x10    
maxpool2                     32x5x5                           
dense                           256    
output                           10  

Convolution layers are different from Fully Connected layers. 卷积层与完全连接层不同。 For fully connected, you reshape the vector to one single dimension and apply matrix multiplication with fc layer weights (W*x+B). 对于完全连接,您可以将向量整形为一个一维,并使用fc层权重(W * x + B)进行矩阵乘法。

You should clearly read and understand concepts here (best tutorial to understand how convnets works) : http://cs231n.github.io/convolutional-networks/#conv 您应该在此处清楚地阅读和理解概念(了解convnets如何工作的最佳教程): http ://cs231n.github.io/convolutional-networks/#conv

For Dense Layer : 对于密集层

In your case, first dense layer has size of weights [32*5*5,256]. 在您的情况下,第一个密集层的权重大小为[32 * 5 * 5,256]。 Reshape the output of pool layer to one vector and feed it through dense layers. 将池层的输出重塑为一个矢量,并将其馈送通过密集层。 Output of first dense layer is 256 dim vector - feed it through second FC layer (weights_size = [256,10]) to get 10 dim vector 第一个密集层的输出是256个暗淡矢量-通过第二个FC层将其馈入(weights_size = [256,10])以获得10个暗淡矢量

All the details of Conv, Pool, Relu, fully-connected layers and calculation of output sizes of each layer are clearly explained in the above link. 上面链接清楚地说明了转换层,池层,Relu层,完全连接的层以及每层输出大小的计算的所有详细信息。

Please go through it. 请通过它。 I hope that helps. 希望对您有所帮助。

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

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