画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. 一文带你认识Java8中接口的默认方法

    Java8是Oracle于2014年3月发布的一个重要版本,其API在现存的接口上引入了非常多的新方法. 例如,Java8的List接口新增了sort方法.在Java8之前,则每个实现了List接口的 ...

  2. char和nchar,varchar和nvarchar的区别(转载)

    1)       定义: char:    固定长度,存储ANSI字符,不足的补英文半角空格. nchar:   固定长度,存储Unicode字符,不足的补英文半角空格 varchar:  可变长度, ...

  3. linux 删除软链接

    Linux下取消软连接,做个案例来说明: 1.先建立一个软连接 ln -s /soft/hexo/nodejs/bin/node /usr/local/bin/node ln -s /soft/hex ...

  4. hdu1394(枚举/树状数组/线段树单点更新&区间求和)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1394 题意:给出一个循环数组,求其逆序对最少为多少: 思路:对于逆序对: 交换两个相邻数,逆序数 +1 ...

  5. luogu 1169 棋盘制作(单调栈/悬线)

    luogu 1169 棋盘制作(单调栈/悬线) 国际象棋是世界上最古老的博弈游戏之一,和中国的围棋.象棋以及日本的将棋同享盛名.据说国际象棋起源于易经的思想,棋盘是一个8*8大小的黑白相间的方阵,对应 ...

  6. jzoj6009. 【THUWC2019模拟2019.1.18】Counting (dp)

    Description 羽月最近发现,她发动能力的过程是这样的: 构建一个 V 个点的有向图 G,初始为没有任何边,接下来羽月在脑中构建出一个长度为 E 的边的序列,序列中元素两两不同,然后羽月将这些 ...

  7. VBA for AutoCAD

    Download the Microsoft Visual Basic for Applications Module (VBA) 2016 Downloads AutoCAD 2016 VBA mo ...

  8. Postgresql 10 自带扩展模块功能说明

    adminpackadminpack提供了许多支持功能,pgAdmin 和其他管理和管理工具可以使用它们来提供其他功能,例如远程管理服务器日志文件.所有这些功能的使用仅限于超级用户. citext 该 ...

  9. require--按需加载js与模块化

    1.html中:  “<script type="text/javascript" src="js/require.js" data-main=" ...

  10. 【手撸一个ORM】第二步、封装实体描述和实体属性描述

    一.实体属性描述 [MyProperty.cs] Name,属性名称 PropertyInfo,反射获取的属性信息,后面很多地方需要通过该属性获取对应的实体类型,或调用SetValue进行赋值 Fie ...