画loss曲线需要用到此shell脚本

#!/bin/bash
# Usage parse_log.sh caffe.log
# It creates the following two text files, each containing a table:
# caffe.log.test (columns: '#Iters Seconds TestAccuracy TestLoss')
# caffe.log.train (columns: '#Iters Seconds TrainingLoss LearningRate') # get the dirname of the script
DIR="$( cd "$(dirname "$0")" ; pwd -P )" if [ "$#" -lt ]
then
echo "Usage parse_log.sh /path/to/your.log"
exit
fi
LOG=`basename $`
grep -B 'Test ' $ > aux.txt
grep 'Iteration ' aux.txt | sed 's/.*Iteration \([[:digit:]]*\).*/\1/g' > aux0.txt
grep 'Test net output #0' aux.txt | awk '{print $11}' > aux1.txt
grep 'Test net output #1' aux.txt | awk '{print $11}' > aux2.txt # Extracting elapsed seconds
# For extraction of time since this line contains the start time
grep '] Solving ' $ > aux3.txt
grep 'Testing net' $ >> aux3.txt
$DIR/extract_seconds.py aux3.txt aux4.txt # Generating
echo '#Iters Seconds TestAccuracy TestLoss'> $LOG.test
paste aux0.txt aux4.txt aux1.txt aux2.txt | column -t >> $LOG.test
rm aux.txt aux0.txt aux1.txt aux2.txt aux3.txt aux4.txt # For extraction of time since this line contains the start time
grep '] Solving ' $ > aux.txt
grep ', loss = ' $ >> aux.txt
grep 'Iteration ' aux.txt | sed 's/.*Iteration \([[:digit:]]*\).*/\1/g' > aux0.txt
grep ', loss = ' $ | awk '{print $9}' > aux1.txt
grep ', lr = ' $ | awk '{print $9}' > aux2.txt # Extracting elapsed seconds
$DIR/extract_seconds.py aux.txt aux3.txt # Generating
echo '#Iters Seconds TrainingLoss LearningRate'> $LOG.train
paste aux0.txt aux3.txt aux1.txt aux2.txt | column -t >> $LOG.train
rm aux.txt aux0.txt aux1.txt aux2.txt aux3.txt

$1表示第一个参数,即命令行输入的第一个参数,parse_log.sh caffe.log,caffe.log就是第一个参数。

grep是linux搜索命令,grep '] Solving ' $1 > aux.txt就是在第一参数里找] Solving,然后把这个所在行重定向到aux.txt文件。

bnrc@bnrc:~$ grep '] Solving ' /home/bnrc/fast-rcnn/caffe-fast-rcnn/tools/extra/out.log
I0619 ::38.261850 solver.cpp:] Solving deeplab_largeFOV

这是自己在电脑上直接执行的grep命令,可以看到,在文件中查询,会返回这个字符串所在的整个这一行。

grep -B 1 'Test ' $1 > aux.txt :在第一个参数所在文件中搜索有'Test '的行,显示这些行,并显示第一个有'Test '的行的前1行。如果换成2就是前2行。-A是向后显示。

这个脚本是前面一段是提取.test的日志,后半部分是提取.train的日志,两个都用到了aux.txt这几个临时文件,都把他们生成然后删除了。

-b 在显示符合范本样式的那一行之外,并显示该行之前的内容。

来自: http://man.linuxde.net/grepgrep的-A, -B, -C选项分别可以显示匹配行的后,前,后前多少行内容

-b 在显示符合范本样式的那一行之外,并显示该行之前的内容。

来自: http://man.linuxde.net/grep

caffe parse_log.sh的更多相关文章

  1. 5.caffe:train.sh 和 test.sh (训练与测试 )

    一,train.sh #!/usr/bin/env sh ./build/tools/caffe train --solver=myself/00b/solver.prototxt # cd CAFF ...

  2. 6.caffe:create_txt.sh(数据预处理成txt文本文件)

    #!/usr/bin/env sh DATA=/home/wp/CAFFE/caffe-master/myself/00b MY=/home/wp/CAFFE/caffe-master/myself/ ...

  3. 8.caffe:make_mean.sh( 数据平均化 )

    个人实践代码如下: #!/usr/bin/env sh # Compute the mean image from the imagenet training lmdb # N.B. this is ...

  4. 7.caffe:create_lmdb.sh(数据预处理转换成lmdb格式)

    个人实践代码如下: #!/usr/bin/env sh # Create the imagenet lmdb inputs # N.B. set the path to the imagenet tr ...

  5. caffe绘制训练过程的loss和accuracy曲线

    转自:http://blog.csdn.net/u013078356/article/details/51154847 在caffe的训练过程中,大家难免想图形化自己的训练数据,以便更好的展示结果.如 ...

  6. Caffe和py-faster-rcnn日常使用备忘录

    罗列日常使用中遇到的问题和解决办法.包括: { caffe使用中的疑惑和解释: 无法正常执行 train/inference 的情况: Caffe基础工具的微小调整,比如绘loss曲线图: 调试pyt ...

  7. Caffe 根据log信息画出loss,accuracy曲线

    在执行训练的过程中,若指定了生成log信息,log信息包含初始化,网络结构初始化和训练过程随着迭代数的loss信息. 注意生成的log文件可能没有.log后缀,那么自己加上.log后缀.如我的log信 ...

  8. caffe操作技巧

    查看网络结构: (1)利用caffe自带的Python,可以将*.prototxt保存为一张图片, sudo  python python/draw_net.py  *.prototxt  *.png ...

  9. caffe 中 plot accuracy和loss, 并画出网络结构图

    plot accuracy + loss 详情可见:http://www.2cto.com/kf/201612/575739.html 1. caffe保存训练输出到log 并绘制accuracy l ...

随机推荐

  1. MVC笔记-模板页布局

    MVC分区后  要加上Ares下的主目录   如:@Html.ActionLink("这个帖子真奇葩", "HotIndex", "Prosceniu ...

  2. 从扫码支付想到的超级APP主宰一切,数据!数据!还是数据!

    前言 做室内定位的人其实内心都明白:基于指纹方法的移动端定位,无论paper每年出来多少,距离真正的大规模应用的距离还有多么遥远.指纹采集,指纹更新,似乎在生产实践上就是不可能的难题.所有还在基于人工 ...

  3. PowerDesigner设计表时显示注释列Comment,Columns中没有Comment的解决办法

    我使用的PowerDesigner版本为16.5,如下图: 在所要编辑的表上双击,打开Table Properties窗口,并将上面的选项卡切换到Columns,如下图: 我们点击Customize ...

  4. 51nod1105(二分)

    题目链接:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1105 题意:中文题诶- 思路:直接二分答案,再通过二分找有多少 ...

  5. Openjudge2729 Blah数集(单调队列)

    2729:Blah数集 总时间限制:  3000ms 内存限制:  65536kB 描述 大数学家高斯小时候偶然间发现一种有趣的自然数集合Blah,对于以a为基的集合Ba定义如下:(1) a是集合Ba ...

  6. 微信小程序请求openid错误码40163

    通过wx.login({})方法获取到的code只能使用一次,如果需要在哎服务器端再次请求获取openid来进行校验,需要再次通过wx.login({})方法获取code 否则会报错误代码40163, ...

  7. JavaWeb之用户数据回显

  8. STP-14-MST配置

    在配置MST之前,工程师要进行一定程度的预先规划.首先,必须决定是否应该使用多区域设计,以及如何设置边界.多区域的设计使得每个区域都有独立的MST实例编号.VLAN到实例的映射,以及独立的实例根.整体 ...

  9. Struts2拦截器再认识

    拦截器(Interceptor)是 Struts 2 的核心组成部分. Struts2 很多功能都是构建在拦截器基础之上的,例如文件的上传和下载.国际化.数据类型转换和数据校验等等. Struts2 ...

  10. Ubuntu安装Python2+Python3

    sudo apt-get install python2.7 python2.7-dev sudo apt-get install python3 命令: python 默认执行python2 pyt ...