One way to learn knowledge is to use it first and then ask why.
After the installation is complete Caffe, according to Caffe tips download mnist training test data, and run Lenet training model, the question is how I use Caffe training their data ah, mnist data through the script can download the creation of Lmdb, What do I do to train my own data set?
To train your own data with Caffe, there are two problems that must be solved: 1. How to enter data, 2. How to define the output
First we solve the first problem: the input of the training data, here we introduce the way of using Lmdb
Looking at the train_val.prototxt of Lenet, the input of the data is specified by the source parameter in the database layer, and the input data is formatted as LMDB, and if we can convert our data to Lmdb, it can be used as input data. Train by modifying the path of the source input to the network. The create_imagenet.sh script in the Caffe directory provides a template that transforms our own data into a lmdb format that we can modify Create_ imagenet.sh script to generate its own data, need to modify the place includes: Output file path example, our own data store path data, the path of our training data train_data_root and the path of the test data test_ Data_root, the full name of the output Lmdb data, if you need to resize the picture, you need to set the resize to True, and then set the resize height and width. Doing this is a step further from generating your own lmdb data, and in the script there are train.txt and val.txt, what do these two texts do? Train.txt and Val.txt are a description of the data, given the category of each data, and the category of the data is best starting from 0, we need to generate the lmdb before we generate these two files for our own data, and our training data placed in the same directory, and then we can run the script to generate our own training data.
After generating your own lmdb data, you can modify the Train_val.prototxt to enter your own data into the network.
After entering our own data, there is another problem, is the output of our data what to do, if we have 10 categories of data, where I input into the model? The definition of the output view the loss layer or the upper layer of the accuracy layer, modify the cover layer of the num_output can be
Then you can start training, you need to know that training parameters are defined in both Solver.prototxt and Train_val.prototxt, and Batch_size defines how many data to train or test each time, Max_ ITER defines the maximum number of iterations, Test_iter defines the number of tests, in order to ensure that all data is tested Test_iter and the product of the test batch_size needs to be greater than or equal to the total number of test data.
Caffe Learning and use • One-use Caffe to train your own data