visdom使用指南

安装visdom

pip install visdom

打开visom

python -m visdom.server
# 然后打开浏览器 http://localhost:8097/

指定端口

vis = visdom.Visdom(env='名称', port=上面开启visdom服务的指定接口)

# eg:
vis = visdom.Visdom(env='faster rcnn', port=15024)

打印loss

def plot(self, name, y):
"""
self.plot('loss',1.00)
"""
x = self.index.get(name, 0)
self.vis.line(Y=np.array([y]), X=np.array([x]),
win=(name),
opts=dict(title=name),
update=None if x == 0 else 'append'
)
self.index[name] = x + 1

vis.plot('errord', error_d)
vis.plot('errorg', error_g)

打印图片

# (n, c, h, w)带batch,打印出一个batch里所有图片
vis.images(fix_fake_imgs.detach().cpu().numpy()[:64] * 0.5 + 0.5, win='fixfake')
vis.images(real_img.data.cpu().numpy()[:64] * 0.5 + 0.5, win='real')
Author: pangzibo243
Link: https://litianbo243.github.io/2019/08/05/visdom使用指南/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
支付宝打赏
微信打赏