Initialize a net with random weights

1,648 views
Skip to first unread message

Rafael Soares Padilha

unread,
May 9, 2016, 7:45:34 AM5/9/16
to Caffe Users
Hi all,

I'm new to Caffe and I'm trying to figure out how to initialize an untrained net and perform the classification without any previous training.
Usually, I would init my net in python with:

net = caffe.Net(model_def,      # defines the structure of the model
                model_weights
,  # contains the trained weights
                caffe
.TEST)     # use test mode (e.g., don't perform dropout)

Is there a way of initializing it without the model_weights, for example?

Another way would be to create a .caffemodel file with random weights. If this is possible, how would I do that? 


Thank you guys for your attention!

Jan

unread,
May 9, 2016, 8:13:23 AM5/9/16
to Caffe Users
That is possible. There is another constructor for caffe.Net in python, that only takes the net.prototxt and the phase flag (e.g. caffe.TEST) as parameters: See https://github.com/BVLC/caffe/blob/master/python/caffe/_caffe.cpp#L89-L97 and https://github.com/BVLC/caffe/blob/master/python/caffe/_caffe.cpp#L240. This constructor just scaffolds the net and inits the layer params according to the config options (usually some kind of randomness).

Jan

Rafael Soares Padilha

unread,
May 10, 2016, 8:49:41 AM5/10/16
to Caffe Users
Thanks, Jan! That was exactly what I was looking for!

Rishabh Shah

unread,
Apr 11, 2017, 2:17:42 AM4/11/17
to Caffe Users
Hey Rafael, could you tell me how you managed to solve this issue?
Reply all
Reply to author
Forward
0 new messages