-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathlayers.h
82 lines (72 loc) · 2.71 KB
/
layers.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef LAYERS_H_
#define LAYERS_H_
#define LayerBase(NAME) \
class NAME ## Layer: public Layer { \
friend class Layer; \
protected: \
NAME ## Layer(const caffe::LayerParameter& params, \
const std::vector<Layer*> inputs);
#define LayerDef(NAME) \
LayerBase(NAME) \
};
#define LayerParamDef(NAME) \
LayerBase(NAME) \
public: \
void Parameterize(THFloatTensor** tensors); \
};
#define LayerExtDef(NAME, FIELDS) \
LayerBase(NAME) \
private: \
FIELDS; \
};
#define LayerExtParamDef(NAME, FIELDS) \
LayerBase(NAME) \
public: \
void Parameterize(THFloatTensor** tensors); \
private: \
FIELDS; \
};
typedef std::tuple<std::string, std::string, std::string> modstrs;
class Layer {
public:
static Layer* MakeLayer(const caffe::LayerParameter& params,
const std::vector<Layer*> inputs);
virtual std::vector<std::vector<int>> GetOutputSizes();
virtual void Parameterize(THFloatTensor** tensors);
virtual std::vector<modstrs> layer_strs();
std::string name;
protected:
Layer(const caffe::LayerParameter& params, const std::vector<Layer*> inputs);
const caffe::LayerParameter& params;
std::vector<Layer*> inputs;
std::vector<modstrs> lua_layers;
std::vector<std::vector<int>> output_sizes;
};
class InputLayer: public Layer {
friend class Layer;
public:
std::vector<modstrs> layer_strs();
protected:
InputLayer(const caffe::LayerParameter& params, const std::vector<Layer*> inputs);
};
LayerDef(Data);
LayerDef(Dropout);
LayerDef(Eltwise);
LayerDef(Concat);
LayerDef(ReLU);
LayerDef(Sigmoid);
LayerDef(Slice);
LayerDef(Softmax);
LayerDef(Tanh);
LayerDef(EuclideanLoss);
LayerParamDef(BatchNorm);
LayerParamDef(InnerProduct);
LayerParamDef(Scale);
LayerExtParamDef(Convolution, int nInputPlane; int nOutputPlane;
std::vector<unsigned int> k;
std::vector<unsigned int> p;
std::vector<unsigned int> d);
LayerExtDef(Pooling, std::vector<unsigned int> k;
std::vector<unsigned int> p;
std::vector<unsigned int> d);
#endif