Use MATLAB to draw the loss curve of Caffe training

Source: Internet
Author: User
Tags strfind

1. The first is to extract the training log file;

2. Then the MATLAB code:

clear all; close all; Clc;log_file='/home/wangxiao/downloads/43_attribute_baseline.log'; FID= fopen (Log_file,'R'); Fid_accuracy= fopen ('/home/wangxiao/downloads/output_accuracy.txt','W'); Fid_loss= fopen ('/home/wangxiao/downloads/output_loss.txt','W'); Iteration={};loss={};accuracy={};p ath='/home/wangxiao/downloads/'; Fid_= fopen ([path,'Loss_file_.txt'],'a'); while(~feof (FID)) Tline=Fgetl (FID); %%ifStrfind (Tline,'Sgd_solver.cpp:') Iter_index= Strfind (Tline,'Iteration'); Rest= Tline ((iter_index+9): End); Iter_current= Strtok (Rest,','); %iteration number; Iteration= [Iteration iter_current]; %count the iteration; Lr_index= Strfind (Tline,'lr ='); Lr_current= Tline ((lr_index+4): End); %Learning rate; End%%ifStrfind (Tline,'solver.cpp:228]') Iter_index= Strfind (Tline,'loss ='); Loss_current= Tline ((iter_index+7): End); fprintf (Fid_,'%s \ n', loss_current); Loss= [loss loss_current]; %count the iteration; EndifStrfind (Tline,'aver_accuracy:') Aver_accuracy_index= Strfind (Tline,'aver_accuracy:'); Aver_accuracy_current= Tline ((aver_accuracy_index+ the): End); Accuracy=[accuracy aver_accuracy_current]; EndEnd Loss_file_path= ImportData ('/home/wangxiao/downloads/loss_file_.txt'); Plot (Loss_file_path)

3. Results show:

Use MATLAB to draw the loss curve of Caffe training

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.