mnist examples

1, mnist examples

mnist is a handwritten digital library maintained by the DL Daniel Yan LeCun. mnist originally used to identify the handwriting on the check digit, now the DL entry exercise library. Special levy on mnist model is recognized by Lenet, regarded as the first model of the cnn.

mnist training sample data for the 60 000, 10 000 test samples, each sample is in black and white picture of the size of 28 * 28 handwritten numbers 0-9, and therefore divided into 10 categories.

First, download the mnist data, assuming that the current directory is the root directory caffe

# sudo sh data/mnist/get_mnist.sh

After the successful operation, there are four files in the data / mnist / directory:

train-images-idx3-ubyte: training set (9,912,422 bytes)  
Train-Labels-idx1-ubyte: training set the corresponding label (28881 bytes)  
T10K-ImagesRF Royalty Free idx3-ubyte-: test set image (1648877 bytes)  
T10K-labels- idx1-ubyte: test set corresponding label (4542 bytes)

These data can not be used directly caffe, the data must be converted to LMDB

# sudo sh examples/mnist/create_mnist.sh

If you want to run leveldb data, run the examples / siamese / folder below the program. examples / mnist / data folder is running lmdb

After the conversion is successful, in the examples / mnist / directory, create two folders, which are mnist_train_lmdb and mnist_test_lmdb, data.mdb and lock.mdb inside the store, is to run the data we need.

Next is to modify the configuration file, if you have a GPU and has been fully installed, this step can be omitted, if not, you need to modify the configuration file solver.

The required configuration file has two, one is lenet_solver.prototxt, and the other is train_lenet.prototxt.

First, open the lenet_solver_prototxt

# sudo vi examples/mnist/lenet_solver.prototxt

If necessary, set the maximum number of iterations, and decided at the last line solver_mode in max_iter, if you want to change the CPU

Save and exit, you can run this example the

# sudo time sh examples/mnist/train_lenet.sh

CPU running time of about 13 minutes, about 4 minutes running time of the GPU, GPU + cudnn running time about 40 seconds, about 99% accuracy are

Model stored in the example / mnist / lenet_iter_10000.caffemodel

Training state saved in example / mnist / lenet_iter_10000.solverstae

2, the data predicted using the trained model

 

Guess you like

Origin www.cnblogs.com/tuyan/p/10968213.html