사용자 도구

사이트 도구


visdom

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판이전 판
다음 판
이전 판
visdom [2018/10/31 02:38] – [이미지 축 변환] rex8312visdom [2024/03/23 02:38] (현재) – 바깥 편집 127.0.0.1
줄 7: 줄 7:
  
 <code python> <code python>
-xs   # (6464, 3) +def hwc2chw(img): 
-np.transpose(xs, (2, 0, 1))  # (3, 6464)+    assert img.shape == (8484, 3) 
 +    return np.transpose(img, (2, 0, 1))  # (3, 8484)
  
 +
 +def chw2hwc(img):
 +    assert img.shape == (3, 84, 84)
 +    return np.transpose(img, (1, 2, 0))  # (84, 84, 3)
 </code> </code>
  
줄 17: 줄 22:
 viz.image(o, win='name', opts=dict(width=256, height=256)) viz.image(o, win='name', opts=dict(width=256, height=256))
 </code> </code>
 +
 +viz_line 편의함수
 +
 +<code python>
 +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)
 +</code>
 +
visdom.1540953502.txt.gz · 마지막으로 수정됨: 2024/03/23 02:37 (바깥 편집)