Caffe常用層參數介紹


 

版權聲明:本文為博主原創文章,轉載請注明出處。 https://blog.csdn.net/Cheese_pop/article/details/52024980

DATA

crop:截取原圖像中一個固定patch

layers {
  name: "data" type: DATA top: "data" top: "label" data_param { source: "../data/ImageNet/imagenet-train" #數據存放位置 batch_size: 128 #一次批處理的大小,視內存大小而定。四維數組N*C*H*W中的N backend: 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_lr decay_mult: 1 #權重的衰減值 } param { lr_mult: 2 #偏置項的學習率 decay_mult: 0 #偏置項的衰減值 } convolution_param { num_output: 96 #該層輸出的filter的個數。四維數組N*C*H*W中的W kernel_size: 11 #卷積核大小11*11。可設定長kernel_h與寬kernel_w stride: 4 #步長,也就是卷積核滑動的距離 weight_filler { #卷積核初始化方式 type: "gaussian" #高斯分布 std: 0.01 #標准差為0.01 } bias_filler { #偏置項初始化方式 type: "constant" #連續分布 value: 0 } } }

 

這里說一下關於weight_filler和bias_filler的幾種設定方式:

TYPE PARAM EXPLAIN
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)f(x)=max(0,x)。 
當未指定negative_slope值時,為標准Relu層;指定negative_slope值時,f(x)={x,negative_slope×x,x>0x0f(x)={x,x>0negative_slope×x,x≤0

LRN

layer {
  name: "norm" type: "LRN" bottom: "conv" top: "norm" lrn_param { local_size: 5#對於cross channel LRN,表示需要求和的channel的數量;對於within channel LRN,表示需要求和的空間區域的邊長。默認為5 alpha: 0.0001 #LRN公式中的參數alpha beta: 0.75 #LRN公式中的參數beta } }

 

POOLING

layer {
  name: "pool" type: "Pooling" bottom: "norm1" top: "pool1" pooling_param { pool: MAX #有三種池化方式:MAX,AVG,STOCHASTIC kernel_size: 3 #卷積核大小;可設定長kernel_h與寬kernel_w stride: 2 #步長 } }

 

INNERPRODUCT

參數和卷積層幾乎一樣,僅貼出代碼,不做過多解釋

layer { name: "fc7" type: "InnerProduct" bottom: "fc6" top: "fc7" param { lr_mult: 1 decay_mult: 1 } param { lr_mult: 2 decay_mult: 0 } inner_product_param { num_output: 4096 weight_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_LOSS bottom: "pool3" bottom: "label" top: "loss" include: { phase: TRAIN } }

 

注意,在計算softmax_loss前,將pool3層默認經過了一次softmax計算。 
另外,以上所有層的name項都是自己隨意定的,只要好辨認,不重復就可以。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM