Caffe安裝成功測試(CPU環境下mnist測試)
阿新 • • 發佈:2018-12-10
- 測試資料和訓練資料集的獲取:https://pan.baidu.com/s/1hry1f4g 將下載下來並解壓得到的測試和訓練資料mnist-test-leveldb和mnist-train-leveldb複製到.\caffe-master\examples\mnist\目錄下
- 將./caffe-master\windows\目錄下的CommonSettings.props做如下改動並儲存:
true false 7.5 true true(為了呼叫Python介面,將預設的false改為true) C:\ProgramData\Anaconda3\(紅色部分為Python.exe根目錄,注意最後一道斜槓)
(CommonSettings.props檔案修改完成)
- 修改.\caffe-master\examples\mnist\下的lenet_train_test.prototxt 做如下修改:
第13行修改為:
data_param { source: "C:/ProgramData/Caffe/caffe-master/examples/mnist/mnist-train-leveldb" batch_size: 64 backend: LEVELDB }
第30行修改為:
data_param { source: "C:/ProgramData/Caffe/caffe-master/examples/mnist/mnist-train-leveldb" batch_size: 64 backend: LEVELDB }
注意:source屬性值的資料路徑的斜槓是’/’而不是windows下的’\’ 4. GPU和CPU的切換在lenet_solver.prototxt修改,最後一行把GPU改成CPU即可
5.編寫windows下指令碼檔案run.bat
.\Build\x64\Release\caffe.exe train --solver=examples/mnist/lenet_solver.prototxt pause
將run.bat檔案放在./caffe-master/檔案下,雙擊run.bat檔案可以看到訓練的結果如下:
... ... I1030 22:57:11.207583 11204 sgd_solver.cpp:106] Iteration 9600, lr = 0.00603682 I1030 22:57:17.158367 11204 solver.cpp:228] Iteration 9700, loss = 0.00264511 I1030 22:57:17.158869 11204 solver.cpp:244] Train net output #0: loss = 0.00264498 (* 1 = 0.00264498 loss) I1030 22:57:17.159369 11204 sgd_solver.cpp:106] Iteration 9700, lr = 0.00601382 I1030 22:57:23.735081 11204 solver.cpp:228] Iteration 9800, loss = 0.0104211 I1030 22:57:23.735081 11204 solver.cpp:244] Train net output #0: loss = 0.010421 (* 1 = 0.010421 loss) I1030 22:57:23.735581 11204 sgd_solver.cpp:106] Iteration 9800, lr = 0.00599102 I1030 22:57:29.758888 11204 solver.cpp:228] Iteration 9900, loss = 0.00677528 I1030 22:57:29.759388 11204 solver.cpp:244] Train net output #0: loss = 0.00677515 (* 1 = 0.00677515 loss) I1030 22:57:29.759891 11204 sgd_solver.cpp:106] Iteration 9900, lr = 0.00596843 I1030 22:57:35.597347 11204 solver.cpp:454] Snapshotting to binary proto file examples/mnist/lenet_iter_10000.caffemodel I1030 22:57:35.615355 11204 sgd_solver.cpp:273] Snapshotting solver state to binary proto file examples/mnist/lenet_iter_10000.solverstate I1030 22:57:35.664417 11204 solver.cpp:317] Iteration 10000, loss = 0.00254389 I1030 22:57:35.664916 11204 solver.cpp:337] Iteration 10000, Testing net (#0) I1030 22:57:39.652560 11204 solver.cpp:404] Test net output #0: accuracy = 0.9912 I1030 22:57:39.653061 11204 solver.cpp:404] Test net output #1: loss = 0.0287646 (* 1 = 0.0287646 loss) I1030 22:57:39.653559 11204 solver.cpp:322] Optimization Done. I1030 22:57:39.654062 11204 caffe.cpp:255] Optimization Done. C:\ProgramData\Caffe\caffe-master>pause 請按任意鍵繼續. . .
可以看到預測的準確率達到了0.9912 ,測試成功。