日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

Caffe部署中的几个train-test-solver-prototxt-deploy等说明 (一)

發(fā)布時(shí)間:2025/3/21 213 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Caffe部署中的几个train-test-solver-prototxt-deploy等说明 (一) 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?

Caffe部署中的幾個(gè)train-test-solver-prototxt-deploy等說明 (一)

?99人閱讀?評論(0)?收藏?舉報(bào) ?分類: caffe(18)?

轉(zhuǎn)載地址:?http://blog.csdn.net/lg1259156776/article/details/52550830

本文只是自己學(xué)習(xí)一天的總結(jié),如有不對的地方,歡迎指正!

歡迎大家轉(zhuǎn)載,但請標(biāo)明出處,謝謝!

1、*_train_test.prototxt文件

這是訓(xùn)練與測試網(wǎng)絡(luò)配置文件

(1)在數(shù)據(jù)層中 參數(shù)include{

???????????????????????????????? phase:TRAIN/TEST

?????????????????????????????}

TRAIN與TEST不能有“...”否則會(huì)報(bào)錯(cuò),還好提示信息里,會(huì)提示哪一行出現(xiàn)了問題,如下圖:

數(shù)字8就代表配置文件的第8行出現(xiàn)了錯(cuò)誤

(2)卷積層和全連接層相似:卷積層(Convolution),全連接層(InnerProduct,容易翻譯成內(nèi)積層)相似處有兩個(gè)【1】:都有兩個(gè)param{lr_mult:1

?????????????????????????????????????????? decay_mult:1????????????????????????????

?????????????????????????????? }

???????????????????????????? param{lr_mult: 2

?????????????????????????????????????? ?decay_mult: 0????????????

????????????????????????????? }

【2】:convolution_param{}與inner_product_param{}里面的參數(shù)相似,甚至相同


(3)平均值文件*_mean.binaryproto要放在transform_param{}里,訓(xùn)練與測試數(shù)據(jù)集放在data_param{}里

2.*_deploy.prototxt文件

【1】*_deploy.prototxt文件的構(gòu)造和*_train_test.prototxt文件的構(gòu)造稍有不同首先沒有test網(wǎng)絡(luò)中的test模塊,只有訓(xùn)練模塊

【2】數(shù)據(jù)層的寫法和原來也有不同,更加簡潔:

input: "data"
input_dim: 1
input_dim: 3
input_dim: 32
input_dim: 32

注意紅色部分,那是數(shù)據(jù)層的名字,沒有這個(gè)的話,第一卷積層無法找到數(shù)據(jù),我一開始沒有加這句就報(bào)錯(cuò)。下面的四個(gè)參數(shù)有點(diǎn)類似batch_size(1,3,32,32)里四個(gè)參數(shù)

【3】卷積層和全連接層中weight_filler{}與bias_filler{}兩個(gè)參數(shù)不用再填寫,應(yīng)為這兩個(gè)參數(shù)的值,由已經(jīng)訓(xùn)練好的模型*.caffemodel文件提供

【4】輸出層的變化(1)沒有了test模塊測試精度(2)輸出層

*_train_test.prototxt文件:

layer{
? name: "loss"
? type: "SoftmaxWithLoss"#注意此處與下面的不同
? bottom: "ip2"
? bottom: "label"#注意標(biāo)簽項(xiàng)在下面沒有了,因?yàn)橄旅娴念A(yù)測屬于哪個(gè)標(biāo)簽,因此不能提供標(biāo)簽
? top: "loss"
}

*_deploy.prototxt文件:

layer {
? name: "prob"
? type: "Softmax"
? bottom: "ip2"
? top: "prob"
}

***注意在兩個(gè)文件中輸出層的類型都發(fā)生了變化一個(gè)是SoftmaxWithLoss,另一個(gè)是Softmax。另外為了方便區(qū)分訓(xùn)練與應(yīng)用輸出,訓(xùn)練是輸出時(shí)是loss,應(yīng)用時(shí)是prob。

3、*_slover.prototxt

net: "test.prototxt"
#訓(xùn)練網(wǎng)絡(luò)的配置文件
test_iter: 100
#test_iter 指明在測試階段有多上個(gè)前向過程(也就是有多少圖片)被執(zhí)行。
在MNIST例子里,在網(wǎng)絡(luò)配置文件里已經(jīng)設(shè)置test網(wǎng)絡(luò)的batch size=100,這里test_iter
設(shè)置為100,那在測試階段共有100*100=10000 圖片被處理
test_interval: 500
#每500次訓(xùn)練迭代后,執(zhí)行一次test
base_lr: 0.01
#學(xué)習(xí)率初始化為0.01
momentum:0.9
#u=0.9
weight_decay:0.0005
#
lr_policy: "inv"
gamma: 0.0001
power: 0.75
#以上三個(gè)參數(shù)都和降低學(xué)習(xí)率有關(guān),詳細(xì)的學(xué)習(xí)策略和計(jì)算公式見下面
// 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次迭代,顯示結(jié)果
snapshot: 5000
#每5000次迭代,保存一次快照
snapshot_prefix: "path_prefix"
#快照保存前綴:更準(zhǔn)確的說是快照保存路徑+前綴,應(yīng)為文件名后的名字是固定的
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


總結(jié)

以上是生活随笔為你收集整理的Caffe部署中的几个train-test-solver-prototxt-deploy等说明 (一)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。