詳細說明可參考網頁:http://blog.csdn.net/wangchuansnnu/article/details/44341753
????????????????????????????????http://blog.sina.com.cn/s/blog_49ea41a20102w4uu.html
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? http://www.cnblogs.com/yymn/p/4553671.html
caffe 下 mnist 進行實驗:
MNIST,一個經典的手寫數字庫,包含60000個訓練樣本和10000個測試樣本,圖片大小28*28
均在 caffe根目錄下執行
1.下載數據:sudo sh ./data/mnist/get_mnist.sh
2.生成lmdb文件:sudo sh ./examples/mnist/create_mnist.sh
? 此時在當前文件目錄下生成?mnist_train_lmdb, mnist_test_lmdb 文件
3.配置網絡: letNet網絡的定義
? ?? 在 ./examples/mnist/lenet_train_test_prototxt文件中,可直接打開編輯
? ? sudogedit?./examples/mnist/lenet_train_test_prototxt
? ?本文不修改lenet_train_test_prototxt直接調用,即不改變網絡的結構。
4.運行 ./examples/mnist/train_lenet.sh
? ?sudo sh ./examples/mnist/train_lenet.sh??這是訓練網絡的程序
? ?? ? ? 查看train_lenet.sh ,可用 sudo gedit ./examples/mnist/train_lenet.sh查看
? ?? ? ?#!/usr/bin/env sh
? ?? ? ?? ./build/tools/caffe train--solver=examples/mnist/lenet_solver.prototxt
? ?? ? ?? 可發現上述執行的是examples/mnist/lenet_solver.prototxt,其實使用的是在lenet_solver.prototxt中定義的解決方案。
? ?? ? ?? ?查看lent_solver.prototxt可知,這個是訓練網絡的參數設置,比如學習率,顯示結果參數,是否采用CPU 或者GPU等
? ?本文不修改letnet_solver.prototxt ,即采用默認的解決方案。
5.測試數據集
??有三種接口可以進行測試數據,命令行、Python、MATLAB,本例中采用命令行進行測試,在
?/examples/mnist路徑下,執行:
?sudo sh?./examples/mnist/test_lenent.sh
?
下面是test_lenet.sh的內容
?
./build/tools/caffe test?-model=examples/mnist/lenet_train_test.prototxt?-weights=examples/mnist/lenet_iter_10000.caffemodel?-gpu=0 ?test:表示對訓練好的模型進行Testing,而不是training。其他參數包括train,time, device_query。
-model=XXX:指定模型prototxt文件,這是一個文本文件,詳細描述了網絡結構和數據集信息。
?
?
注意:test_lenent.sh腳本是根據train_lenet.sh腳本對照改寫的。
?
下面給出MNIST結構網絡的圖示,(轉載)
