Borrar filtros
Borrar filtros

fully connected layer in a CNN

6 visualizaciones (últimos 30 días)
Jyoti Nautiyal
Jyoti Nautiyal el 27 de Sept. de 2020
Comentada: Jyoti Nautiyal el 2 de Oct. de 2020
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.

Respuesta aceptada

Srivardhan Gadila
Srivardhan Gadila el 1 de Oct. de 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 comentarios
Jyoti Nautiyal
Jyoti Nautiyal el 2 de Oct. de 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 el 2 de Oct. de 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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by