Number of Parameters

472 views
Skip to first unread message

Ihsan Ullah

unread,
May 22, 2015, 2:19:02 PM5/22/15
to caffe...@googlegroups.com
Hi,
I am new with caffe. So pardon me for simple questions.
How to calculate number of parameters in a model e.g. LENET or ConvNet etc.
Is there any specific function in caffe that returns or saves number of parameters in a model.
Earliest reply will be highly appreciated.
Regards
Khan

Axel Angel

unread,
May 27, 2015, 5:37:28 AM5/27/15
to caffe...@googlegroups.com
You can open your model with python and just look at the shapes:

import caffe
n = caffe.Net('smallnorb_lecun_siamese.prototxt', 'snapshots/lecun_siamese0b_iter_100.caffemodel', caffe.TEST)
[ (k,i,p.data.shape) for k in n.params for i,p in enumerate(n.params[k]) ]
# eg:[('prod1', 0, (20, 9216)), ('prod1', 1, (20,)), ('prod2', 0, (3, 20)), ('prod2', 1, (3,))]
sum([ (reduce(lambda x,y: x*y, p.data.shape)) for k in n.params for i,p in enumerate(n.params[k]) ])
# 184403

Hopefully it should be correct.
Reply all
Reply to author
Forward
0 new messages