0

I have built a CNN using the Matlab Neural Network Toolbox. How can I calculate the total number of parameters used in my network?

For example, I can use the analyzeNetwork() from the support addon, and this can show me the number of learnable parameters per layer. Would it be correct to add these up?

layers = [
imageInputLayer([128 300 1])

convolution2dLayer([7 7], 32, 'Stride', [2 2], 'Padding', 1)
batchNormalizationLayer
reluLayer

convolution2dLayer([5 5], 32, 'Stride', [2 2], 'Padding', 1)
batchNormalizationLayer
reluLayer

convolution2dLayer([3 3], 64, 'Stride', [2 2],'Padding', 1)
batchNormalizationLayer
reluLayer
dropoutLayer(0.2)

convolution2dLayer([3 3], 64, 'Stride', [2 2],'Padding', 1)
batchNormalizationLayer
reluLayer
dropoutLayer(0.2)

convolution2dLayer([8 1], 1024, 'Stride', [1 1],'Padding', 0)
batchNormalizationLayer
reluLayer
dropoutLayer(0.2)

averagePooling2dLayer([1 12],'Stride', [1 1]);
dropoutLayer(0.2)

fullyConnectedLayer(4096)
batchNormalizationLayer
reluLayer

dropoutLayer(0.2)

fullyConnectedLayer(1251)
softmaxLayer
classificationLayer];
3
  • What are imageSize and numClasses? Please add this to your question. Commented Jun 17, 2018 at 15:43
  • imageSize is 128x300x1 and numClasses are 1251 Commented Jun 17, 2018 at 15:45
  • The network analyzer shows that ReLU layers have 0 learnable parameters. This means it cannot be trusted... Commented Jun 17, 2018 at 16:44

1 Answer 1

0

I used analyzeNetwork() from the support addon, and added up all of the learnable parameters, equalling 1.4M.

I then created the same network in matconvnet library, and used vl_simplenn_display to analyse the network. It also showed 1.4M parameters.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.