所采用的网络是GoogleNet,故训练日志也是GoogleNet的日志。
其他网络稍微修改即可

import matplotlib.pyplot as plt
import numpy as np
import re

loss = [] 
iteration = 0 #存放迭代次数

with open("log.txt", 'r') as f:
	for line in f:
		if "Test net output #6" in line:  #loss3
			loss.append(re.findall(r"= (\d+\.\d+) \(", line)) #\d+,任意多数字。\.就是. 。 
		#if "Test net output #7" in line:  #loss3_top-1
		#	loss.append(re.findall(r"= (\d+\.\d+)", line))
		if "] Iteration" in line: #获取最大迭代次数
			if(re.findall(r"Iteration (.\d+),",line)):
				iteration=int(re.findall(r"Iteration (.\d+),",line)[0])#re.findall返回的是一个列表,需要[0]提取元素
			
print(iteration)
y = np.array(loss, dtype=np.float64)  #list转array
x = np.arange(0, iteration, iteration/y.size) 

plt.figure()
plt.plot(x, y)
plt.xlabel('#iters')
plt.ylabel('loss3_top-1')
# plt.ylim(0.84, 0.4)  # top-1 or 5
plt.show()

caffe从log里画loss3或者loss3_top-1的图

相关文章:

  • 2021-09-26
  • 2022-12-23
  • 2021-12-12
  • 2021-10-27
  • 2022-12-23
  • 2021-11-03
  • 2021-10-25
  • 2022-03-02
猜你喜欢
  • 2022-12-23
  • 2021-07-20
  • 2022-12-23
  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案