caffe 日志保存以及matlab绘制方法(windows以及ubuntu下)
caffe 用matlab解析日志画loss和accuracy
- clc;
- clear;
- % load the log file of caffe model
- fid = fopen('log-previous-insulator.txt', 'r');
- tline = fgetl(fid);
- accuracyIter =[];
- accuracyArray =[];
- lossIter = [];
- lossArray = [];
- %record the last line
- lastLine = '';
- %read line
- while ischar(tline)
- %%%%%%%%%%%%%% the accuracy line %%%%%%%%%%%%%%
- k = strfind(tline, 'Test net output');
- if (k)
- k = strfind(tline, 'accuracy');
- if (k)
- % If the string contain test and accuracy at the same time
- % The bias from 'accuracy' to the float number
- indexStart = k + 11;
- indexEnd = size(tline);
- str = tline(indexStart : indexEnd(2));
- accuracyArray = [accuracyArray, str2num(str)];
- end
- % Get the number of index
- k = strfind(lastLine, 'Iteration');
- if (k)
- indexStart = k + 10;
- indexEnd = strfind(lastLine, '(');
- str2 = lastLine(indexStart : indexEnd - 1);
- accuracyIter = [accuracyIter, str2num(str2)];
- end
- % Concatenation of two string
- res_str = strcat(str2, '/', str);
- end
- %%%%%%%%%%%%%% the loss line %%%%%%%%%%%%%%
- k1 = strfind(tline, 'Iteration');
- if (k1)
- k2 = strfind(tline, 'loss');
- if (k2)
- indexStart = k2 + 7; %loss位置到数据位置起始位置相差7位
- indexEnd = size(tline);
- str1 = tline(indexStart:indexEnd(2)); %数据开始位置到结束位置,就是loss,也就是纵坐标
- indexStart = k1 + 10; %从iteration到迭代次数数据起始位相差10位
- indexEnd = strfind(tline, '(') - 1; %找到左括号位置-1:根据你的txt来看是括号还是逗号
- str2 = tline(indexStart:indexEnd); %从起始位置到结束位置为迭代次数,也就是横坐标
- res_str1 = strcat(str2, '/', str1); %把横纵坐标连接起来
- lossIter = [lossIter, str2num(str2)]; %把迭代次数转化为数据赋值给lossiter
- lossArray = [lossArray, str2num(str1)]; %把loss转化为数据复给lossArray
- end
- end
- lastLine = tline;
- tline = fgetl(fid);
- end
- %draw figure
- figure;h1 = plot(accuracyIter, accuracyArray);title('iteration vs accurancy'); %绘制accuracy曲线
- figure;h2 = plot(lossIter, lossArray);title('iteration vs loss'); %绘制loss曲线
- print(2,'-dpng','iteration vs loss')%保存
caffe保存训练log日志文件并利用保存的log文件绘制accuary loss曲线图
- 1、训练模型时保存log日志文件
- 方法1 一般情况下我们的训练模型标准语句是:$ sudo ./build/tools/caffe train -solver=xxx/xxx/solver.prototxt xxx/xxx/表示你的solver.prototxt文件所在位置
- 需要保存log文件时的命令是:$ sudo GLOG_logtostderr=0 GLOG_log_dir='xxx/xxx/xxx/' build/tools/caffe train -solver=xxx/xxx/solver.prototxt ’xxx/xxx/xxx/‘表示你所保存的log文件所在位置。
- 训练完成后发现在我们保存的目录xxx/xxx/xxx/下生成了两个上锁log文件caffe.INFO和caffe.ubuntu.root.log.INFO.20170611-103712.5383。点击打开后我们可以看到我们所训练的日志文件。
- 方法2 ./build/tools/caffe train -solver=xn/PENLU/neural/nin/nin_solver.prototxt 2>&1 | tee xn/PENLU/snapshot/nin/nin_relu.log
- 2、利用生成的log文件绘制accuary loss曲线图
- 首先绘制图,caffe中其实已经自带了这样的小工具 caffe-master/tools/extra/parse_log.sh 和caffe-master/tools/extra/extract_seconds.py还有 caffe-master/tools/extra/plot_training_log.py.example;拷贝以上文件到当前训练模型的目录下。
- 然后我们到你保存的log文件目录下将1中保存的log文件解锁,解锁命令:sudo chmod -R 777 ./caffe.ubuntu.root.log.INFO.20170611-103712.5383
- 解锁后我们就可以更改该log文件名为xxx.log(注意:要画图一定是.log文件,所以不改名不可以画)。
- 然后复制该xxx.log文件到你训练模型所在目录下。
- 然后就可以利用命令画图了:在模型所在目录下命令: ./plot_training_log.py.example y xxx.png xxx.log xxx.png是你保存的绘制出的图片名称,xxx.log是你保存的log文件名称。y表示的是你的所绘制的图片到底是什么图片,具体解释如下:
- y的数字代表意义(0~7):
- Supported chart types: 0: Test accuracy vs. Iters (准确率与迭代次数图)
- 1: Test accuracy vs. Seconds (准确率与时间图)
- 2: Test loss vs. Iters (测试损失与迭代次数图)
- 3: Test loss vs. Seconds (测试损失与时间图)
- 4: Train learning rate vs. Iters (学习率与迭代次数图)
- 5: Train learning rate vs. Seconds (学习率与时间图)
- 6: Train loss vs. Iters (训练损失与迭代次数图)
- 7: Train loss vs. Seconds (训练损失与时间图)
- 运行后生成的文件有:log-data.log.test和log-data.log.test和xxx.png
- 3、test测试log日志文件保存与绘图类似过程
Ps: windows记录训练日志
- caffe中其实已经自带了这样的小工具 caffe-master/tools/extra/parse_log.sh caffe-master/tools/extra/extract_seconds.py和 caffe-master/tools/extra/plot_training_log.py.example ,使用方法如下:1.windows记录训练日志:在训练过程中的命令中加入一行参数 ,实现Log日志的记录,这里我使用的.bat。其实一可以像前面某位大哥一样,直接copy输出的类容。
- caffe train --solver=deepid/deepid2/deepid_solver.prototxt >log/XXXXX.log 2>&1
- pause
caffe 日志保存以及matlab绘制方法(windows以及ubuntu下)的更多相关文章
- windows、ubuntu下eclipse搭建java、Python环境问题总结
前两篇博文分别讲述了如何在windows.ubuntu下用eclipse搭建java.python环境,下面就针对本人遇到的问题做一个总结. 一.windows下关于java环境变量JAVA_HOME ...
- windows和ubuntu下git commit提交后如何保存和退出,回到命令行
问题一: windows下git commit后会进入vim界面,不知道怎么操作 解决办法: 1.输入小写字母i,此时进入编辑模式,可以输入你想输入的内容 2.按下esc键,此时退出编辑模式,输入英文 ...
- Windows和ubuntu下更改pip国内镜像
windows下更改pip国内镜像 # 在C:\Users\admin路径下创建pip文件夹,然后创建pip.ini文件, 并在文件下写入 [global] index-url = http://py ...
- [转]windows下和Ubuntu下adb找不到设备的解决方法
最近在做flash手机项目,用fb选择android设备调试,总会出现找不到设备的情况.看了很多帖子都解决不了问题,后来终于研究出来是adb无法找到设备的问题.最后通知这篇帖子终于解决了问题. 使用电 ...
- windows和ubuntu下gif动态图片的制作
现在社交软件中, 各种各样的动图为大家交流很大的乐趣. Gif图片比视频小, 比静态JPG图片形象生动, 更适用于产品展示和步骤演示等. 这里简单介绍一下在window系统和ubuntu系统下gif ...
- Elasticsearch 在 windows 和 ubuntu 下详细安装过程
1. 前言 作为一名 .NET 平台开发者,选择开发框架时总会面临更多的局限性,不过对于搜索这种刚需服务来说,开源框架可供选择的余地还是比较大的.笔者之前用的是 Lucene.net ,现在深感其使用 ...
- windows和Ubuntu下安装mongodb
windows 下载 mongodb官网下载压缩版安装包:下载地址:https://www.mongodb.com/download-center/community 注意选择版本(目前windows ...
- windows调用ubuntu下的sublimeText2环境搭建
部署需求: windows: windows 7 32 sp1 32位: linux :ubuntu 12.04 LTS 64位: 环境: windows安装:xmanager 4 linux安装:g ...
- windows远程访问ubuntu下的jupyter notebook必要配置
0.生成配置文件(一般采用默认) jupyter notebook --generate-config 1.打开ipython, 创建一个密文密码 In [1]: from notebook.auth ...
随机推荐
- 面试题:Concurrenthashmap原理分析 有用
一.背景: 线程不安全的HashMap 因为多线程环境下,使用Hashmap进行put操作会引起死循环,导致CPU利用率接近100%,所以在并发情况下不能使用HashMap. 效率低下的H ...
- noi.ac day1t3 Sort
传送门 分析 快排的原理是以任意一个数为标准,然后把所有小于它的数换到它的左边,所有大于它的数换到它的右边.我们就使用快排的思路,分治整个区间.对于每个区间以排好序的这个数列的中间位置的值为标准,然后 ...
- ElementUI的表单和vee-validate结合使用时发生冲突的解决
在Vue项目中使用ElementUI表单时,同时又引入了vee-validate进行使用的时候,在浏览器上会出现这样的报错: [Vue warn]: The computed property &qu ...
- SQL Server 2014 清理日志
USE [master] GO ALTER DATABASE [TempTestDb02] SET RECOVERY SIMPLE WITH NO_WAIT GO ALTER DATABASE [Te ...
- wpf跳转网页
如果是本地磁盘上的网页,可以考虑利用操作系统的文件关联自动调用操作系统默认浏览器: System.Diagnostics.Process.Start("explorer.exe", ...
- Linux文件锁flock ,检测进程是否已经存在
在多个进程同时操作同一份文件的过程中,很容易导致文件中的数据混乱,需要锁操作来保证数据的完整性,这里介绍的针对文件的锁,称之为“文件锁”-flock. 头文件:#include<sys/fil ...
- c#操作word类,进行html和word文档的互相转换
实例引用:http://www.7es.cn/Software_development/171.shtml using Microsoft.Office.Core;using Word = Micro ...
- Hexo下Next主题配置与优化
使用Next主题 在这里Downloads Next主题代码 将下载的代码放在myBlog/theme/next目录下 设置站点myBlog/_config.yml的theme字段值为next 生成新 ...
- JetBrains WebStorm 如何从GitHub上克隆的代码
工作中经常会遇到要从GitHub上拉代码,详细操作记录如下: 绑定账号 1.File->Settings->Version Control->Github 成功后会出现下面的这个账户 ...
- IOS中录音后再播放声音太小问题解决
1.AVAudioSessionCategory说明 1.1 AVAudioSessionCategoryAmbient 或 kAudioSessionCategory_AmbientSound 用于 ...