Caffe常用层参数介绍
生活随笔
收集整理的這篇文章主要介紹了
Caffe常用层参数介绍
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
DATA
crop:截取原圖像中一個固定patch
layers {name: "data"type: DATAtop: "data"top: "label"data_param {source: "../data/ImageNet/imagenet-train" #數據存放位置batch_size: 128 #一次批處理的大小,視內存大小而定。四維數組N*C*H*W中的Nbackend: LMDB #數據庫類型,默認為leveldb}include: { phase: TRAIN } #如果加了這一行的話表示是在訓練過程中使用該層,可將TRAIN替換為TEST }CONVOLUTION
layer {name: "conv"type: "Convolution"bottom: "data"top: "conv"param { lr_mult: 1 #權重的學習率 該層lr=lr_mult*base_lrdecay_mult: 1 #權重的衰減值}param { lr_mult: 2 #偏置項的學習率decay_mult: 0 #偏置項的衰減值}convolution_param {num_output: 96 #該層輸出的filter的個數。四維數組N*C*H*W中的Wkernel_size: 11 #卷積核大小11*11。可設定長kernel_h與寬kernel_wstride: 4 #步長,也就是卷積核滑動的距離weight_filler { #卷積核初始化方式type: "gaussian" #高斯分布std: 0.01 #標準差為0.01}bias_filler { #偏置項初始化方式type: "constant" #連續分布value: 0}} }這里說一下關于weight_filler和bias_filler的幾種設定方式:
| Constant | Value | 以常量初始化,初始化值為[Value] |
| Gaussian | std,mean | 以高斯分布方式初始化,均值為[mean],標準差為[std] |
| uniform | min,max | 均勻分布,[min,max] |
| xavier | scale | 均勻分布,[-scale,scale],scale=sqrt(3/K*H*W) |
RELU
layer {name: "relu"type: "ReLU"bottom: "conv"top: "conv" }Relu標準函數:f(x)=max(0,x)。
當未指定negative_slope值時,為標準Relu層;指定negative_slope值時,f(x)={x,negative_slope×x,x>0x≤0
LRN
layer {name: "norm"type: "LRN"bottom: "conv"top: "norm"lrn_param {local_size: 5#對于cross channel LRN,表示需要求和的channel的數量;對于within channel LRN,表示需要求和的空間區域的邊長。默認為5alpha: 0.0001 #LRN公式中的參數alphabeta: 0.75 #LRN公式中的參數beta} }POOLING
layer {name: "pool"type: "Pooling"bottom: "norm1"top: "pool1"pooling_param {pool: MAX #有三種池化方式:MAX,AVG,STOCHASTICkernel_size: 3 #卷積核大小;可設定長kernel_h與寬kernel_wstride: 2 #步長} }INNERPRODUCT
參數和卷積層幾乎一樣,僅貼出代碼,不做過多解釋
layer {name: "fc7"type: "InnerProduct"bottom: "fc6"top: "fc7"param { lr_mult: 1decay_mult: 1}param { lr_mult: 2decay_mult: 0}inner_product_param {num_output: 4096weight_filler {type: "gaussian"std: 0.005}bias_filler {type: "constant"value: 0.1}} }ACCURACY
layer {name: "accuracy"type: "Accuracy"bottom: "fc8"bottom: "label"top: "accuracy"include {phase: TEST} }可添加
accuracy_param {top_k: 5}默認為top_1,添加該項后,選擇測試top_k準確率。
SOFTMAX_LOSS
layers {name: "loss"type: SOFTMAX_LOSSbottom: "pool3"bottom: "label"top: "loss"include: { phase: TRAIN } }注意,在計算softmax_loss前,將pool3層默認經過了一次softmax計算。
另外,以上所有層的name項都是自己隨意定的,只要好辨認,不重復就可以。
總結
以上是生活随笔為你收集整理的Caffe常用层参数介绍的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python必备神器_Python 必备
- 下一篇: Caffe抽取图像特征