caffe学习笔记13-caffe写训练日志

caffe写训练日志(output.m)

  在train的时候最后加 tee $folder_prefix/caffe.log,就可以重定向到文件夹了。

  1. 你可以从系统 /tmp 文件夹获取,名字是什么 caffe.ubuntu.username.log.INFO.....之类。(参考output.m)

  2. 在train的时候最后加 2>&1 | tee $folder_prefix/caffe.log,就可以重定向到文件夹了。

output.m:

% Well, this is a function that write the

% iteration vs accurancy
% iteration vs loss
% To a file
clc;
clear;
% log file of caffe model caffe.nielsen-HP-Z230-SFF-Workstation.nielsen.log.INFO.20160725-115237.8174
logName = '/tmp/caffe.nielsen-HP-Z230-SFF-Workstation.nielsen.log.INFO.20160725-115237.8174';
fid = fopen(logName, 'r');
fid_accuracy = fopen('output_accuracy.txt', 'w');
fid_loss = fopen('output_loss.txt', 'w');
tline = fgetl(fid);
str_accuracy ='';
str_index_accuracy = ''
while ischar(tline)
    % Then find the loss line
    k1 = strfind(tline, 'Iteration');
    if (k1)
       k2 = strfind(tline, 'loss');
       if (k2)
           indexStart = k2 + 7;
           indexEnd = size(tline);
           str1 = tline(indexStart:indexEnd(2));
           indexStart = k1 + 10;
           indexEnd = strfind(tline, ',') - 1;
           str2 = tline(indexStart:indexEnd);
           res_str1 = strcat(str2, '/', str1);
           fprintf(fid_loss, '%s\r\n', res_str1);
       end
    end
    % first get the number of Testing net index
    k = strfind(tline, 'Testing net (#0)');
    if (k)
        k = strfind(tline, 'Iteration');
        if(k)
           indexStart = k + 10;
           indexEnd = strfind(tline, ',');
           str_index_accuracy = tline(indexStart : indexEnd - 1);
           % second If the string contain test and accuracy at the same time
           % The bias from 'accuracy' to the float number
           tline = fgetl(fid);
           l = strfind(tline, 'accuracy');
  indexStart = l + 11; 
           indexEnd = size(tline);
  str_accuracy = tline(indexStart : indexEnd(2));  
        end    
        % third Concatenation of two string
        res_str = strcat(str_index_accuracy, '/', str_accuracy);
        fprintf(fid_accuracy, '%s\r\n', res_str);
    end
    tline = fgetl(fid);
 
end
fclose(fid);

fclose(fid_accuracy);




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值