Caffe部署中的几个train-test-solver-prototxt-deploy等说明 (一)
Caffe部署中的幾個train-test-solver-prototxt-deploy等說明 (一)
2016-10-13 09:07?99人閱讀?評論(0)?收藏?舉報 ?分類: caffe(18)? 轉載地址:?http://blog.csdn.net/lg1259156776/article/details/52550830
本文只是自己學習一天的總結,如有不對的地方,歡迎指正!
歡迎大家轉載,但請標明出處,謝謝!
1、*_train_test.prototxt文件
這是訓練與測試網絡配置文件
(1)在數據層中 參數include{
???????????????????????????????? phase:TRAIN/TEST
?????????????????????????????}
TRAIN與TEST不能有“...”否則會報錯,還好提示信息里,會提示哪一行出現了問題,如下圖:
數字8就代表配置文件的第8行出現了錯誤
(2)卷積層和全連接層相似:卷積層(Convolution),全連接層(InnerProduct,容易翻譯成內積層)相似處有兩個【1】:都有兩個param{lr_mult:1
?????????????????????????????????????????? decay_mult:1????????????????????????????
?????????????????????????????? }
???????????????????????????? param{lr_mult: 2
?????????????????????????????????????? ?decay_mult: 0????????????
????????????????????????????? }
【2】:convolution_param{}與inner_product_param{}里面的參數相似,甚至相同
(3)平均值文件*_mean.binaryproto要放在transform_param{}里,訓練與測試數據集放在data_param{}里
2.*_deploy.prototxt文件
【1】*_deploy.prototxt文件的構造和*_train_test.prototxt文件的構造稍有不同首先沒有test網絡中的test模塊,只有訓練模塊
【2】數據層的寫法和原來也有不同,更加簡潔:
input: "data"
input_dim: 1
input_dim: 3
input_dim: 32
input_dim: 32
注意紅色部分,那是數據層的名字,沒有這個的話,第一卷積層無法找到數據,我一開始沒有加這句就報錯。下面的四個參數有點類似batch_size(1,3,32,32)里四個參數
【3】卷積層和全連接層中weight_filler{}與bias_filler{}兩個參數不用再填寫,應為這兩個參數的值,由已經訓練好的模型*.caffemodel文件提供
【4】輸出層的變化(1)沒有了test模塊測試精度(2)輸出層
*_train_test.prototxt文件:
layer{
? name: "loss"
? type: "SoftmaxWithLoss"#注意此處與下面的不同
? bottom: "ip2"
? bottom: "label"#注意標簽項在下面沒有了,因為下面的預測屬于哪個標簽,因此不能提供標簽
? top: "loss"
}
*_deploy.prototxt文件:
layer {
? name: "prob"
? type: "Softmax"
? bottom: "ip2"
? top: "prob"
}
***注意在兩個文件中輸出層的類型都發生了變化一個是SoftmaxWithLoss,另一個是Softmax。另外為了方便區分訓練與應用輸出,訓練是輸出時是loss,應用時是prob。
3、*_slover.prototxt
net: "test.prototxt"
#訓練網絡的配置文件
test_iter: 100
#test_iter 指明在測試階段有多上個前向過程(也就是有多少圖片)被執行。
在MNIST例子里,在網絡配置文件里已經設置test網絡的batch size=100,這里test_iter
設置為100,那在測試階段共有100*100=10000 圖片被處理
test_interval: 500
#每500次訓練迭代后,執行一次test
base_lr: 0.01
#學習率初始化為0.01
momentum:0.9
#u=0.9
weight_decay:0.0005
#
lr_policy: "inv"
gamma: 0.0001
power: 0.75
#以上三個參數都和降低學習率有關,詳細的學習策略和計算公式見下面
// The learning rate decay policy. The currently implemented learning rate
? // policies are as follows:
? //??? - fixed: always return base_lr.
? //??? - step: return base_lr * gamma ^ (floor(iter / step))
? //??? - exp: return base_lr * gamma ^ iter
??? - inv: return base_lr * (1 + gamma * iter) ^ (- power)
? //??? - multistep: similar to step but it allows non uniform steps defined by
? //????? stepvalue
? //??? - poly: the effective learning rate follows a polynomial decay, to be
? //????? zero by the max_iter. return base_lr (1 - iter/max_iter) ^ (power)
? //??? - sigmoid: the effective learning rate follows a sigmod decay
? //????? return base_lr ( 1/(1 + exp(-gamma * (iter - stepsize))))
? // where base_lr, max_iter, gamma, step, stepvalue and power are defined
? // in the solver parameter protocol buffer, and iter is the current iteration.
display:100
#每100次迭代,顯示結果
snapshot: 5000
#每5000次迭代,保存一次快照
snapshot_prefix: "path_prefix"
#快照保存前綴:更準確的說是快照保存路徑+前綴,應為文件名后的名字是固定的
solver_mode:GPU
#選擇解算器是用cpu還是gpu
批處理文件編寫:
F:/caffe/caffe-windows-master/bin/caffe.exe train --solver=C:/Users/Administrator/Desktop/caffe_test/cifar-10/cifar10_slover_prototxt --gpu=all
pause
總結
以上是生活随笔為你收集整理的Caffe部署中的几个train-test-solver-prototxt-deploy等说明 (一)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: caffe学习笔记
- 下一篇: Caffe部署中的几个train-tes