visdom
문서의 이전 판입니다!
Visdom
이미지 축 변환
일반 이미지(height x widht x channel)에서 torch (channel x height x width)로 변환
xs # (64, 64, 3) np.transpose(xs, (2, 0, 1)) # (3, 64, 64)
이미지 보이기
viz.image(o, win='name', opts=dict(width=256, height=256))
viz_line 편의함수
viz = visdom.Visdom() def viz_line_(viz, title, x, y, window_size=25, width=None, height=None, ymin=None, ymax=None): title_ = title.replace(' ', '_') if type(y) == dict: _, update = getattr(viz, '_{}'.format(title_), (None, None)) legend, xs, ys = [], [], [] for k, v in sorted(y.items()): k_ = k.replace(' ', '_') dq, _ = getattr(viz, '_{}'.format(k_), (collections.deque(maxlen=window_size), None)) dq.append(v) legend.append(k) xs.append([x]) ys.append([np.mean(dq)]) viz.line(X=np.column_stack(xs), Y=np.column_stack(ys), win=title, update=update, opts=dict(title=title, width=width, height=height, legend=legend)) setattr(viz, '_{}'.format(title_), (None, 'append')) else: dq, update = getattr(viz, '_{}'.format(title_), (collections.deque(maxlen=window_size), None)) dq.append(y) y_mean = np.mean(dq) viz.line(X=[x], Y=[y_mean], win=title, update=update, opts=dict(title=f'{title}: {y_mean}', width=width, height=height, ytickmin=ymin, ytickmax=ymax)) setattr(viz, '_{}'.format(title_), (dq, 'append')) viz_line = functools.partial(viz_line_, viz)
visdom.1544151604.txt.gz · 마지막으로 수정됨: (바깥 편집)