Vision Layers
1. 卷積層(ConvolutionLayer)
2. 池化層(PoolingLayer)
Activation / Neuron Layers
1. ReLU(Rectified-Linear and Leaky)
Loss Layers
Utility Layers
1. Slice
將bottom按照需要分解成多個tops。即在某一個維度,按照給定的下標倾芝,blob拆分成幾塊拌喉。比如要拆分channel肘迎,總數(shù)50灸姊,下標為10,30,40父叙,那就是分成4份徙垫,輸出4個layer饺汹。假設input的維度是N*50*H*W
,tops輸出的維度分別為N*10*H*W
, N*20*H*W
, N*10*H*W
, N*10*H*W
蛔添,使用示例:
layer {
name: "slice"
type: "Slice"
bottom: "input"
top: "output1"
top: "output2"
top: "output3"
top: "output4"
slice_param {
axis: 1 #要進行分解的維度
slice_point: 10
slice_point: 20
slice_point: 30
slice_point: 40
}
}
這里需要注意的是,如果有slice_point兜辞,slice_point的個數(shù)一定要等于top個數(shù)減1迎瞧。 slice_point的作用是將axis按照slic_point 進行分解,沒有設置時則對axis進行均勻分解逸吵⌒坠瑁可設參數(shù)如下:
message SliceParameter {
// The axis along which to slice -- may be negative to index from the end
// (e.g., -1 for the last axis).
// By default, SliceLayer concatenates blobs along the "channels" axis (1).
optional int32 axis = 3 [default = 1];
repeated uint32 slice_point = 2;
// DEPRECATED: alias for "axis" -- does not support negative indexing.
optional uint32 slice_dim = 1 [default = 1];
}
2. Concat
在某個維度,將輸入的layer拼接起來扫皱,是slice的逆過程足绅。使用示例:
layer {
name: "data_all"
type: "Concat"
bottom: "data_classfier"
bottom: "data_boundingbox"
bottom: "data_facialpoints"
top: "data_all"
concat_param {
axis: 1 # 拼接的維度,默認1韩脑,0表示沿batch(即num)拼接
}
}
參數(shù)定義:
message ConcatParameter {
// The axis along which to concatenate -- may be negative to index from the
// end (e.g., -1 for the last axis). Other axes must have the
// same dimension for all the bottom blobs.
// By default, ConcatLayer concatenates blobs along the "channels" axis (1).
optional int32 axis = 2 [default = 1];
// DEPRECATED: alias for "axis" -- does not support negative indexing.
optional uint32 concat_dim = 1 [default = 1];
}
3. Split
將blob復制幾份编检,分別給不同的layer,這些上層layer共享這個blob扰才。無需參數(shù)允懂。
4. Tile
將blob的某個維度,擴大n倍衩匣。比如原來是1234蕾总,擴大兩倍變成11223344。
5. Reduction
使用sum或mean等操作作用于輸入blob按照給定參數(shù)規(guī)定的維度琅捏。(通俗的講就是將輸入的特征圖按照給定的維度進行求和或求平均)生百。用法示例:
layer {
name: "o_pseudoloss"
type: "Reduction"
bottom: "o"
top: "o_pseudoloss"
loss_weight: 1
reduction_param{
axis: 0//default = 0
optional ReductionOp operation = SUM //default = SUM
}
}
參數(shù)
// Message that stores parameters used by ReductionLayer
message ReductionParameter {
enum ReductionOp {
SUM = 1;
ASUM = 2;
SUMSQ = 3;
MEAN = 4;
}
optional ReductionOp operation = 1 [default = SUM]; // reduction operation
// The first axis to reduce to a scalar -- may be negative to index from the
// end (e.g., -1 for the last axis).
// (Currently, only reduction along ALL "tail" axes is supported; reduction
// of axis M through N, where N < num_axes - 1, is unsupported.)
// Suppose we have an n-axis bottom Blob with shape:
// (d0, d1, d2, ..., d(m-1), dm, d(m+1), ..., d(n-1)).
// If axis == m, the output Blob will have shape
// (d0, d1, d2, ..., d(m-1)),
// and the ReductionOp operation is performed (d0 * d1 * d2 * ... * d(m-1))
// times, each including (dm * d(m+1) * ... * d(n-1)) individual data.
// If axis == 0 (the default), the output Blob always has the empty shape
// (count 1), performing reduction across the entire input --
// often useful for creating new loss functions.
optional int32 axis = 2 [default = 0];
optional float coeff = 3 [default = 1.0]; // coefficient for output
}
6. Reshape
這個很簡單,就是matlab里的reshape柄延。
7. Eltwise
按元素對輸入執(zhí)行相應的操作運算:如相加蚀浆,相乘,取最大等搜吧。因此輸入必須具有相同的尺寸和維度市俊。
layer
{
name: "eltwise_layer"
type: "Eltwise"
bottom: "A"
bottom: "B"
top: "diff"
eltwise_param {
operation: SUM
coeff: 1 # 執(zhí)行A+(-B)=A-B的操作,默認不寫時執(zhí)行A+B
coeff: -1
}
}?
注意:參數(shù)coeff只對SUM操作有效滤奈,用于控制相加時的權(quán)值
參數(shù):
message EltwiseParameter {
enum EltwiseOp {
PROD = 0;
SUM = 1;
MAX = 2;
}
optional EltwiseOp operation = 1 [default = SUM]; // element-wise operation
repeated float coeff = 2; // blob-wise coefficient for SUM operation
// Whether to use an asymptotically slower (for >2 inputs) but stabler method
// of computing the gradient for the PROD operation. (No effect for SUM op.)
optional bool stable_prod_grad = 3 [default = true];
}
8. Flatten
把一個輸入的大小為n * c * h * w變成一個簡單的向量摆昧,其大小為 n * (chw)⊙殉蹋可以用reshape代替~绅你,相當于第一維不變伺帘,后面的自動計算。
參數(shù)定義:
/// Message that stores parameters used by FlattenLayer
message FlattenParameter {
// The first axis to flatten: all preceding axes are retained in the output.
// May be negative to index from the end (e.g., -1 for the last axis).
optional int32 axis = 1 [default = 1];
// The last axis to flatten: all following axes are retained in the output.
// May be negative to index from the end (e.g., the default -1 for the last
// axis).
optional int32 end_axis = 2 [default = -1];
}
參考
http://caffe.berkeleyvision.org/tutorial/
https://blog.csdn.net/chenzhi1992/article/details/52837462
http://www.reibang.com/p/0ade01e9e48a