How to find the total number of parameters in CNN network?

88 次查看(过去 30 天)
Suppose I am using a deep learning model like VGG-16/ResNet, The other tools like tensorflow, Keras automatically show the number of parameters used by the candidate network.
How do I can find the total number of used paramters if I modfiy the pre-trained network based on my application?

回答(2 个)

yanqi liu
yanqi liu 2022-2-17
yes,may be use analyzeNetwork to get net model,such as
net = vgg16;
analyzeNetwork(net)
  3 个评论
Sivylla Paraskevopoulou
See a similar thread: https://www.mathworks.com/matlabcentral/answers/426886-how-to-calculate-the-number-of-parameters-in-matlab-that-is-used-by-a-deep-learning-network-like-vgg
Katarina Vuckovic
Katarina Vuckovic 2022-12-25
analyzeNet shows the total number of learnable parameters per layer in the GUI. Is there a way I can extract that number and input it into the workspace? Right now it seems the only way to caclulate the learnable parameters is to manually sum up all the learnable parameters.

请先登录,再进行评论。


adel adel
adel adel 2023-3-13
hello,
try this code:
lgraph = layerGraph(Net);
output = lgraph.Layers(end).Name;
prob = lgraph.Layers(end-1).Name;
lgraph = removeLayers(lgraph,output);
lgraph = removeLayers(lgraph,prob);
dlnet = dlnetwork(lgraph);
numparams = 0;
for i = 1:size(dlnet.Learnables,1)
numparams = numparams + numel(dlnet.Learnables.Value{i});
end
numparams = round(numparams/1000000,3);
end

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by