1、fc层
例如caffenet的fc8层:
- layer {
- name: "fc8"
- type: "InnerProduct"
- bottom: "fc7"
- top: "fc8"
- param {
- lr_mult: 1
- decay_mult: 1
- }
- param {
- lr_mult: 2
- decay_mult: 0
- }
- inner_product_param {
- num_output: 1000
- weight_filler {
- type: "gaussian"
- std: 0.01
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
- }
最后一个全连接层:神经元个数 = 类别数, 输出值位于区间[−∞,∞],并不是概率值,输出数值最大的值的index就是样本的预测类别;
2、Accuracy层
例如caffenet的accuracy层:
- layer {
- name: "accuracy"
- type: "Accuracy"
- bottom: "fc8"
- bottom: "label"
- top: "accuracy"
- include {
- phase: TEST
- }
- }
Accuracy = fc8层 输出 对比 数据集的labels,在AccuracyLayer中实现;
3、Softmax function
- layer {
- name: "prob"
- type: "Softmax"
- bottom: "fc8"
- top: "prob"
- }
为了使输出具有统计意义,需要加入softmax function输出似然值。
softmax function是增函数,它使前面的全连接层输出(fc8)具有了概率意义,并不改变这些输出之前的大小关系;
4、loss function
- layer {
- name: "loss"
- type: "SoftmaxWithLoss" //loss fucntion的类型
- bottom: "pred" //loss fucntion的输入数据blob,即网络的预测值lable
- bottom: "label" //loss function的另外一个输入数据blob,即数据集的真实label
- top: "loss" //loss的输出blob,即分类器的loss 值
- }
为了利用误差反向传播,还需要构造loss function,利用softmax function的输出,即输入样本属于每一类的概率值;
粗略地讲,loss function用来衡量估计值和真实值之间的误差情况,在caffe中,包含常用的loss function主要有以下几种:
(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