简体   繁体   中英

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?

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).

You should clearly read and understand concepts here (best tutorial to understand how convnets works) : http://cs231n.github.io/convolutional-networks/#conv

For Dense Layer :

In your case, first dense layer has size of weights [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

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.

Please go through it. I hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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