caffe环境下,画faster rcnn的训练loss曲线图

 用faster rcnn对自己的数据集训练,得到训练模型的同时,训练日志也会自动保存在./experiments/logs文件夹下。要想知道整个训练过程中训练损失的变化,可通过画Loss曲线图观察,并以此调整学习率、迭代次数等参数。具体代码如下:

#!/usr/bin/env python

import os

import sys

import numpy as np

import matplotlib.pyplot as plt

import math

import re

import pylab

from pylab import figure, show, legend

from mpl_toolkits.axes_grid1 import host_subplot

fp = open('E:/fastrcnn/py-faster-rcnn/experiments/logs/faster_rcnn_end2end_VGG16_.txt.2019-07-14_11-25-04', 'r')  
# 改成自己的日志文件地址

train_iterations = []

train_loss = []

test_iterations = []

#test_accuracy = []

for ln in fp:

      if '] Iteration ' in ln and 'loss = ' in ln:

        arr = re.findall(r'ion \b\d+\b,',ln)

        train_iterations.append(int(arr[0].strip(',')[4:]))

        train_loss.append(float(ln.strip().split(' = ')[-1]))

fp.close()

host = host_subplot(111)

plt.subplots_adjust(right=0.8) # ajust the right boundary of the plot window

#par1 = host.twinx()

# set labels

host.set_xlabel("iterations")

host.set_ylabel("RPN loss")

#par1.set_ylabel("validation accuracy")

# plot curves

p1, = host.plot(train_iterations, train_loss, label="train RPN loss")

host.legend(loc=1)

# set label color

host.axis["left"].label.set_color(p1.get_color())

host.set_xlim([-1000, 150000])

host.set_ylim([0., 3.5])

plt.draw()

plt.show()

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值