画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. LeetCode: 598 Range Addition II(easy)

    题目: Given an m * n matrix M initialized with all 0's and several update operations. Operations are r ...

  2. 修改mac host文件绑定域名

    打开终端在终端terminal中输入 sudo vi /etc/hosts 上一步输入完成之后按enter回车键,如果当前用户账号有密码,则在按完之后会提示输入密码,此时输入当前账户密码后继续按ert ...

  3. 虚拟机vmware11装Mac ox 10.8 解决windows8.1下unlocker202 vmxsmc.exe已停止工作的问题

    转载:http://tieba.baidu.com/p/3485956366 先说说故事吧,相信很多图钉都用过VMware Workstation这个软件.我系统是win8.1up1,之前用VMwar ...

  4. Spring Boot Dubbo 构建分布式服务

    概述: 节点角色说明 节点 角色说明 Provider 暴露服务的服务提供方 Consumer 调用远程服务的服务消费方 Registry 服务注册与发现的注册中心 Monitor 统计服务的调用次数 ...

  5. css正方形盒子 自适应

      <!DOCTYPE html>   <html lang="en">   <head>   <meta charset="U ...

  6. Ubuntu设置打不开排错

    记录一次系统设置打不开排错过程 系统信息: ××××××:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu ...

  7. Jar命令用法

    JAR文件 JAR文件 全称:Java Archive File , 意思是Java档案文件.通常JAR文件是一种压缩文件,与常见的ZIP压缩文件兼容,通常被称为JAR包. JAR文件和ZIP文件的区 ...

  8. IP服务-8-WCCP

    WCCP(网页缓存通信协议) 内容引擎负责将频繁访问的数据收集到本地,通常是HTTP流量,当主机访问相同页面时,可以直接通过内容引擎为主机提供相应内容,而无需通过WAN进行访问.WCCP与网页代理并不 ...

  9. 一份比较完整的gulpfile.js

    var gulp = require('gulp'); //工具 var autoprefixer = require('gulp-autoprefixer'); var include = requ ...

  10. PHP EXCEL相关

    这次的需求是在二次扫描的EXCEL报表中加入一列扫描时间. 扫描的时间之前已经写进日志里了,这次要做的就是把时间读取出来然后作为一列插入报表.其实日志也已经读出来了,要做的就是插入.但插入还是碰到不少 ...