Hi, I've been studying deep on Caffe recently, ran a mnist handwriting recognition example, but at that time on the Internet search, only to tell you how to do the steps, but the specific Caffe execution program is not step-by-step to tell you what it means, I now to sum up, still learning, wrong welcome correct.
The overall framework is as follows:
First we need to download the database, after downloading, use create_mnist.sh to convert format to LMDB format and generate Mnist_test_lmdb and Mnist_train_lmdb two folders, the second step we write lenet_ Solver.prototxt and Lenet_train_test.prototxt files build a learning framework, and finally run train_lenet.sh for training. These steps and codes are detailed on the web and are not discussed here.
Here's a parse of Lenet_solver.prototxt and Lenet_train_test.prototxt.
In Lenet_train_test.prototxt, first of all, the data layer
layer{
Name: "Mnist" #层名称, take whatever you want.
Type: "Data" #层类型
Top: "Data" #在前向传播中, the output data type is top, input data type is bottom
Top: "Label" #在后向传播中, output data type is bottom, output data type is top
include{
phase:train# Indicates whether this layer is for training or testing, if no include indicates that the training test is available
}
transform_param{
scale:o.oo390625# data preprocessing, transform the data into a defined range, for example, here scale is 1/255, the input data will be 0-255 normalized to 0-1
}
data_param{
Source: "Mnist/mnist_train_lmdb" #包含数据库的目录名称
batch_size:100# the number of data processed each time
backend:lmdb# choose to use LEVEL1DB or Lmdb, the default is LEVEL1DB
}
}
And then the CNN convolution layer
layer{
Name: "Conv1"
Type: "Convolution"
Bottom: "Data"
Top: "Conv1"
param{
lr_mult:1# Learning rate coefficient, if there are two learning rate coefficients, then the first is the weight of the learning rate, the second is biased learning rate
}
param{
lr_mult:2# The learning rate of general bias is twice times the weight
}
convolution_param{
Number of num_output:20# convolution and
kernel_size:5# convolution kernel size
stride:1# Volume kernel step, defaults to 1
weight_filler{
Type: "Xavier" #权重初始化
}
bias_filler{
Type: "Constant" #偏置初始化
}
}
}
And then the pool layer.
layer{
Name: "Pool1"
Type: "Pooling"
Bottom: "Conv1"
Top: "Pool1"
pooling_param{
Pool:max
Kernel_size:2
Stride:2
}
}
Fully connected Layer
layer{#把输入当做一个向量, the output is also a simple vector, that is, the input data blobs width and height of the total into 1
Name: "Ip1"
Type: "Innerproduct"
Bottom: "Pool2"
param{
lr_mult:1# Learning rate coefficient, if there are two learning rate coefficients, then the first is the weight of the learning rate, the second is biased learning rate
}
param{
lr_mult:2# The learning rate of general bias is twice times the weight
}
inner_product_param{
The number of num_output:500# convolution and the volume kernel size of the whole connecting layer is the same as the original data.
weight_filler{
Type: "Xavier" #权重初始化
}
bias_filler{
Type: "Constant" #偏置初始化
}
}
}
The rest has the accuracy layer and so on, but is similar to the usage which has already introduced, may extrapolate.
Hope to be helpful to you, we will see you next time.