Unknown layer type

574 views
Skip to first unread message

Samira

unread,
Jul 14, 2016, 3:03:45 PM7/14/16
to Caffe Users
Hello Everyone,

I am using the windows caffe in a c++ project. I wrote a cmake to add all caffe libraries and its dependencies to my project and I could successfully build my project. 
but when I am trying to initialize a net with a prototxt file I am getting an error. I am using the lenet.prototxt from caffe example as my prototxt file.
I initialize the net  this way.
caffe::Caffe::set_mode(caffe::Caffe::CPU);
net = std::shared_ptr<caffe::Net<float>>(new caffe::Net<float>(protoFile, caffe::TEST));
net->CopyTrainedLayersFrom(layerFile);

the error happens in layerfactory.cpp line 81 and it says "Unknown layer type:Input"

any suggestion?

Thanks, 
Samira

Daniel Moodie

unread,
Jul 15, 2016, 12:07:21 PM7/15/16
to Caffe Users

The error log should output a list of known layers, if it outputs no known layers then you have the same problem that I ran into.
Basically since the layer object factory is defined in a header file, it is instantiated multiple times, thus the object factory that your application is trying to access is not the one where all the layers are registered to in the caffe library.
The fix for this is to move the object factory definition and instantiation into a cpp file in the caffe library.
This fork has this fix applied:

I'm currently working on testing an updated branch with a few other useful changes for when integrating caffe into C++ projects.

Samira

unread,
Jul 18, 2016, 2:40:58 PM7/18/16
to Caffe Users
Hi Daniel,

Thank you so much for the answer, the layer object factory was empty in my case. I changed the object factory and defined it in cpp file, now my output is not empty but it only has 10 layer types in it which is not all layer types so for example it cannot find Input layer type and crashes. Do you know how it fills the layer types?

Thanks, 
Samira

Samira

unread,
Jul 22, 2016, 1:57:59 PM7/22/16
to Caffe Users
I have resolved the problem by adding libcaffe project to my solution and linked it as a reference. this link was helpful.
Reply all
Reply to author
Forward
0 new messages