Caffe技巧之使用snapshot来继续网络训练

Caffe技巧之使用snapshot来继续网络训练

有时候想在已经训练好的网络上继续之前的训练,那么可以使用snapshot的命令,本文介绍在Caffe里如何使用snapshot来继续网络训练。

Step 1:设置solver.prototxt

首先,在solver.prototxt 中设置得到snapshot 文件,例如:

<code class="hljs vala has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;"># snapshot intermediate results</span>
snapshot: <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">500</span></code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

这样每 500 iterations就可以得到model_iter_xxx.caffemodel 和model_iter_xxx.solverstate (例如 cifar10_quick_iter_3000.solverstate)。

Step 2:设置运行脚本sh

这样, 设置好了snapshot,在.sh 再设置一下就可以了,使用它来在原有基础上继续训练则设置如下 
这里写图片描述

特别需要注意的是,图中的反斜杠 \ ,如果丢失了 “\” 那么这个选项的设置将会失效!!

以上面的设置为例,snapshot载入成功的话,Ubuntu的终端里显示的迭代次数将是从3000 iterations开始,如果还是从0 iterations开始那就是设置没有成功。

参考: 
CAFFE notes

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值