Ubuntu+caffe plotting Cifar10 datasets loss and accuracy curves

Source: Internet
Author: User
Tags system log

In the process of training and testing data sets using open-source deep learning Framework (Caffe), we will inevitably want to visualize some training data in our training process, this article mainly introduces how to use the tools of Caffe to visualize the error curve and the precision curve in the course of CIFAR10 training and testing.

0. Preparation, the CIFAR data set has been downloaded, and the format has been converted well. The specific code is:

CD $CAFFE _root #cd到caffe的根目录
./data/cifar10/get_cifar10.sh  #该脚本会下载二进制的cifar并解压
./examples/cifar10/ create_cifar10.sh  #运行后将会在examples中出现数据集.
If you do not understand it, see blog http://blog.csdn.net/liumaolincycle/article/details/47258937 written in detail. But here, just run the top 3 lines I wrote on it.
1. Create a new log folder

First of all, in Ubuntu configuration under the Caffe framework, I downloaded the Caffe under the home, that is, the default way to set.

The address of the specific log folder is as follows: caffe/examples/cifar10/

2. Move three files to the log folder

Copy the three files under Caffe/tools/extra: parse_log.sh extract_seconds.py and Plot_training_log.py.example to the new log folder in 1.

3. Modify the Cifar10 training file

Under Address: Caffe/examples/cifar10 Find the train_quick.sh file open, the modified code is as follows:

Set-e

tools=./build/tools
glog_logtostderr=0 glog_log_dir=examples/cifar10/log/\
$TOOLS/caffe train \
  --solver=examples/cifar10/cifar10_quick_solver.prototxt $@

# Reduce learning rate by factor of ten after 8 epochs
$TOOLS/caffe train \
  --solver=examples/cifar10/cifar10_quick_solver_lr1.prototxt \
  --snapshot= Examples/cifar10/cifar10_quick_iter_4000.solverstate $@
That is, the first line with the # number is removed, and a new line is added to the original folder:

Glog_logtostderr=0 glog_log_dir=examples/cifar10/log/\
If you create the same log address as mine, directly with the above code on the line, if different according to their own needs to modify the address behind dir=. The function of the above sentence is to save the training log during the build process.

4. Make log generation

CD to the Caffe root directory, and then enter the following statement:

./examples/cifar10/train_quick.sh
After that, the CIFAR10 dataset will begin training, after the training is complete, look under the Caffe/examples/cifar10/log folder, Will find that there is more than one caffe.cat.dog.log.info.20170508-141812.7610 file, where cat and dog are training system name and user name, of course, the time is dynamically generated. This is our training system log, in order for it to generate the error curve we need, we need to make some changes to change the name of a long string above to Cifar.log of course cifar can be random, but the extension is. log this is required.

5. Generate training loss and accuracy curves

The terminal is currently under the Caffe root directory and requires CD to log, i.e.:

CD Examples/cifar10/log
Then enter the following statement:
./plot_training_log.py.example 0  save.png Cifar.log
Generates a graph, of course, only one of the 8 curve types, the number 0 after example can be changed to any one of 0-7, the meaning is:

Notes:  
    1. Supporting multiple logs.  
    2. log file name must end with the lower-cased ". Log".  
Supported chart types:  
    0:test accuracy  vs. Iters  
    1:test accuracy  vs. Seconds  
    2:test loss  vs. I ters  
    3:test loss  vs. Seconds  
    4:train Learning rate  vs. Iters 5:train  
    Learning rate  vs. Se Conds  
    6:train loss  vs. Iters  
    7:train loss  vs. Seconds
It is worth noting that, in this process, I input in addition to 4 5 of all can generate curves, this specific reason I would like to delve into. Share a few of my generated images:




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.