輸入:n*c*h*w
輸出:n*c*h*w
常用的激活函數有sigmoid, tanh,relu等,下面分別介紹。
1、Sigmoid
對每個輸入數據,利用sigmoid函數執行操作。這種層設置比較簡單,沒有額外的參數。
層類型:Sigmoid
示例:
layer { name: "encode1neuron" bottom: "encode1" top: "encode1neuron" type: "Sigmoid" }
2、ReLU / Rectified-Linear and Leaky-ReLU
ReLU是目前使用最多的激活函數,主要因爲其收斂更快,並且能保持同樣效果。
標準的ReLU函數爲max(x, 0),當x>0時,輸出x; 當x<=0時,輸出0
f(x)=max(x,0)
層類型:ReLU
可選參數:
negative_slope:默認爲0. 對標準的ReLU函數進行變化,如果設置了這個值,那麼數據爲負數時,就不再設置爲0,而是用原始數據乘以negative_slope
layer { name: "relu1" type: "ReLU" bottom: "pool1" top: "pool1" }
RELU層支持in-place計算,這意味着bottom的輸出和輸入相同以避免內存的消耗。
3、TanH / Hyperbolic Tangent
利用雙曲正切函數對數據進行變換。
層類型:TanH
layer { name: "layer" bottom: "in" top: "out" type: "TanH" }
4、Absolute Value
求每個輸入數據的絕對值。
f(x)=Abs(x)
層類型:AbsVal
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))
層類型:BNLL
layer { name: "layer" bottom: "in" top: "out" type: “BNLL” }