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);
caffe学习笔记13-caffe写训练日志
最新推荐文章于 2019-08-10 17:12:19 发布