caffe学习系列———激活层及参数
在激活层,对输入数据进行激活操作,是逐元素进行运算。从bottom得到一个blob数据输入,运算后,从top输入一个blob数据。
输入:n*c*h*w
输出:n×c×h×w
常用的激活函数sigmoid,tanh,relu
1 sigmoid函数
layer{
name:"sigmoid"
bottom:"conv1"
top:"conv1ac"
type:"Sigmoid"
}
2ReLU
ReLU是目前使用最多的激活函数,因为它的收敛速度更快,并且保持同样效果。
f(x) = max(x,0)
可选参数:
negative_slope:默认为0,对应标准的ReLU函数,如果设置来这个值,数据为负时,为原始数据乘以negative_slope
layer{
name:"relu1"
type:"ReLU"
bottom:"pool1"
top:"pool1"
}
ReLU支持in-place计算,这意味着bottom的输出和输入相同避免内存消耗。
3 Tanh
layer{
name:"layer"
bottom:"in"
top:"out"
type:"TanH"
}
4 Absolute Value
每个输入数据的绝对值
layer{
name:"layer"
bottom:"in"
top:"out"
type:"AbsVal"
}
5 Power
对每个数据幂运算
f(x) =(shift+scale*x)^power
层类型:Power
参数:
power:默认为1
scale:默认为1
shift:默认为0
layer{
name:"layer"
bottom:"in"
top:"out"
type:"Power"
power_param{
power:2
scale:1
shift:0
}
}
6 BNLL(binomial normal log likelihood)
f(x) =log(1+exp(x))
layer{
name:"layer"
bottom:"in"
top:"out"
type:"BNLL"
}