• 将caffe训练时loss的变化曲线用matlab绘制出来


    1. 首先是提取 训练日志文件;

    2. 然后是matlab代码:

    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 = {};
    path = '/home/wangxiao/Downloads/';
    fid_ = fopen([path, 'loss_file_.txt'], 'a');
    while(~feof(fid))
        tline = fgetl(fid);
        %%
        if strfind(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
        
        %%
        if strfind(tline, 'solver.cpp:228]')
            iter_index = strfind(tline, 'loss = ');
            loss_current = tline((iter_index+7):end);
            fprintf(fid_, '%s 
    ', loss_current );
            loss = [loss  loss_current] ;       % count the iteration; 
        end
        
        if strfind(tline, 'aver_accuracy: ')
            aver_accuracy_index = strfind(tline, 'aver_accuracy: ');
            aver_accuracy_current = tline((aver_accuracy_index+15):end);
           
            accuracy = [accuracy  aver_accuracy_current];
        end
    end
        
    
    loss_file_Path = importdata('/home/wangxiao/Downloads/loss_file_.txt');
    
    
    
     plot(loss_file_Path)

    3. 结果展示:

  • 相关阅读:
    C++矢量图形库系列(转)
    ArcGIS Server 地图发布请求分析
    Git在提交代码时出现的fatal: Authentication failed的问题
    创建WPF项目
    Linux查看日志常用命令(转载)
    CentOS6 + MapServer7.4编译
    升级GCC
    QT+OpenGL(03)--libpng库的编译
    QT+OpenGL(02)-- zlib库的编译
    QT+OpenGL(01)--实现三角形渲染
  • 原文地址:https://www.cnblogs.com/wangxiaocvpr/p/5425427.html
Copyright © 2020-2023  润新知