Caffe Brief Introduction:
Caffe doesn't have a Windows version yet, so I need to log on to a Linux server
Caffe main processing picture/picture sequence
data format read by Caffe
Read from a dedicated database (Lmdb, LEVELDB) |
Read pictures directly |
Read from memory (takes up a lot of memory) |
Read from the HDF5 file |
Read from the sliding window (slide once as a small picture in a larger image) |
The most common is the first two ways. The default is to read from the Lmdb database format, so you need to first convert the picture file into a lmdb format file. Reading a picture directly can cause the mean value to be reduced. If you do not consider the reduction of the average value, you can read the picture directly.
Caffe Operation 1----Preparing data
STEP1: Get a list of files
The image above originates from the Fer library, in which a single image represents an expression, and the write code automatically generates TXT documents
STEP2: Converting to IMDB format
Command principle:
This includes the above four parameters, the pink parameter can choose not to set, which----means that you can not adjust
Actual operation:
Open the terminal under the/caffe path under the root directory home, enter the sudo command, enter the password, and enter the maximum permissions:
Enter command: (note space when entering)
In Caffe, the author provides us with such a file: convert_imageset.cpp, stored in the Tools folder under the root directory. After compiling, the resulting executable file is placed under buile/tools/, which is used to convert the picture file into a IMDB file that can be used directly in the Caffe frame.
The screen shows:
View results:
A folder I named was added to the target directory
The folder contains two files, Data.mdb store the data; Lock.mdb Store the label
Basic Knowledge Supplement
Folders and directories under Linux
/home |
root directory, maximum partition time |
/bin |
Store system commands |
/user |
Largest directories, storing applications and files |
/etc |
Storing configuration files |
/dev |
Device Special files |
/mnt |
For temporary mounting of hard disks, discs |
/src |
Put source files like CPP |
How to generate train.txt files and how to adjust the format of a picture when you turn IMDB formatting, see: http://www.cnblogs.com/denny402/p/5082341.html
STEP3: Calculating mean value
Minus the mean, you can improve the accuracy. Of course, you can also choose not to reduce the mean value.
Extension must be Binaryproto
Actual code:
This includes two parameters, one is the file address where the IMDB data is placed, and the other is the address and file name of the save mean file
Get Binarypro mean file
Extended reading: http://www.cnblogs.com/denny402/p/5102328.html
Caffe Operation 2----Build network structure
The whole process of running can be divided into three phases: the training phase, the verification phase and the testing phase. The network structure is different at different stages and is stored in the Prototxt file. In order to facilitate, the training phase and the verification phase of the network structure in a file, the test phase of the network structure in a separate file:
A layer represents a layer of
Layer can be copied by nesting
1) Data layer
Name can be arbitrarily taken
Type is brought by the system and cannot be named by itself
Top indicates that the data is sent up, and the bottom indicates that the data is received from below, and that the bottom determines the flow of data and the link between the layers.
Phase:train says this layer is only called during training.
Mirror means flip
Cropsize indicates that a picture becomes 40*40*10, which increases the number of samples.
BatchSize is a multiple of 2, representing batch processing
Http://www.cnblogs.com/denny402/p/5070928.html
2) convolution layer
Decay=0 means no decay
Number of num_output convolution cores/nodes
Kernal_size is usually 3*3 5*5 7*7 not too big
Padding after the volume of the plot smaller, so fixed fill 0, if = 2, indicating the surrounding padding around 2 pixel
Gaussian indicates that W and B are initialized with the Gaussian method
Http://www.cnblogs.com/denny402/p/5071126.html
3) Activation layer
Common Relu,sigmod
Http://www.cnblogs.com/denny402/p/5072507.html
4) Pool Layer
Caffe only supports Max and average,stochastic is random meaning
Stride cannot write 1, otherwise there will be no pooling function
Http://www.cnblogs.com/denny402/p/5071126.html
5) Full Connection layer
Xvaier initialization method is good, the default value is 0
Type types are unchanged
Http://www.cnblogs.com/denny402/p/5072746.html
6) Other layers
The loss layer is added behind the full connecting layer.
If you want to test, add a layer of Softmax layer
The Deploy.prototxt file is used for the test phase, and the test data does not have a tagged value, so the data entry layer differs from the other two stages.
Caffe automatically copies grayscale to 3-channel graphs
Caffe Operation 3----configuration Parameters Solver.prototxt
Set global parameters here
After each training completes one interval, verifies once whether >449
Basic Learning rate determines convergence and does not converge
Step: Change every how many times
Stepshot: Save one parameter per training
Http://www.cnblogs.com/denny402/p/5074049.html
Caffe Operation 4----training Model
This step will generate the Caffe model file, the parameter training completed
Cases:
Build/tools/caffe Train-solver/home/bnu/fer/solver.prototxt
Http://www.cnblogs.com/denny402/p/5076285.html
Caffe Operation 5----test Model
Classification.bin is an executable with its own body
Http://www.cnblogs.com/denny402/p/5111018.html
Original address: Http://www.cnblogs.com/weiqinglan/p/5969016.html?utm_source=itdadao&utm_medium=referral