深度學習caffe平臺-----激活層(Activiation Layers)參數及參數詳解


在激活層中,對輸入數據進行激活操作(實際上就是一種函數變換),是逐元素進行運算的。從bottom得到一個blob數據輸入,運算後,從top輸入一個blob數據。在運算過程中,沒有改變數據的大小,即輸入和輸出的數據大小是相等的。

輸入: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”
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章