代码改变世界

caffe自定义layer

2018-08-25 21:40  ZealouSnesS  阅读(455)  评论(0编辑  收藏  举报

caffe自带layers:

http://caffe.berkeleyvision.org/tutorial/layers.html

Layers:

Note that the Python Layer can be useful for create custom data layers.

 

自定义caffe layers:

https://chrischoy.github.io/research/making-caffe-layer/

模型文件的参数在/src/caffe/proto/caffe.proto中,caffe.proto文件编译后以.h文件的方式被include/caffe/zss_layers.hpp引用,如下:

#include "caffe/proto/caffe.pb.h"
 

 

protobuf:

https://developers.google.com/protocol-buffers/docs/cpptutorial

syntax = "proto2";

package tutorial;

message Person {
  required string name = 1;
  required int32 id = 2;
  optional string email = 3;

  enum PhoneType {
    MOBILE = 0;
    HOME = 1;
    WORK = 2;
  }

  message PhoneNumber {
    required string number = 1;
    optional PhoneType type = 2 [default = HOME];
  }

  repeated PhoneNumber phones = 4;
}

message AddressBook {
  repeated Person people = 1;
}

1、2、16、3、4表示变量的编码,编码为1-15的比编码大于16的变量存储时少用1个字节的空间,因此使用频率较高的变量应当给予1-15的编码

required——慎用

optional——可以赋默认值

repeated——长度不固定,可以用来存动态数组之类的

 

 

源码阅读过程中遇到的一些c++知识:

1、explicit关键字,禁止构造函数隐式转换

https://blog.csdn.net/qq_35524916/article/details/58178072

 

2、在类、对象之后的 . :: : ->的作用

https://blog.csdn.net/k_koris/article/details/80469956

 

3、函数后:的作用——构造函数初始化列表

http://www.cnblogs.com/BlueTzar/articles/1223169.html

 

4、c++模板

template <class identifier> function_declaration;
template <typename identifier> function_declaration;

https://blog.csdn.net/qq_35637562/article/details/55194097