MNIST,一個經典的手寫數字庫,包含60000個訓練樣本和10000個測試樣本,圖片大小28*28,在Caffe上配置的第一個案例
1首先,獲取minist的數據包。 這個版本是四個數據包
cd $CAFFE_ROOT
./data/mnist/get_mnist.sh
- #!/usr/bin/env sh
- # This scripts downloads the mnist data and unzips it.
- DIR="$( cd "$(dirname "$0")" ; pwd -P )"
- cd $DIR
- echo "Downloading..."
- wget --no-check-certificate http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
- wget --no-check-certificate http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
- wget --no-check-certificate http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
- wget --no-check-certificate http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
- echo "Unzipping..."
- gunzip train-images-idx3-ubyte.gz
- gunzip train-labels-idx1-ubyte.gz
- gunzip t10k-images-idx3-ubyte.gz
- gunzip t10k-labels-idx1-ubyte.gz
- # Creation is split out because leveldb sometimes causes segfault
- # and needs to be re-created.
- echo "Done."
然后執行
./examples/mnist/create_mnist.sh
- Creating lmdb...
- Done.
在這一步做了什么工作呢?
create_mnist.sh是利用caffe-master/build/examples/mnist/的convert_mnist_data.bin工具,將mnist date轉化為可用的lmdb格式的文件。並將新生成的2個文件mnist-train-lmdb 和 mnist-test-lmdb放於create_mnist.sh同目錄下。
2 數據准備好了,那么接下來的工作就是訓練了。
http://caffe.berkeleyvision.org/gathered/examples/mnist.html
給出來的例子是
./examples/mnist/train_lenet.sh
這個腳本調用的工具如下:
- ./build/tools/caffe train --solver=examples/mnist/lenet_solver.prototxt
還有其他的示例,如:
./examples/mnist/train_mnist_autoencoder.sh
這個腳本調用的工具如下:
- ./build/tools/caffe train \
- --solver=examples/mnist/mnist_autoencoder_solver.prototxt
運行完結果如下:
生成四個文件
lenet_iter_10000.caffemodel
lenet_iter_10000.solverstate
lenet_iter_5000.caffemodel
lenet_iter_5000.solverstate
屏幕顯示每次
.......................
I0126 17:32:32.171516 18290 solver.cpp:246] Iteration 10000, loss = 0.00453533
I0126 17:32:32.171550 18290 solver.cpp:264] Iteration 10000, Testing net (#0)
I0126 17:32:40.498195 18290 solver.cpp:315] Test net output #0: accuracy = 0.9903
I0126 17:32:40.498236 18290 solver.cpp:315] Test net output #1: loss = 0.0309918 (* 1 = 0.0309918 loss)
I0126 17:32:40.498245 18290 solver.cpp:251] Optimization Done.
I0126 17:32:40.498249 18290 caffe.cpp:121] Optimization Done.
首先討論訓練的網絡模型:LeNet: the MNIST Classification Model http://yann.lecun.com/exdb/publis/pdf/lecun-01a.pdf
LeNet 模型之前在手寫識別上就有非常好的表現。caffe 這里提供的是一個改進版的LeNet模型,其中的 sigmoid 被rectified linear units (ReLUs) 替換。
(標准的sigmoid輸出不具備稀疏性,需要用一些懲罰因子來訓練出一大堆接近0的冗余數據來,從而產生稀疏數據,例如L1、L1/L2或Student-t作懲罰因子。因此需要進行無監督的預訓練。多層的神經網絡如果用sigmoid或tanh激活函數也不做pre-training的話會因為 gradient vanishing problem 而會無法收斂。ReLU則這沒有這個問題。ReLU是線性修正,公式為:g(x) = max(0, x),是purelin的折線版。它的作用是如果計算出的值小於0,就讓它等於0,否則保持原來的值不變。這是一種簡單粗暴地強制某些數據為0的方法,然而經實踐證明,訓練后的網絡完全具備適度的稀疏性。而且訓練后的可視化效果和傳統方式預訓練出的效果很相似,這也說明了ReLU具備引導適度稀疏的能力。 來自討論 http://tieba.baidu.com/p/3061925556)
LeNet的結構和CNN的結構是由相似之處的,是由兩個 convolutional layer 和 pooling layer交錯連接 ,然后兩個fully connected layers結構組成。 具體可參見http://deeplearning.net/tutorial/lenet.html,此外DeepID 有個簡單直觀的結構圖,可以輔助了解 http://blog.csdn.net/stdcoutzyx/article/details/42091205
定義MNIST網絡和MNIST Solver:
從 ./examples/mnist/train_lenet.sh 腳本調用的指令我們就可以看到,solver是定義在了$CAFFE_ROOT/examples/mnist/lenet_solver.prototxt 中。
- # The train/test net protocol buffer definition
- net: "examples/mnist/lenet_train_test.prototxt" //網絡協議具體定義
- # test_iter specifies how many forward passes the test should carry out.
- # In the case of MNIST, we have test batch size 100 and 100 test iterations,
- # covering the full 10,000 testing images.
- test_iter: 100 //test迭代次數 如果batch_size =100,則100張圖一批,訓練100次,則可以覆蓋10000張圖的需求
- # Carry out testing every 500 training iterations.
- test_interval: 500 //訓練迭代500次,測試一次
- # The base learning rate, momentum and the weight decay of the network. //網絡參數:學習率,動量,權重的衰減
- base_lr: 0.01
- momentum: 0.9
- weight_decay: 0.0005
- # The learning rate policy //學習策略:有固定學習率和每步遞減學習率
- lr_policy: "inv"
- gamma: 0.0001
- power: 0.75
- # Display every 100 iterations //每迭代100次顯示一次
- display: 100
- # The maximum number of iterations //最大迭代次數
- max_iter: 10000
- # snapshot intermediate results // 每5000次迭代存儲一次數據,路徑前綴是<span style="font-family: Arial, Helvetica, sans-serif;">examples/mnist/lenet</span>
- snapshot: 5000
- snapshot_prefix: "examples/mnist/lenet"
- solver_mode: CPU
再看一下./examples/mnist/train_mnist_autoencoder.sh 調用的 mnist_autoencoder_solver.prototxt 的solver定義
- net: "examples/mnist/mnist_autoencoder.prototxt"
- test_state: { stage: 'test-on-train' }
- test_iter: 500
- test_state: { stage: 'test-on-test' }
- test_iter: 100
- test_interval: 500
- test_compute_loss: true
- base_lr: 0.01
- lr_policy: "step"
- gamma: 0.1
- stepsize: 10000
- display: 100
- max_iter: 65000
- weight_decay: 0.0005
- snapshot: 10000
- snapshot_prefix: "examples/mnist/mnist_autoencoder"
- momentum: 0.9
- # solver mode: CPU or GPU
- solver_mode: GPU
MNIST網絡定義在 $CAFFE_ROOT/examples/mnist/lenet_train_test.prototxt. solver的第二行已經注明
具體解釋 可以參見http://caffe.berkeleyvision.org/gathered/examples/mnist.html
$CAFFE_ROOT/examples/mnist/lenet_train_test.prototx
- name: "LeNet"
- layers {
- name: "mnist"
- type: DATA
- top: "data"
- top: "label"
- data_param {
- source: "examples/mnist/mnist_train_lmdb"
- backend: LMDB
- batch_size: 64
- }
- transform_param {
- scale: 0.00390625
- }
- include: { phase: TRAIN }
- }
- layers {
- name: "mnist"
- type: DATA
- top: "data"
- top: "label"
- data_param {
- source: "examples/mnist/mnist_test_lmdb"
- backend: LMDB
- batch_size: 100
- }
- transform_param {
- scale: 0.00390625
- }
- include: { phase: TEST }
- }
- layers {
- name: "conv1"
- type: CONVOLUTION
- bottom: "data"
- top: "conv1"
- blobs_lr: 1
- blobs_lr: 2
- convolution_param {
- num_output: 20
- kernel_size: 5
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- }
- }
- }
- layers {
- name: "pool1"
- type: POOLING
- bottom: "conv1"
- top: "pool1"
- pooling_param {
- pool: MAX
- kernel_size: 2
- stride: 2
- }
- }
- layers {
- name: "conv2"
- type: CONVOLUTION
- bottom: "pool1"
- top: "conv2"
- blobs_lr: 1
- blobs_lr: 2
- convolution_param {
- num_output: 50
- kernel_size: 5
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- }
- }
- }
- layers {
- name: "pool2"
- type: POOLING
- bottom: "conv2"
- top: "pool2"
- pooling_param {
- pool: MAX
- kernel_size: 2
- stride: 2
- }
- }
- layers {
- name: "ip1"
- type: INNER_PRODUCT
- bottom: "pool2"
- top: "ip1"
- blobs_lr: 1
- blobs_lr: 2
- inner_product_param {
- num_output: 500
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- }
- }
- }
- layers {
- name: "relu1"
- type: RELU
- bottom: "ip1"
- top: "ip1"
- }
- layers {
- name: "ip2"
- type: INNER_PRODUCT
- bottom: "ip1"
- top: "ip2"
- blobs_lr: 1
- blobs_lr: 2
- inner_product_param {
- num_output: 10
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- }
- }
- }
- layers {
- name: "accuracy"
- type: ACCURACY
- bottom: "ip2"
- bottom: "label"
- top: "accuracy"
- include: { phase: TEST }
- }
- layers {
- name: "loss"
- type: SOFTMAX_LOSS
- bottom: "ip2"
- bottom: "label"
- top: "loss"
- }
而examples/mnist/mnist_autoencoder.prototxt 的網絡定義則復雜許多:我們也可以看到,里面采用的是sigmoid 而不是 RELU
- name: "MNISTAutoencoder"
- layers {
- top: "data"
- name: "data"
- type: DATA
- data_param {
- source: "examples/mnist/mnist_train_lmdb"
- backend: LMDB
- batch_size: 100
- }
- transform_param {
- scale: 0.0039215684
- }
- include: { phase: TRAIN }
- }
- layers {
- top: "data"
- name: "data"
- type: DATA
- data_param {
- source: "examples/mnist/mnist_train_lmdb"
- backend: LMDB
- batch_size: 100
- scale: 0.0039215684
- }
- include: {
- phase: TEST
- stage: 'test-on-train'
- }
- }
- layers {
- top: "data"
- name: "data"
- type: DATA
- data_param {
- source: "examples/mnist/mnist_test_lmdb"
- backend: LMDB
- batch_size: 100
- }
- transform_param {
- scale: 0.0039215684
- }
- include: {
- phase: TEST
- stage: 'test-on-test'
- }
- }
- layers {
- bottom: "data"
- top: "flatdata"
- name: "flatdata"
- type: FLATTEN
- }
- layers {
- bottom: "data"
- top: "encode1"
- name: "encode1"
- type: INNER_PRODUCT
- blobs_lr: 1
- blobs_lr: 1
- weight_decay: 1
- weight_decay: 0
- inner_product_param {
- num_output: 1000
- weight_filler {
- type: "gaussian"
- std: 1
- sparse: 15
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
- }
- layers {
- bottom: "encode1"
- top: "encode1neuron"
- name: "encode1neuron"
- type: SIGMOID
- }
- layers {
- bottom: "encode1neuron"
- top: "encode2"
- name: "encode2"
- type: INNER_PRODUCT
- blobs_lr: 1
- blobs_lr: 1
- weight_decay: 1
- weight_decay: 0
- inner_product_param {
- num_output: 500
- weight_filler {
- type: "gaussian"
- std: 1
- sparse: 15
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
- }
- layers {
- bottom: "encode2"
- top: "encode2neuron"
- name: "encode2neuron"
- type: SIGMOID
- }
- layers {
- bottom: "encode2neuron"
- top: "encode3"
- name: "encode3"
- type: INNER_PRODUCT
- blobs_lr: 1
- blobs_lr: 1
- weight_decay: 1
- weight_decay: 0
- inner_product_param {
- num_output: 250
- weight_filler {
- type: "gaussian"
- std: 1
- sparse: 15
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
- }
- layers {
- bottom: "encode3"
- top: "encode3neuron"
- name: "encode3neuron"
- type: SIGMOID
- }
- layers {
- bottom: "encode3neuron"
- top: "encode4"
- name: "encode4"
- type: INNER_PRODUCT
- blobs_lr: 1
- blobs_lr: 1
- weight_decay: 1
- weight_decay: 0
- inner_product_param {
- num_output: 30
- weight_filler {
- type: "gaussian"
- std: 1
- sparse: 15
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
- }
- layers {
- bottom: "encode4"
- top: "decode4"
- name: "decode4"
- type: INNER_PRODUCT
- blobs_lr: 1
- blobs_lr: 1
- weight_decay: 1
- weight_decay: 0
- inner_product_param {
- num_output: 250
- weight_filler {
- type: "gaussian"
- std: 1
- sparse: 15
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
- }
- layers {
- bottom: "decode4"
- top: "decode4neuron"
- name: "decode4neuron"
- type: SIGMOID
- }
- layers {
- bottom: "decode4neuron"
- top: "decode3"
- name: "decode3"
- type: INNER_PRODUCT
- blobs_lr: 1
- blobs_lr: 1
- weight_decay: 1
- weight_decay: 0
- inner_product_param {
- num_output: 500
- weight_filler {
- type: "gaussian"
- std: 1
- sparse: 15
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
- }
- layers {
- bottom: "decode3"
- top: "decode3neuron"
- name: "decode3neuron"
- type: SIGMOID
- }
- layers {
- bottom: "decode3neuron"
- top: "decode2"
- name: "decode2"
- type: INNER_PRODUCT
- blobs_lr: 1
- blobs_lr: 1
- weight_decay: 1
- weight_decay: 0
- inner_product_param {
- num_output: 1000
- weight_filler {
- type: "gaussian"
- std: 1
- sparse: 15
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
- }
- layers {
- bottom: "decode2"
- top: "decode2neuron"
- name: "decode2neuron"
- type: SIGMOID
- }
- layers {
- bottom: "decode2neuron"
- top: "decode1"
- name: "decode1"
- type: INNER_PRODUCT
- blobs_lr: 1
- blobs_lr: 1
- weight_decay: 1
- weight_decay: 0
- inner_product_param {
- num_output: 784
- weight_filler {
- type: "gaussian"
- std: 1
- sparse: 15
- }
- bias_filler {
- type: "constant"
- value: 0
- }
- }
- }
- layers {
- bottom: "decode1"
- bottom: "flatdata"
- top: "cross_entropy_loss"
- name: "loss"
- type: SIGMOID_CROSS_ENTROPY_LOSS
- loss_weight: 1
- }
- layers {
- bottom: "decode1"
- top: "decode1neuron"
- name: "decode1neuron"
- type: SIGMOID
- }
- layers {
- bottom: "decode1neuron"
- bottom: "flatdata"
- top: "l2_error"
- name: "loss"
- type: EUCLIDEAN_LOSS
- loss_weight: 0
- }
當所有數據都訓練好之后,接下來就是如何將模型應用到實際數據了:
./build/tools/caffe.bin test -model=examples/mnist/lenet_train_test.prototxt -weights=examples/mnist/lenet_iter_10000.caffemodel -gpu=0
如果沒有GPU則使用
./build/tools/caffe.bin test -model=examples/mnist/lenet_train_test.prototxt -weights=examples/mnist/lenet_iter_10000.caffemodel
test:表示對訓練好的模型進行Testing,而不是training。其他參數包括train, time, device_query。
-model=XXX:指定模型prototxt文件,這是一個文本文件,詳細描述了網絡結構和數據集信息。
輸出如下:
- I0303 18:26:31.961637 27313 caffe.cpp:138] Use CPU.
- I0303 18:26:32.035434 27313 net.cpp:275] The NetState phase (1) differed from the phase (0) specified by a rule in layer mnist
- I0303 18:26:32.035794 27313 net.cpp:39] Initializing net from parameters:
- name: "LeNet"
- layers {
- top: "data"
- top: "label"
- name: "mnist"
- type: DATA
- data_param {
- source: "examples/mnist/mnist_test_lmdb"
- batch_size: 100
- backend: LMDB
- }
- include {
- phase: TEST
- }
- transform_param {
- scale: 0.00390625
- }
- }
- layers {
- bottom: "data"
- top: "conv1"
- name: "conv1"
- type: CONVOLUTION
- blobs_lr: 1
- blobs_lr: 2
- convolution_param {
- num_output: 20
- kernel_size: 5
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- }
- }
- }
- layers {
- bottom: "conv1"
- top: "pool1"
- name: "pool1"
- type: POOLING
- pooling_param {
- pool: MAX
- kernel_size: 2
- stride: 2
- }
- }
- layers {
- bottom: "pool1"
- top: "conv2"
- name: "conv2"
- type: CONVOLUTION
- blobs_lr: 1
- blobs_lr: 2
- convolution_param {
- num_output: 50
- kernel_size: 5
- stride: 1
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- }
- }
- }
- layers {
- bottom: "conv2"
- top: "pool2"
- name: "pool2"
- type: POOLING
- pooling_param {
- pool: MAX
- kernel_size: 2
- stride: 2
- }
- }
- layers {
- bottom: "pool2"
- top: "ip1"
- name: "ip1"
- type: INNER_PRODUCT
- blobs_lr: 1
- blobs_lr: 2
- inner_product_param {
- num_output: 500
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- }
- }
- }
- layers {
- bottom: "ip1"
- top: "ip1"
- name: "relu1"
- type: RELU
- }
- layers {
- bottom: "ip1"
- top: "ip2"
- name: "ip2"
- type: INNER_PRODUCT
- blobs_lr: 1
- blobs_lr: 2
- inner_product_param {
- num_output: 10
- weight_filler {
- type: "xavier"
- }
- bias_filler {
- type: "constant"
- }
- }
- }
- layers {
- bottom: "ip2"
- bottom: "label"
- top: "accuracy"
- name: "accuracy"
- type: ACCURACY
- include {
- phase: TEST
- }
- }
- layers {
- bottom: "ip2"
- bottom: "label"
- top: "loss"
- name: "loss"
- type: SOFTMAX_LOSS
- }
- I0303 18:26:32.035923 27313 net.cpp:67] Creating Layer mnist
- I0303 18:26:32.035931 27313 net.cpp:356] mnist -> data
- I0303 18:26:32.035948 27313 net.cpp:356] mnist -> label
- I0303 18:26:32.035955 27313 net.cpp:96] Setting up mnist
- I0303 18:26:32.076159 27313 data_layer.cpp:68] Opening lmdb examples/mnist/mnist_test_lmdb
- I0303 18:26:32.084071 27313 data_layer.cpp:128] output data size: 100,1,28,28
- I0303 18:26:32.084214 27313 net.cpp:103] Top shape: 100 1 28 28 (78400)
- I0303 18:26:32.084223 27313 net.cpp:103] Top shape: 100 1 1 1 (100)
- I0303 18:26:32.084249 27313 net.cpp:67] Creating Layer label_mnist_1_split
- I0303 18:26:32.084257 27313 net.cpp:394] label_mnist_1_split <- label
- I0303 18:26:32.084269 27313 net.cpp:356] label_mnist_1_split -> label_mnist_1_split_0
- I0303 18:26:32.084280 27313 net.cpp:356] label_mnist_1_split -> label_mnist_1_split_1
- I0303 18:26:32.084286 27313 net.cpp:96] Setting up label_mnist_1_split
- I0303 18:26:32.084292 27313 net.cpp:103] Top shape: 100 1 1 1 (100)
- I0303 18:26:32.084297 27313 net.cpp:103] Top shape: 100 1 1 1 (100)
- I0303 18:26:32.084306 27313 net.cpp:67] Creating Layer conv1
- I0303 18:26:32.084311 27313 net.cpp:394] conv1 <- data
- I0303 18:26:32.084317 27313 net.cpp:356] conv1 -> conv1
- I0303 18:26:32.084326 27313 net.cpp:96] Setting up conv1
- I0303 18:26:32.084775 27313 net.cpp:103] Top shape: 100 20 24 24 (1152000)
- I0303 18:26:32.084791 27313 net.cpp:67] Creating Layer pool1
- I0303 18:26:32.084796 27313 net.cpp:394] pool1 <- conv1
- I0303 18:26:32.084803 27313 net.cpp:356] pool1 -> pool1
- I0303 18:26:32.084810 27313 net.cpp:96] Setting up pool1
- I0303 18:26:32.099537 27313 net.cpp:103] Top shape: 100 20 12 12 (288000)
- I0303 18:26:32.099583 27313 net.cpp:67] Creating Layer conv2
- I0303 18:26:32.099593 27313 net.cpp:394] conv2 <- pool1
- I0303 18:26:32.099606 27313 net.cpp:356] conv2 -> conv2
- I0303 18:26:32.099619 27313 net.cpp:96] Setting up conv2
- I0303 18:26:32.099905 27313 net.cpp:103] Top shape: 100 50 8 8 (320000)
- I0303 18:26:32.099925 27313 net.cpp:67] Creating Layer pool2
- I0303 18:26:32.099947 27313 net.cpp:394] pool2 <- conv2
- I0303 18:26:32.099959 27313 net.cpp:356] pool2 -> pool2
- I0303 18:26:32.099970 27313 net.cpp:96] Setting up pool2
- I0303 18:26:32.099979 27313 net.cpp:103] Top shape: 100 50 4 4 (80000)
- I0303 18:26:32.099990 27313 net.cpp:67] Creating Layer ip1
- I0303 18:26:32.099998 27313 net.cpp:394] ip1 <- pool2
- I0303 18:26:32.100008 27313 net.cpp:356] ip1 -> ip1
- I0303 18:26:32.100019 27313 net.cpp:96] Setting up ip1
- I0303 18:26:32.104487 27313 net.cpp:103] Top shape: 100 500 1 1 (50000)
- I0303 18:26:32.104518 27313 net.cpp:67] Creating Layer relu1
- I0303 18:26:32.104527 27313 net.cpp:394] relu1 <- ip1
- I0303 18:26:32.104538 27313 net.cpp:345] relu1 -> ip1 (in-place)
- I0303 18:26:32.104549 27313 net.cpp:96] Setting up relu1
- I0303 18:26:32.104558 27313 net.cpp:103] Top shape: 100 500 1 1 (50000)
- I0303 18:26:32.104571 27313 net.cpp:67] Creating Layer ip2
- I0303 18:26:32.104579 27313 net.cpp:394] ip2 <- ip1
- I0303 18:26:32.104591 27313 net.cpp:356] ip2 -> ip2
- I0303 18:26:32.104604 27313 net.cpp:96] Setting up ip2
- I0303 18:26:32.104676 27313 net.cpp:103] Top shape: 100 10 1 1 (1000)
- I0303 18:26:32.104691 27313 net.cpp:67] Creating Layer ip2_ip2_0_split
- I0303 18:26:32.104701 27313 net.cpp:394] ip2_ip2_0_split <- ip2
- I0303 18:26:32.104710 27313 net.cpp:356] ip2_ip2_0_split -> ip2_ip2_0_split_0
- I0303 18:26:32.104722 27313 net.cpp:356] ip2_ip2_0_split -> ip2_ip2_0_split_1
- I0303 18:26:32.104733 27313 net.cpp:96] Setting up ip2_ip2_0_split
- I0303 18:26:32.104743 27313 net.cpp:103] Top shape: 100 10 1 1 (1000)
- I0303 18:26:32.104751 27313 net.cpp:103] Top shape: 100 10 1 1 (1000)
- I0303 18:26:32.104763 27313 net.cpp:67] Creating Layer accuracy
- I0303 18:26:32.104770 27313 net.cpp:394] accuracy <- ip2_ip2_0_split_0
- I0303 18:26:32.104779 27313 net.cpp:394] accuracy <- label_mnist_1_split_0
- I0303 18:26:32.104790 27313 net.cpp:356] accuracy -> accuracy
- I0303 18:26:32.104802 27313 net.cpp:96] Setting up accuracy
- I0303 18:26:32.104811 27313 net.cpp:103] Top shape: 1 1 1 1 (1)
- I0303 18:26:32.104822 27313 net.cpp:67] Creating Layer loss
- I0303 18:26:32.104830 27313 net.cpp:394] loss <- ip2_ip2_0_split_1
- I0303 18:26:32.104838 27313 net.cpp:394] loss <- label_mnist_1_split_1
- I0303 18:26:32.104848 27313 net.cpp:356] loss -> loss
- I0303 18:26:32.104857 27313 net.cpp:96] Setting up loss
- I0303 18:26:32.104869 27313 net.cpp:103] Top shape: 1 1 1 1 (1)
- I0303 18:26:32.104877 27313 net.cpp:109] with loss weight 1
- I0303 18:26:32.104909 27313 net.cpp:170] loss needs backward computation.
- I0303 18:26:32.104918 27313 net.cpp:172] accuracy does not need backward computation.
- I0303 18:26:32.104925 27313 net.cpp:170] ip2_ip2_0_split needs backward computation.
- I0303 18:26:32.104933 27313 net.cpp:170] ip2 needs backward computation.
- I0303 18:26:32.104941 27313 net.cpp:170] relu1 needs backward computation.
- I0303 18:26:32.104948 27313 net.cpp:170] ip1 needs backward computation.
- I0303 18:26:32.104956 27313 net.cpp:170] pool2 needs backward computation.
- I0303 18:26:32.104964 27313 net.cpp:170] conv2 needs backward computation.
- I0303 18:26:32.104975 27313 net.cpp:170] pool1 needs backward computation.
- I0303 18:26:32.104984 27313 net.cpp:170] conv1 needs backward computation.
- I0303 18:26:32.104991 27313 net.cpp:172] label_mnist_1_split does not need backward computation.
- I0303 18:26:32.105000 27313 net.cpp:172] mnist does not need backward computation.
- I0303 18:26:32.105006 27313 net.cpp:208] This network produces output accuracy
- I0303 18:26:32.105017 27313 net.cpp:208] This network produces output loss
- I0303 18:26:32.105034 27313 net.cpp:467] Collecting Learning Rate and Weight Decay.
- I0303 18:26:32.105046 27313 net.cpp:219] Network initialization done.
- I0303 18:26:32.105053 27313 net.cpp:220] Memory required for data: 8086808
- I0303 18:26:32.136730 27313 caffe.cpp:145] Running for 50 iterations.
- I0303 18:26:32.243196 27313 caffe.cpp:169] Batch 0, accuracy = 1
- I0303 18:26:32.243229 27313 caffe.cpp:169] Batch 0, loss = 0.0140614
- I0303 18:26:32.326557 27313 caffe.cpp:169] Batch 1, accuracy = 1
- I0303 18:26:32.326588 27313 caffe.cpp:169] Batch 1, loss = 0.00749996
- I0303 18:26:32.409931 27313 caffe.cpp:169] Batch 2, accuracy = 0.99
- I0303 18:26:32.409963 27313 caffe.cpp:169] Batch 2, loss = 0.0106815
- I0303 18:26:32.493257 27313 caffe.cpp:169] Batch 3, accuracy = 0.99
- I0303 18:26:32.493288 27313 caffe.cpp:169] Batch 3, loss = 0.0528439
- I0303 18:26:32.576733 27313 caffe.cpp:169] Batch 4, accuracy = 0.99
- I0303 18:26:32.576761 27313 caffe.cpp:169] Batch 4, loss = 0.0632355
- I0303 18:26:32.660257 27313 caffe.cpp:169] Batch 5, accuracy = 0.99
- I0303 18:26:32.660289 27313 caffe.cpp:169] Batch 5, loss = 0.041726
- I0303 18:26:32.743624 27313 caffe.cpp:169] Batch 6, accuracy = 0.97
- I0303 18:26:32.743654 27313 caffe.cpp:169] Batch 6, loss = 0.0816639
- I0303 18:26:32.827059 27313 caffe.cpp:169] Batch 7, accuracy = 0.99
- I0303 18:26:32.827090 27313 caffe.cpp:169] Batch 7, loss = 0.0146397
- I0303 18:26:32.910567 27313 caffe.cpp:169] Batch 8, accuracy = 1
- I0303 18:26:32.910598 27313 caffe.cpp:169] Batch 8, loss = 0.00730312
- I0303 18:26:32.993976 27313 caffe.cpp:169] Batch 9, accuracy = 0.99
- I0303 18:26:32.994007 27313 caffe.cpp:169] Batch 9, loss = 0.0225503
- I0303 18:26:33.077335 27313 caffe.cpp:169] Batch 10, accuracy = 0.98
- I0303 18:26:33.077366 27313 caffe.cpp:169] Batch 10, loss = 0.0657359
- I0303 18:26:33.160778 27313 caffe.cpp:169] Batch 11, accuracy = 0.98
- I0303 18:26:33.160809 27313 caffe.cpp:169] Batch 11, loss = 0.0431129
- I0303 18:26:33.244256 27313 caffe.cpp:169] Batch 12, accuracy = 0.96
- I0303 18:26:33.244284 27313 caffe.cpp:169] Batch 12, loss = 0.132687
- I0303 18:26:33.327652 27313 caffe.cpp:169] Batch 13, accuracy = 0.98
- I0303 18:26:33.327684 27313 caffe.cpp:169] Batch 13, loss = 0.0907693
- I0303 18:26:33.411123 27313 caffe.cpp:169] Batch 14, accuracy = 0.99
- I0303 18:26:33.411151 27313 caffe.cpp:169] Batch 14, loss = 0.0150445
- I0303 18:26:33.494606 27313 caffe.cpp:169] Batch 15, accuracy = 0.98
- I0303 18:26:33.494635 27313 caffe.cpp:169] Batch 15, loss = 0.0465094
- I0303 18:26:33.578012 27313 caffe.cpp:169] Batch 16, accuracy = 0.99
- I0303 18:26:33.578042 27313 caffe.cpp:169] Batch 16, loss = 0.0343866
- I0303 18:26:33.661423 27313 caffe.cpp:169] Batch 17, accuracy = 0.99
- I0303 18:26:33.661454 27313 caffe.cpp:169] Batch 17, loss = 0.0277292
- I0303 18:26:33.744851 27313 caffe.cpp:169] Batch 18, accuracy = 1
- I0303 18:26:33.744882 27313 caffe.cpp:169] Batch 18, loss = 0.0146081
- I0303 18:26:33.828307 27313 caffe.cpp:169] Batch 19, accuracy = 0.99
- I0303 18:26:33.828338 27313 caffe.cpp:169] Batch 19, loss = 0.0457058
- I0303 18:26:33.911772 27313 caffe.cpp:169] Batch 20, accuracy = 0.98
- I0303 18:26:33.911800 27313 caffe.cpp:169] Batch 20, loss = 0.086042
- I0303 18:26:33.995313 27313 caffe.cpp:169] Batch 21, accuracy = 0.98
- I0303 18:26:33.995343 27313 caffe.cpp:169] Batch 21, loss = 0.0756276
- I0303 18:26:34.078820 27313 caffe.cpp:169] Batch 22, accuracy = 0.99
- I0303 18:26:34.078850 27313 caffe.cpp:169] Batch 22, loss = 0.0306264
- I0303 18:26:34.162230 27313 caffe.cpp:169] Batch 23, accuracy = 0.98
- I0303 18:26:34.162261 27313 caffe.cpp:169] Batch 23, loss = 0.0438904
- I0303 18:26:34.245688 27313 caffe.cpp:169] Batch 24, accuracy = 0.98
- I0303 18:26:34.245718 27313 caffe.cpp:169] Batch 24, loss = 0.0494635
- I0303 18:26:34.329123 27313 caffe.cpp:169] Batch 25, accuracy = 0.99
- I0303 18:26:34.329152 27313 caffe.cpp:169] Batch 25, loss = 0.0670097
- I0303 18:26:34.412616 27313 caffe.cpp:169] Batch 26, accuracy = 0.99
- I0303 18:26:34.412647 27313 caffe.cpp:169] Batch 26, loss = 0.117325
- I0303 18:26:34.496093 27313 caffe.cpp:169] Batch 27, accuracy = 0.99
- I0303 18:26:34.496122 27313 caffe.cpp:169] Batch 27, loss = 0.0199489
- I0303 18:26:34.579558 27313 caffe.cpp:169] Batch 28, accuracy = 0.98
- I0303 18:26:34.579587 27313 caffe.cpp:169] Batch 28, loss = 0.0489519
- I0303 18:26:34.663027 27313 caffe.cpp:169] Batch 29, accuracy = 0.96
- I0303 18:26:34.663051 27313 caffe.cpp:169] Batch 29, loss = 0.103231
- I0303 18:26:34.746485 27313 caffe.cpp:169] Batch 30, accuracy = 1
- I0303 18:26:34.746516 27313 caffe.cpp:169] Batch 30, loss = 0.0104769
- I0303 18:26:34.829927 27313 caffe.cpp:169] Batch 31, accuracy = 1
- I0303 18:26:34.829990 27313 caffe.cpp:169] Batch 31, loss = 0.00431556
- I0303 18:26:34.913399 27313 caffe.cpp:169] Batch 32, accuracy = 0.98
- I0303 18:26:34.913429 27313 caffe.cpp:169] Batch 32, loss = 0.027013
- I0303 18:26:34.996893 27313 caffe.cpp:169] Batch 33, accuracy = 1
- I0303 18:26:34.996923 27313 caffe.cpp:169] Batch 33, loss = 0.00294145
- I0303 18:26:35.080307 27313 caffe.cpp:169] Batch 34, accuracy = 0.99
- I0303 18:26:35.080338 27313 caffe.cpp:169] Batch 34, loss = 0.0528829
- I0303 18:26:35.163833 27313 caffe.cpp:169] Batch 35, accuracy = 0.93
- I0303 18:26:35.163862 27313 caffe.cpp:169] Batch 35, loss = 0.164353
- I0303 18:26:35.247449 27313 caffe.cpp:169] Batch 36, accuracy = 1
- I0303 18:26:35.247481 27313 caffe.cpp:169] Batch 36, loss = 0.00703398
- I0303 18:26:35.331092 27313 caffe.cpp:169] Batch 37, accuracy = 0.97
- I0303 18:26:35.331121 27313 caffe.cpp:169] Batch 37, loss = 0.0861889
- I0303 18:26:35.414821 27313 caffe.cpp:169] Batch 38, accuracy = 0.99
- I0303 18:26:35.414850 27313 caffe.cpp:169] Batch 38, loss = 0.028661
- I0303 18:26:35.498474 27313 caffe.cpp:169] Batch 39, accuracy = 0.99
- I0303 18:26:35.498502 27313 caffe.cpp:169] Batch 39, loss = 0.0414709
- I0303 18:26:35.582015 27313 caffe.cpp:169] Batch 40, accuracy = 1
- I0303 18:26:35.582042 27313 caffe.cpp:169] Batch 40, loss = 0.0357227
- I0303 18:26:35.665555 27313 caffe.cpp:169] Batch 41, accuracy = 0.99
- I0303 18:26:35.665585 27313 caffe.cpp:169] Batch 41, loss = 0.0525798
- I0303 18:26:35.749254 27313 caffe.cpp:169] Batch 42, accuracy = 1
- I0303 18:26:35.749285 27313 caffe.cpp:169] Batch 42, loss = 0.0257062
- I0303 18:26:35.833019 27313 caffe.cpp:169] Batch 43, accuracy = 0.99
- I0303 18:26:35.833048 27313 caffe.cpp:169] Batch 43, loss = 0.0198026
- I0303 18:26:35.916801 27313 caffe.cpp:169] Batch 44, accuracy = 1
- I0303 18:26:35.916833 27313 caffe.cpp:169] Batch 44, loss = 0.0178475
- I0303 18:26:36.000491 27313 caffe.cpp:169] Batch 45, accuracy = 0.97
- I0303 18:26:36.000522 27313 caffe.cpp:169] Batch 45, loss = 0.0608676
- I0303 18:26:36.085665 27313 caffe.cpp:169] Batch 46, accuracy = 1
- I0303 18:26:36.085697 27313 caffe.cpp:169] Batch 46, loss = 0.0100693
- I0303 18:26:36.169760 27313 caffe.cpp:169] Batch 47, accuracy = 0.98
- I0303 18:26:36.169791 27313 caffe.cpp:169] Batch 47, loss = 0.0211241
- I0303 18:26:36.277791 27313 caffe.cpp:169] Batch 48, accuracy = 0.95
- I0303 18:26:36.277822 27313 caffe.cpp:169] Batch 48, loss = 0.111764
- I0303 18:26:36.361287 27313 caffe.cpp:169] Batch 49, accuracy = 1
- I0303 18:26:36.361318 27313 caffe.cpp:169] Batch 49, loss = 0.0052372
- I0303 18:26:36.361326 27313 caffe.cpp:174] Loss: 0.0452134
- I0303 18:26:36.361332 27313 caffe.cpp:186] accuracy = 0.986
- I0303 18:26:36.361341 27313 caffe.cpp:186] loss = 0.0452134 (* 1 = 0.0452134 loss)
- [root@localhost caffe]#
參考文獻:
學習筆記4 學習搭建自己的網絡——MNIST在caffe上進行訓練與學習-薛開宇
http://wenku.baidu.com/link?url=_sERcBsTCgKElwFi7Hf9FXFe3J-c35ftm27Trf8SJX_iGsR2SlKDDIJmF-5DYruWK-uYJu5pYA3MMfcYt_IRiTL95tYVZ72TYwVTxf0JF27
Deep Learning(深度學習)學習筆記整理系列之LeNet-5卷積參數個人理解 :http://blog.csdn.net/qiaofangjie/article/details/16826849
Deep Learning論文筆記之(四)CNN卷積神經網絡推導和實現:http://blog.csdn.net/zouxy09/article/details/9993371
Deep Learning論文筆記之(六)Multi-Stage多級架構分析:http://blog.csdn.net/zouxy09/article/details/10007237
cuda-convnet 卷積神經網絡 一般性結構卷積核個數 和 輸入輸出的關系以及輸入輸出的個數的說明: http://blog.csdn.net/zhubenfulovepoem/article/details/29583429
DeepID http://blog.csdn.net/stdcoutzyx/article/details/42091205