We learn the simple routines provided by Caffe, which are designed to allow beginners to get started easily, taking examples/cifar10/as an example, mainly for the classification of small images.
1 CIFAR10 Data Set
60000 32*32 color pictures, 50000 training, 10000 tests
Download CIFAR10 Data set: http://www.cs.toronto.edu/~kriz/cifar-10-binary.tar.gz
Store the downloaded and decompressed data in the/data/cifar10/path
The downloaded raw data is binary (binary) format and needs to be converted to Lmdb or LEVELDB format to be Caffe recognized (this article takes the LEVELDB format as an example).
2 conversion format
We have compiled good Caffe, can refer to the previous blog Caffe Environment, just need to write a script in the root directory D:\caffe-master, after the completion of the script can be double-click, I will caffe source code extracted in the D-disk.
The script file looks like this:
. \build\x64\release\convert_cifar_data.exe./data/cifar10./examples/cifar10 leveldb
Pause
. \build\x64\release\convert_cifar_data.exe
./data/cifar10 represents the input data file path
./examples/cifar10 represents the output data file path
LEVELDB represents the data format, you can also try to generate the Lmdb format
Tip: How do I write a bat script file?
A: In fact, is to create a new text file, and then rewrite the suffix name to bat.
About the release mode in the script, someone will definitely ask, I use the debug mode can not?
Answer: Yes. However, since there are a number of issues in debug mode, I personally recommend that you generate Caffe in release mode.
3 image data mean value
We have compiled the Caffe, just need to write a script under directory D:\caffe-master, and then double-click the script after completion.
The script looks like this:
. \build\x64\release\compute_image_mean.exe-backend=leveldb./examples/cifar10/cifar10_train_leveldb Mean.binaryproto
Pause
. \build\x64\release\compute_image_mean.exe represents the initialization of image data and requires Compute_image_mean.exe executable file
-BACKEND=LEVELDB represents the data format, and if you do not add the sentence, the default is converted to Lmdb
The./examples/cifar10/cifar10_train_leveldb represents the path of the training dataset that was just generated, not the path of the Val validation data set
The Mean.binaryproto represents the output mean file name, with the suffix named Binaryproto. This is saved by default in the current path, which is the D:\caffe-master.
4 Configuring Network Files
There are a lot of this version of the network configuration file, I use/examples/cifar10/cifar10_quick_train_test.prototxt here. After opening, modify the path of the training data and the validation data and the mean file, as shown in the red part as modified:
Since I am CPU mode, I also need to modify the/examples/cifar10/cifar10_quick_solver.prototx file inside the mode, as shown, the red circle is modified, originally GPU mode.
5 Training Log
Due to the use of cifar10_quick_train_test.prototxt, corresponding to the model training settings file We use Cifar10_quick_solver.prototxt, in fact, do not need to modify the content, of course, you can also specify some parameters.
We have compiled the Caffe, just need to write a script under the root directory D:\caffe-master, and then double-click the script to complete.
. \build\x64\release\caffe.exe Train--solver=examples/cifar10/cifar10_quick_solver.prototxt
Pause
If you want to verify, you can modify the command to:
. \build\x64\release\caffe.exe Test--model=examples/cifar10/cifar10_quick_train_test.prototxt
Pause
The results of the operation, the red in the figure for the accuracy rate, we train the test is mainly to see it:
Caffe for Windows Training Cifar10