vlfeat / matconvnet

MatConvNet: CNNs for MATLAB
Other
1.4k stars 752 forks source link

Error using dagnn.DagNN.loadobj (line 17) Invalid model. #1241

Open asharani97 opened 4 years ago

asharani97 commented 4 years ago

I want to extract features from the image using inception_5b/output" as output means 'icp9_out' So, I did following

netStruct = load([modelPath 'imagenet-googlenet-dag.mat']); 
net = dagnn.DagNN.loadobj(netStruct) ;
net.mode='test';
net.move('gpu');
net.conserveMemory=false
removeLayer(net,'softmax')
removeLayer(net,'cls3_fc')
removeLayer(net,'cls3_pool')
net_mat = net.saveobj()
save('inception_5b.mat', 'net_mat') ;

While when I load the inception_5b.mat error:: Error using dagnn.DagNN.loadobj (line 17) Invalid model. @jotaf98

zosel260 commented 4 years ago

I'm not sure my way is correct or not . This error means that loadobj(s) function wants the input 's' has the 'layers' field, because line17 of loadobj.m is: assert(isfield(s, 'layers'), 'Invalid model.');

So, your 'netStruct' must has the 'layers' field.

In my case the loaded structure 'netStruct' has the sub-structure 'net' and 'net' has the 'layers' field. So, I changed like below and then the net is loaded. net = dagnn.DagNN.loadobj(netStruct.net) ;

Because my library is the newest (v1.0-beta25), I don't know why the guide is not working.

I hope my comments be helpful.