1、网络结构可视化
可以使用:https://dgschwend.github.io/netscope/quickstart.html
Netscope是一个功能强大的在线工具,不仅可以将网络结构可视化,还可以对网络进行详尽的分析,计算ops、mem等(不支持一些特殊的层),是一个分析结构的有力帮手。
2、loss分析及可视化
2.1 绘制loss曲线
loss可视化有多种方式,例如使用caffe自带的工具,可以参考 https://blog.csdn.net/auto1993/article/details/71293678
也可以编写脚本来完成,如使用python中的matplotlib。
#!/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
train_iterations = []
train_loss = []
fp = open('logfile', 'r')
for ln in fp:
# get train_iterations and train_loss
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
# set labels
host.set_xlabel("iterations")
host.set_ylabel("loss")
# plot curves
p1, = host.plot(train_iterations, train_loss, label="train loss")
host.legend(loc=1)
# set label color
host.axis["left"].label.set_color(p1.get_color())
host.set_xlim([-1000, 50000])
host.set_ylim([0., 100])
plt.draw()
plt.show()
2.1 计算loss均值
除了绘制总的loss的曲线外,还可以编写脚本文件计算loss均值来进行分析。例如可以用cat和grep指令在log文件中搜索所需的关键字,然后计算均值并输出。如果网络有多个stage,可以编写多个关键字的指令,分别计算分段的loss均值。
3、结果可视化
待补充。