{"action":"created","issue":{"url":"https://api.github.com/repos/BVLC/caffe/issues/4171","repository_url":"https://api.github.com/repos/BVLC/caffe","labels_url":"https://api.github.com/repos/BVLC/caffe/issues/4171/labels{/name}","comments_url":"https://api.github.com/repos/BVLC/caffe/issues/4171/comments","events_url":"https://api.github.com/repos/BVLC/caffe/issues/4171/events","html_url":"https://github.com/BVLC/caffe/issues/4171","id":155573205,"number":4171,"title":"Adding new layer","user":{"login":"sam-lass","id":17691096,"avatar_url":"https://avatars.githubusercontent.com/u/17691096?v=3","gravatar_id":"","url":"https://api.github.com/users/sam-lass","html_url":"https://github.com/sam-lass","followers_url":"https://api.github.com/users/sam-lass/followers","following_url":"https://api.github.com/users/sam-lass/following{/other_user}","gists_url":"https://api.github.com/users/sam-lass/gists{/gist_id}","starred_url":"https://api.github.com/users/sam-lass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sam-lass/subscriptions","organizations_url":"https://api.github.com/users/sam-lass/orgs","repos_url":"https://api.github.com/users/sam-lass/repos","events_url":"https://api.github.com/users/sam-lass/events{/privacy}","received_events_url":"https://api.github.com/users/sam-lass/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-05-18T18:42:31Z","updated_at":"2016-05-18T23:05:47Z","closed_at":"2016-05-18T23:05:47Z","body":"\r\nHi I want to create new layer in caffe named Load Layer. I created the respected hpp and cpp files for them. I added \r\nINSTANTIATE_CLASS(LoadLayer); at the end of cpp file,\r\n\r\nin layer_factory.cpp I added\r\n\r\ntemplate <typename Dtype> shared_ptr<Layer<Dtype> > GetLoadLayer (const LayerParameter& param){\r\n        return shared_ptr<Layer<Dtype> >(new LoadLayer<Dtype>(param));\r\n}\r\n\r\nREGISTER_LAYER_CREATOR(Load, GetLoadLayer);\r\n\r\nin caffe.proto I added LOAD = 40 \r\n\r\nto\r\n\r\nmessage V1LayerParameter {\r\n  ...\r\n  enum LayerType {\r\n\r\n\r\nIn upgrade_proto.cpp, I added:\r\n\r\n  case V1LayerParameter_LayerType_LOAD:\r\n    return \"Load\";\r\n\r\nto const char* UpgradeV1LayerType(const V1LayerParameter_LayerType type)\r\n\r\n\r\nnow when I try to do make all I get\r\n\r\nIn file included from ./include/caffe/layer.hpp:10:0,\r\n                 from ./include/caffe/layers/load_layer.hpp:7,\r\n                 from src/caffe/layers/load_layer.cpp:5:\r\nsrc/caffe/layers/load_layer.cpp: In instantiation of ‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::Creator_LoadLayer(const caffe::LayerParameter&) [with Dtype = float]’:\r\nsrc/caffe/layers/load_layer.cpp:139:1:   required from here\r\n./include/caffe/layer_factory.hpp:135:67: error: cannot allocate an object of abstract type ‘caffe::LoadLayer<float>’\r\n     return shared_ptr<Layer<Dtype> >(new type##Layer<Dtype>(param));           \\\r\n                                                                   ^\r\nsrc/caffe/layers/load_layer.cpp:139:1: note: in expansion of macro ‘REGISTER_LAYER_CLASS’\r\n REGISTER_LAYER_CLASS(Load);\r\n ^\r\nIn file included from src/caffe/layers/load_layer.cpp:5:0:\r\n./include/caffe/layers/load_layer.hpp:13:7: note:   because the following virtual functions are pure within ‘caffe::LoadLayer<float>’:\r\n class LoadLayer : public Layer<Dtype> {\r\n       ^\r\nIn file included from ./include/caffe/layers/load_layer.hpp:7:0,\r\n                 from src/caffe/layers/load_layer.cpp:5:\r\n./include/caffe/layer.hpp:351:16: note: \tvoid caffe::Layer<Dtype>::Backward_cpu(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<bool>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = float]\r\n   virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,\r\n                ^\r\nIn file included from ./include/caffe/layer.hpp:10:0,\r\n                 from ./include/caffe/layers/load_layer.hpp:7,\r\n                 from src/caffe/layers/load_layer.cpp:5:\r\nsrc/caffe/layers/load_layer.cpp: In instantiation of ‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::Creator_LoadLayer(const caffe::LayerParameter&) [with Dtype = double]’:\r\nsrc/caffe/layers/load_layer.cpp:139:1:   required from here\r\n./include/caffe/layer_factory.hpp:135:67: error: cannot allocate an object of abstract type ‘caffe::LoadLayer<double>’\r\n     return shared_ptr<Layer<Dtype> >(new type##Layer<Dtype>(param));           \\\r\n                                                                   ^\r\nsrc/caffe/layers/load_layer.cpp:139:1: note: in expansion of macro ‘REGISTER_LAYER_CLASS’\r\n REGISTER_LAYER_CLASS(Load);\r\n ^\r\nIn file included from src/caffe/layers/load_layer.cpp:5:0:\r\n./include/caffe/layers/load_layer.hpp:13:7: note:   because the following virtual functions are pure within ‘caffe::LoadLayer<double>’:\r\n class LoadLayer : public Layer<Dtype> {\r\n       ^\r\nIn file included from ./include/caffe/layers/load_layer.hpp:7:0,\r\n                 from src/caffe/layers/load_layer.cpp:5:\r\n./include/caffe/layer.hpp:351:16: note: \tvoid caffe::Layer<Dtype>::Backward_cpu(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<bool>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = double]\r\n   virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,\r\n                ^\r\nIn file included from ./include/caffe/layer.hpp:10:0,\r\n                 from ./include/caffe/layers/load_layer.hpp:7,\r\n                 from src/caffe/layers/load_layer.cpp:5:\r\nsrc/caffe/layers/load_layer.cpp: In function ‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::Creator_LoadLayer(const caffe::LayerParameter&) [with Dtype = double]’:\r\n./include/caffe/layer_factory.hpp:136:3: warning: control reaches end of non-void function [-Wreturn-type]\r\n   }                                                                            \\\r\n   ^\r\nsrc/caffe/layers/load_layer.cpp:139:1: note: in expansion of macro ‘REGISTER_LAYER_CLASS’\r\n REGISTER_LAYER_CLASS(Load);\r\n ^\r\nsrc/caffe/layers/load_layer.cpp: In function ‘boost::shared_ptr<caffe::Layer<Dtype> > caffe::Creator_LoadLayer(const caffe::LayerParameter&) [with Dtype = float]’:\r\n./include/caffe/layer_factory.hpp:136:3: warning: control reaches end of non-void function [-Wreturn-type]\r\n   }                                                                            \\\r\n   ^\r\nsrc/caffe/layers/load_layer.cpp:139:1: note: in expansion of macro ‘REGISTER_LAYER_CLASS’\r\n REGISTER_LAYER_CLASS(Load);\r\n\r\n \r\nPlease help."},"comment":{"url":"https://api.github.com/repos/BVLC/caffe/issues/comments/220184138","html_url":"https://github.com/BVLC/caffe/issues/4171#issuecomment-220184138","issue_url":"https://api.github.com/repos/BVLC/caffe/issues/4171","id":220184138,"user":{"login":"shelhamer","id":311113,"avatar_url":"https://avatars.githubusercontent.com/u/311113?v=3","gravatar_id":"","url":"https://api.github.com/users/shelhamer","html_url":"https://github.com/shelhamer","followers_url":"https://api.github.com/users/shelhamer/followers","following_url":"https://api.github.com/users/shelhamer/following{/other_user}","gists_url":"https://api.github.com/users/shelhamer/gists{/gist_id}","starred_url":"https://api.github.com/users/shelhamer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shelhamer/subscriptions","organizations_url":"https://api.github.com/users/shelhamer/orgs","repos_url":"https://api.github.com/users/shelhamer/repos","events_url":"https://api.github.com/users/shelhamer/events{/privacy}","received_events_url":"https://api.github.com/users/shelhamer/received_events","type":"User","site_admin":false},"created_at":"2016-05-18T23:05:47Z","updated_at":"2016-05-18T23:05:47Z","body":"Follow the new layer development guide: https://github.com/BVLC/caffe/wiki/Development#developing-new-layers and perhaps look at PRs that add layers for more examples. In particular note both lines\r\n\r\n`\r\nINSTANTIATE_CLASS(MyAwesomeLayer);\r\nREGISTER_LAYER_CLASS(MyAwesome);\r\n`\r\nare needed with `REGISTER_LAYER_CLASS()` as a simpler alternative to adding a factory method.\r\n\r\nWhile about layer development, this issue isn't so much about framework development or changing how layers are developed as it is about debugging end-user development of layer types, so I think it belongs on the mailing list.\r\n\r\nFrom https://github.com/BVLC/caffe/blob/master/CONTRIBUTING.md:\r\n\r\n> _Please do not post usage, installation, or modeling questions, or other requests for help to Issues._\r\nUse the [caffe-users list](https://groups.google.com/forum/#!forum/caffe-users) instead. This helps developers maintain a clear, uncluttered, and efficient view of the state of Caffe."}}