caffe:自帶數據測試

Step1  下載安裝:

  1. Git bash:https://git-scm.com/download/win 用於在windows中運行shell腳本
  2. Wget:http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-setup.exe   用於從互聯網上下載數據
  3. 安裝並配置環境變量

Step2  下載MNIST數據:

打開 git bash,運行caffe/data/mnist 下的get_mnist.sh文件

Step3   數據格式轉換:

從網絡下載的數據是二進制數據,無法直接在caffe框架下使用,需要轉換成lmdb或者leveldb格式的數據

在\data\mnist目錄下,新建一個create_mnist.bat,內容如下:

..scripts\build\examples\mnist\Release\convert_mnist_data.exe train-images.idx3-ubyte train-labels.idx1-ubyte  ...\examples\mnist\mnist_train_lmdb 

echo. 

..\scripts\build\examples\mnist\Release\convert_mnist_data.exe t10k-images.idx3-ubyte t10k-labels.idx1-ubyte  ..\examples\mnist\mnist_test_lmdb

pause

執行create_mnist.bat文件,在examples\mnist目錄下生成了對應的訓練和測試集數據:

https://img-blog.csdn.net/20161111221937649?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center

Step4    修改文件:

  1. 用notepad打開\examples\mnist下的lenet_train_test.prototxt文件:將下面兩處改爲絕對路徑

    2.  用notepad打開\examples\mnist下的lenet_solver.prototxt文件,將2行和23行設爲絕對路徑,25行設爲CPU

Step5    訓練:

在..\examples\mnist文件夾下編寫run.bat文件

..\scripts\build\tools\Release\caffe.exe  train --solver=..\examples\mnist\lenet_solver.prototxt

Pause

雙擊運行run.bat,訓練結束如下圖所示

訓練完成後,會在..\examples\mnist文件夾下出現5000次和10000次的模型

Step6    測試模型:

在..\examples\mnist文件夾下創建test_mnist.bat文件,內容如下:

..\scripts\build\tools\Release\caffe.exe  test --model=..\examples\mnist\lenet_train_test.prototxt  -weights=..\examples\mnist\lenet_iter_10000.caffemodel

Pause

精度爲0.9869,至此測試結束

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章