画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. Python实现栈、队列

    目录 1. 栈的Python实现 1.1 以列表的形式简单实现栈 1.2 以单链表形式实现栈 2. 队列的Python实现 2.1 以列表实现简单队列 2.2 以单链表形式实现队列   本文将使用py ...

  2. 2017swpu-ctf总结

    2017swpu-ctf总结 今年是我第一次出题感受很多,就分析几道我印象最深刻的题吧 你能进入后台吗? 这道题主要是考察php_screw还有md5加密开启true过后的注入 phpscrew加密在 ...

  3. Codeforces Round #564 (Div. 2) C. Nauuo and Cards

    链接:https://codeforces.com/contest/1173/problem/C 题意: Nauuo is a girl who loves playing cards. One da ...

  4. UVaLive6443(线段树)

    要点 题意--题意往往是个大坎Orz:输入操作 p 则在区间\([x_1,x_2]\)插入一个三次函数, t 则先查询区间\([x_1,x_2]\)的函数值的和,然后按题目要求得到新的\(x_1\). ...

  5. 使用表达式目录树实现SqlDataReader到实体的映射

    SqlDataReader映射实体,是ORM的基础功能,常见的实现方式有反射.表达式目录树和emit,这里要说的就是用表达式目录树生成实体的方法. 先分析下思路: 假设有个数据实体类,Student ...

  6. python 8 函数

    调用函数 Python内置了很多有用的函数,我们可以直接调用. 要调用一个函数,需要知道函数的名称和参数,比如求绝对值的函数abs,只有一个参数.可以直接从Python的官方网站查看文档: 也可以在交 ...

  7. python2 学习 数据类型和变量

    数据类型和变量 数据类型 整数 Python可以处理任意大小的整数,当然包括负整数,在程序中的表示方法和数学上的写法一模一样,例如:1,100,-8080,0,等等. 计算机由于使用二进制,所以,有时 ...

  8. ios 绘制虚线 CGContextSetLineDash的使用

    画虚线需要用到函数: CGContextSetLineDash 此函数需要四个参数: context – 这个不用多说 phase - 稍后再说 lengths – 指明虚线是如何交替绘制,具体看例子 ...

  9. restframework安装及APIView分析

    一.restframework的安装 方式一:pip3 install djangorestframework 方式二:pycharm图形化界面安装 方式三:pycharm命令行下安装(装在当前工程所 ...

  10. Ubuntu 配置IP地址方法

    接到一客户的服务器,开机已启动发现是Ubuntu系统,当时有点郁闷了,心想没有配置过ubuntu系统,这客户还在旁边了,心里有点紧张了,于是开始上网寻找各种方法配置,最终将IP配置好,给客户上架调试通 ...