Caffe Study Notes (i) Caffe_example training mnist

Source: Internet
Author: User
Tags relative
Caffe Study Notes (i) Caffe_example training mnist 0. Reference Documents

[1]caffe official website "Training LeNet on MNIST with Caffe";
[2] Shikayu "Reading notes 4 learning to build their own network mnist training and learning on the Caffe" ([1] translation version, but also some of the author's comments, great); 1. How to execute the *.sh file.

① method One: Has the SH suffix name is the Linux script file, under Windows in order to execute this file, should download the git. Then for the sh file right-click, open mode, select Git-bash.exe.
② method Two: Directly change the suffix name to "bat" and then double-click. 2, how to load mnist data and start training.

(1) First, it is clear that we need to set two important prototxt files, which are Lenet_train.prototxt and lenet_solver.prototxt under Caffe_root/examples/mnist respectively.
(2) in Lenet_train.prototxt:
① here gives the mnist data mnist-train-leveldb and mnist-test-leveldb path for training;
② here defines which layers of the network are available, and gives a definition of each layer.
(3) in Lenet_solver.prototxt:
① here indicates that we want to train the network is lenet_train.prototxt, give the path of lenet_train.prototxt;
② here Specifies whether to use the CPU or GPU.
(4) Under Caffe_root/examples/mnist find the Sh file train_lenet.sh, in the inside gives:
①caffe the name of the executable EXE generated after compilation (with no ". exe"), followed by "Train" to select "Training";
② just wrote the path of Lenet_solver.prototxt.
Then double-click to execute the script file. 3, about the path

As described in 2, in these two prototxt and an sh file, you have to indicate the path of some files. It is summarized as follows:
(1) Lenet_train.prototxt: The path of training set MNIST-TRAIN-LEVELDB and test set mnist-test-leveldb;
(2) Lenet_solver.prototxt: 3-(1) The path of the Prototxt file lenet_train.prototxt;
(3) train_lenet.sh: Caffe executable exe name, and 3-(2) prototxt file Lenet_solver.prototxt path. 4, can let the program run up the setting method (law one)

(1) In Caffe_root/x64/debug, create a new folder Example2, so that the folder and the executable file Caffe.exe in the same path;

Do not tube examples and myexamples, these two folders is a brother copy to me when there is, one is Caffe, one is a brother to do the experiment. In a word, example2 is independent of the relationship.

(2) The Mnist-test-leveldb, Mnist-train-leveldb, Lenet_train_test.prototxt and lenet_, which were just under the caffe_root/examples/mnist. Solver.prototxt These four files are all copied to example2.

(3) Set the Prototxt file and give the corresponding path.
①lenet_train_test.prototxt
This file is the lenet_train.prototxt of the previous one, in order to facilitate the distinction in the following add a _test. The relative paths are given as follows:

It is also possible to give an absolute path here. Such as:

②lenet_solver.prototxt
To set a relative path:

It is also possible to give an absolute path here. Such as:

(4) Copy the train_lenet.sh file under Caffe_root/examples/mnist to Caffe_root/x64/debug in the same directory as the executable file Caffe.exe and example2.

Open the train_lenet.sh file and modify the following:

Modify the file suffix named bat and double-click Train_lenet.bat to run successfully.
5, can let the program run up the setting method (Law II)

This time we no longer create a new example2, and do not change the sh file suffix named bat, but directly under Caffe_root/examples/mnist modify two prototxt files and an sh file. This method is simpler and more straightforward, but be careful to save the Prototxt file backup to avoid writing bad changes.
How to set the path for these two prototxt files is not mentioned here. I give a screenshot of the settings directly as follows:
Lenet_train_test.prototxt:

Lenet_solver.prototxt:

Next, set the sh file train_lenet.sh:

When you have finished setting up, double-click the sh file, you can see the following result:
6. Summary

(1) When setting the path of some files, the absolute path can be given, or the relative path can be given.
(2) When using train_lenet.sh training, you can run directly with the sh file, or you can modify the suffix named bat and run the program.
(3) This article only needle for how to "training Network" to expand, as to how to open test mode testing on the network has been trained to test, has not carried out the experiment, and so on, and then do a good job will update the article.

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.