fully connected layer in a CNN

3 visualizzazioni (ultimi 30 giorni)
I trained a CNN for MNIST dataset with one fully connected layer. The input to fully connected layer is 9 channels of size 20 x 20, and ouput is 10 classes. How can i calculate the total number of multiplications and additions in this layer.

Risposta accettata

Srivardhan Gadila
Srivardhan Gadila il 1 Ott 2020
You can use the analyzeNetwork to view the network architecture, shape of layerwise Activations & Learnables etc.
Based on the above information and under the assumption that your fullyConnectedLayer is having bias as Learnables then the layer has an input vector of size 4000 (i.e., 20x20x10 flattened) and the size of Weights & Bias are 10x4000, 10x1 respectively.
The general operation of fullyConnectedLayer is Z = W*X + b => 10*4000 = 40,000 multiplications and 39,990 + 10 = 40,000 additions.
  2 Commenti
Jyoti Nautiyal
Jyoti Nautiyal il 2 Ott 2020
Thanks a lot for replying..
I am confused with the size of the fully connected layer and the number of neurons. If size of my fully connected layer is 10 x 1, does it mean it has 10 neurons?
or
if input size is 20 x 20, so number of neurons will be 400?
Jyoti Nautiyal
Jyoti Nautiyal il 2 Ott 2020
I have one more query that-
our 1st conv layer is having 9 filters of size 3 x 3, then weights are 3 x 3 x 9 and image size is 26 x 26 x 9.
now when our second conv layer is having 9 filters of size 3 x 3 x 9, so image size should be = 22 x 22 x 9 or 22 x 22 x 9 x 9 and why?
Thanks in advance.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Deep Learning Toolbox in Help Center e File Exchange

Prodotti


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by