-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
39 lines (35 loc) · 984 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import visdom
import numpy as np
class DrawLine():
def __init__(self, env, title, xlabel=None, ylabel=None):
self.vis = visdom.Visdom()
self.update_flag = False
self.env = env
self.xlabel = xlabel
self.ylabel = ylabel
self.title = title
def __call__(
self,
xdata,
ydata,
):
if not self.update_flag:
self.win = self.vis.line(
X=np.array([xdata]),
Y=np.array([ydata]),
opts=dict(
xlabel=self.xlabel,
ylabel=self.ylabel,
title=self.title,
),
env=self.env,
)
self.update_flag = True
else:
self.vis.line(
X=np.array([xdata]),
Y=np.array([ydata]),
win=self.win,
env=self.env,
update='append',
)