Caffe LENET或Imagenet模型中的参数数量

kha*_*han 8 computer-vision neural-network deep-learning caffe matcaffe

如何计算模型中的参数数量,例如mnist的LENET,或者imagent模型的ConvNet等.在caffe中是否有任何特定的函数可以返回或保存模型中的参数数量.问候

小智 1

我可以提供一种通过 Matlab 界面执行此操作的明确方法(确保首先安装 matcaffe)。基本上,您从每个网络层提取一组参数并对它们进行计数。在Matlab中:

% load the network
net_model = <path to your *deploy.prototxt file>
net_weights = <path to your *.caffemodel file>
phase = 'test';
test_net = caffe.Net(net_model, net_weights, phase);

% get the list of layers
layers_list = test_net.layer_names;
% for those layers which have parameters, count them
counter = 0;
for j = 1:length(layers_list),
    if ~isempty(test_net.layers(layers_list{j}).params)
    feat = test_net.layers(layers_list{j}).params(1).get_data();
    counter = counter + numel(feat)
    end
end
Run Code Online (Sandbox Code Playgroud)

最后,“counter”包含参数的数量。