在caffe中,網絡的結構由prototxt文件中給出,由一些列的Layer(層)組成,常用的層如:數據加載層、卷積操作層、pooling層、非線性變換層、內積運算層、歸一化層、損失計算層等;本篇主要介紹loss層
1. loss層總述
下面首先給出全loss層的結構設置的一個小例子(定義在.prototxt文件中)
layer { name: "loss" type: "SoftmaxWithLoss" //loss fucntion的類型 bottom: "pred" //loss fucntion的輸入數據blob,即網絡的預測值lable bottom: "label" //loss function的另外一個輸入數據blob,即數據集的真實label top: "loss" //loss的輸出blob,即分類器的loss 值 }
2. loss function類型
粗略地講,loss function是用來衡量估計值和真實值之間的誤差情況的;在caffe中,包含了常用的loss function,目前主要有以下幾種:
【Loss drives learning by comparing an output to a target and assigning cost to minimize. The loss itself is computed by the forward pass and the gradient w.r.t. to the loss is computed by the backward pass.】
(1)softmax:圖像多類分類問題中主要就是用它
- Layer type:
SoftmaxWithLoss
(2)
Sum-of-Squares / Euclidean:主要用在線性回歸中
- Layer type:
EuclideanLoss
(3)
Hinge / Margin:主要用在SVM分類器中
- Layer type:
HingeLoss
(4)Sigmoid Cross-Entropy
- Layer type: SigmoidCrossEntropyLoss
(5)Infogain
- Layer type: InfogainLoss
參考:caffe tutorial