caffe中accuracy和loss用python从log日志里面获取
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了caffe中accuracy和loss用python从log日志里面获取相关的知识,希望对你有一定的参考价值。
import re import pylab as pl import numpy as np if __name__=="__main__": accuracys=[] losses=[] with open(r‘/home/wxl/bnscallog.txt‘,‘r‘) as f: lines=f.readlines(); print len(lines) str="".join(lines) str=str.replace(‘\\n‘,‘‘) print len(str) pattern1=r‘Iteration \\d{4,5}, Testing net \\(#0\\)\\w\\d{1,6} \\d{2}:\\d{2}:\\d{2}\\.\\d{1,6} \\d{1,6} solver\\.cpp:\\d{2,5}] Test net output #0: accuracy = 0\\.\\d{6}‘; pattern2=r‘Iteration \\d+, loss = 0\\.\\d{6}‘; accuracys=re.findall(pattern1,str); losses=re.findall(pattern2,str); print len(accuracys),‘aaaa‘; print len(losses),‘===‘ print accuracys with open(r‘/home/wxl/project/code/loss‘,‘w+‘) as f1: for ac in losses: f1.write(ac[10:15]) f1.write(‘ ‘) f1.write(ac[23:]); f1.write(‘\\n‘); ‘‘‘ with open(r‘/home/wxl/project/code/loss‘,‘r‘) as f2: lines=f2.readlines(); x=[]; y=[] for line in lines: if "," in line: line=line.replace(‘,‘,‘‘); tmp=line.strip(‘\\n‘).split(‘ ‘) x.append(int(tmp[0])) y.append(float(tmp[-1])) pl.plot(x,y) pl.show() ‘‘‘
注意:python对圆括号()前面要加上转移字符\\,还有点号也要加上转意字符\\
以上是关于caffe中accuracy和loss用python从log日志里面获取的主要内容,如果未能解决你的问题,请参考以下文章
如何利用caffe自带的工具包绘制accuracy/loss曲线
解决caffe绘制训练过程的loss和accuracy曲线时候报错:paste: aux4.txt: 没有那个文件或目录 rm: 无法删除"aux4.txt": 没有那个文件或目录