fully connected layer in a CNN

3 次查看(过去 30 天)
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.

采纳的回答

Srivardhan Gadila
Srivardhan Gadila 2020-10-1
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 个评论
Jyoti Nautiyal
Jyoti Nautiyal 2020-10-2
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 2020-10-2
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by