% 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
下面是一个python代码片段,用于计算Caffe模型中的参数数:
https://gist.github.com/kaushikpavani/a6a32bd87fdfe5529f0e908ed743f779
我可以通过Matlab接口提供一种明确的方法来实现这一点(确保首先安装了matcaffe)。 基本上,您从每个网络层提取一组参数并对其进行计数。 在Matlab中:
最后,“counter”包含参数的数量。在
相关问题 更多 >
编程相关推荐