caffe master - matlab interface - cannot read network parameter

92 views
Skip to first unread message

himora...@gmail.com

unread,
Apr 25, 2016, 11:33:22 PM4/25/16
to Caffe Users
Hi everyone,

I'm using matlab interface (caffe master) to read one trained neural network

model file = 'lsp_iteration_6000.caffemodel';
net = caffe_('get_net', model_file, 'test');


I got the following error
"Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: ./cache/lsp/lsp_iter_60000.caffemodel"

 Hope you can support me on this issue.

Best regards

Jan

unread,
Apr 26, 2016, 5:32:11 AM4/26/16
to Caffe Users
Seems to me you have the caffemodel where you should have given the net.prototxt. But I am not sure, I don't use the MATLAB interface.

Jan

Ahmed Ibrahim

unread,
Apr 26, 2016, 11:55:55 AM4/26/16
to Caffe Users
What Jan said is true.
if you would like to read a trained network you should do
model file='yourmodel.prototxt';
weights_file=  'lsp_iteration_6000.caffemodel';
hnet
= caffe_('get_net', model_file, 'test');
net
= caffe.Net(hNet);

net
.copy_from(weights_file);

Although I do now like this way of loading nets in matlab. I would simply do
net_weights = 'mymodel.caffemodel';
net_model
= 'mymodel.prototxt';
net
= caffe.Net(net_model, net_weights, 'test');


Jan

unread,
Apr 27, 2016, 4:49:30 AM4/27/16
to Caffe Users
The second method Ahmed showed is nice because it is (syntactically) very close to doing the same thing in python:

import caffe

net_weights
= 'mymodel.caffemodel'
net_model
= 'mymodel.mymodel.prototxt'
net
= caffe.Net(net_model, net_weights, caffe.TEST)

# then do something like net.forward()


Jan
Reply all
Reply to author
Forward
0 new messages