Caffe学习系列(4):激活层(Activiation Layers)及参数
在激活層中,對輸入數(shù)據(jù)進行激活操作(實際上就是一種函數(shù)變換),是逐元素進行運算的。從bottom得到一個blob數(shù)據(jù)輸入,運算后,從top輸入一個blob數(shù)據(jù)。在運算過程中,沒有改變數(shù)據(jù)的大小,即輸入和輸出的數(shù)據(jù)大小是相等的。
輸入:n*c*h*w
輸出:n*c*h*w
常用的激活函數(shù)有sigmoid, tanh,relu等,下面分別介紹。
1、Sigmoid
對每個輸入數(shù)據(jù),利用sigmoid函數(shù)執(zhí)行操作。這種層設(shè)置比較簡單,沒有額外的參數(shù)。
層類型:Sigmoid
示例:
layer {name: "encode1neuron"bottom: "encode1"top: "encode1neuron"type: "Sigmoid" }2、ReLU / Rectified-Linear and Leaky-ReLU
ReLU是目前使用最多的激活函數(shù),主要因為其收斂更快,并且能保持同樣效果。
標(biāo)準(zhǔn)的ReLU函數(shù)為max(x, 0),當(dāng)x>0時,輸出x; 當(dāng)x<=0時,輸出0
f(x)=max(x,0)
層類型:ReLU
可選參數(shù):
negative_slope:默認為0. 對標(biāo)準(zhǔn)的ReLU函數(shù)進行變化,如果設(shè)置了這個值,那么數(shù)據(jù)為負數(shù)時,就不再設(shè)置為0,而是用原始數(shù)據(jù)乘以negative_slope
layer {name: "relu1"type: "ReLU"bottom: "pool1"top: "pool1" }RELU層支持in-place計算,這意味著bottom的輸出和輸入相同以避免內(nèi)存的消耗。
3、TanH / Hyperbolic Tangent
利用雙曲正切函數(shù)對數(shù)據(jù)進行變換。
層類型:TanH
layer {name: "layer"bottom: "in"top: "out"type: "TanH" }4、Absolute Value
求每個輸入數(shù)據(jù)的絕對值。
f(x)=Abs(x)
層類型:AbsVal
layer {name: "layer"bottom: "in"top: "out"type: "AbsVal" }5、Power
對每個輸入數(shù)據(jù)進行冪運算
f(x)=?(shift + scale * x) ^ power
層類型:Power
可選參數(shù):
power: 默認為1
scale: 默認為1
shift: 默認為0
layer {name: "layer"bottom: "in"top: "out"type: "Power"power_param {power: 2scale: 1shift: 0} }6、BNLL
binomial normal log likelihood的簡稱
f(x)=log(1 + exp(x))
層類型:BNLL
layer {name: "layer"bottom: "in"top: "out"type: “BNLL” }?
總結(jié)
以上是生活随笔為你收集整理的Caffe学习系列(4):激活层(Activiation Layers)及参数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Caffe学习系列(3):视觉层(Vis
- 下一篇: Caffe学习系列(5):其它常用层及参