以mnist數據集為例:
bat訓練腳本:
Build\x64\Release\caffe.exe train --solver=examples/mnist/lenet_solver.prototxt pause
在這個模型的基礎上,繼續訓練。
繼續訓練之前,也可以修改lenet_solver.prototxt中的學習率。
Build\x64\Release\caffe.exe train --solver=examples/mnist/lenet_solver.prototxt --snapshot=examples/mnist/lenet_iter_1000.solverstate
pause
訓練從1000次iterations開始。
用Python腳本啟動訓練:
import caffe caffe.set_device(int(0)) caffe.set_mode_gpu() solver = caffe.SGDSolver('.\\examples\\mnist\\lenet_solver.prototxt') solver.solve()
加載已訓練的模型,只用加一句話
import caffe caffe.set_device(int(0)) caffe.set_mode_gpu() solver = caffe.SGDSolver('.\\examples\\mnist\\lenet_solver.prototxt') solver.restore('examples\\mnist\\lenet_iter_5000.solverstate') solver.solve()