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

조회 수: 12 (최근 30일)
M M Nabi
M M Nabi 2022년 2월 16일
댓글: Joel 2025년 1월 16일
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)
  댓글 수: 4
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.
Joel
Joel 2025년 1월 16일
If you save the output of analyzeNetwork you will be able to get the number of learnables into your workspace:
netinfo = analyzeNetwork(net)
netinfo.TotalLearnables % <- number of learnables
I am using R2024a.

댓글을 달려면 로그인하십시오.


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에서 Deep Learning Toolbox에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by