Caffe Learning and use • One-use Caffe to train your own data

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.