pytorch visdom可視化工具學習—2—詳細使用-3-Generic Plots和Others


4)Generic Plots

注意,服務器API遵循數據和布局對象的規則,這樣您就可以生成自己的任意Plotly可視化:

# Arbitrary visdom content
trace = dict(x=[1, 2, 3], y=[4, 5, 6], mode="markers+lines", type='custom',
             marker={'color': 'red', 'symbol': 104, 'size': "10"},
             text=["one", "two", "three"], name='1st Trace')
layout = dict(title="First Plot", xaxis={'title': 'x1'},
              yaxis={'title': 'x2'})

viz._send({'data': [trace], 'layout': layout, 'win': 'mywin'})

圖示:

 

 

5)Others

  • vis.close : 通過id關閉窗口
  • vis.delete_env : 通過env_id刪除環境
  • vis.win_exists : 通過id檢查窗口是否已經存在
  • vis.get_env_list : 獲取服務器上所有環境的列表
  • vis.win_hash: 獲取窗口內容的md5散列
  • vis.get_window_data: 獲取窗口的當前數據
  • vis.check_connection: 檢查服務器是否連接
  • vis.replay_log: 重播所提供的日志文件中的操作

1》 vis.replay_log

 

2》vis.delete_env

此函數完全刪除指定的env。它接受env id :eid作為輸入。

注意:delete_env刪除一個環境的所有數據,並且是不可逆的。除非絕對想要刪除環境,否則不要使用。

 

 一開始有三個環境,打算將test環境刪除

調用:

viz.delete_env('test')

返回:

''

然后就可以看見test環境不見了:

 

3》vis.win_exists

此函數返回一個bool,指示服務器上是否已經存在窗口win。如果出現錯誤,則返回None。

可選參數:

  • env:在Environment中搜索窗口。默認是沒有的。
    win = viz.scatter(
        X=np.random.rand(255, 2), opts=dict( markersize=10, markercolor=np.random.randint(0, 255, (255, 3,)), ), ) #斷言該窗口是否存在 assert viz.win_exists(win), 'Created window marked as not existing' # 添加新的追蹤到散點圖中 viz.scatter( X=np.random.rand(255), Y=np.random.rand(255), win=win, name='new_trace', update='new' )

 圖示:

 

4》vis.get_env_list

此函數返回調用時服務器上所有環境的列表。它不需要任何參數。

調用:

viz.get_env_list()

返回:

['main', 'default', '']

 

5》vis.win_hash

如果存在於服務器上,此函數將返回win窗口內容的md5散列。否則返回None。

可選參數:

  • env:在Environment中搜索窗口。默認是沒有的。
viz.win_hash('default')

什么都沒有返回

正確的使用方式是:

win = viz.scatter(
    X=np.random.rand(255, 2),
    opts=dict(
        markersize=10,
        markercolor=np.random.randint(0, 255, (255, 3,)),
    ),
)
viz.win_hash(win)

返回:

'b144c351f2f68f59d8b0dc5f28688b63'

 

6》vis.get_window_data

viz.get_window_data('default')

返回:

''

 

正確的使用方式是:

win = viz.scatter(
    X=np.random.rand(255, 2),
    opts=dict(
        markersize=10,
        markercolor=np.random.randint(0, 255, (255, 3,)),
    ),
)
viz.get_window_data(win)

返回:

'{"command": "window", "id": "window_3739ceea81b772", "title": "", "inflate": true, "width": null, "height": null, "contentID": "3739ceea81b79c", "content": {"data": [{"x": [0.04551835890074274, 0.9772260473924358, 0.9009148817295527, 0.539562493921608, 0.24118526960032582, 0.46977995598941924, 0.060850500332354174, 0.7347072292427027, 0.5412919280211997, 0.09581282770005128, 0.810341818084029, 0.41717700845083594, 0.1368515602012041
...
6], "name": "1", "type": "scatter", "mode": "markers", "textposition": "right", "line": {}, "marker": {"size": 10, "symbol": "dot", "color": ["#ebbb47", "#1818ad", "#7bd242", "#333f7d", "#f2f7c4", "#f7c7c0", "#c2025f", "#ac2ca9", 
...
"#bbc91d", "#156b58", "#315d0d", "#96c8e2", "#1c1291", "#3def07", "#5adcbc", "#f1baec", "#a67050", "#373313", "#025bd9"], "line": {"color": "#000000", "width": 0.5}}}], "layout": {"showlegend": false, "margin": {"l": 60, "r": 60, "t": 60, "b": 60}}}, "type": "plot", "i": 15}'

 

7》vis.check_connection

舉例:

viz = Visdom(port=DEFAULT_PORT, server=DEFAULT_HOSTNAME)

assert viz.check_connection(timeout_seconds=3), \ 'No connection could be formed quickly' textwindow = viz.text('Hello World!') #生成一個窗口,里面帶文本Hello World! #生成另一個窗口,里面帶文本Hello World! More text should be here updatetextwindow = viz.text('Hello World! More text should be here') #斷言查看updatetextwindow窗口對象是否存在 assert updatetextwindow is not None, 'Window was none' #窗口存在的話,就在該窗口中添加下面的文本,win指定添加到的窗口對象,append指定進行的操作是在元原有的基礎上添加 viz.text('And here it is', win=updatetextwindow, append=True)

返回生成的窗口編號:

'window_373974331dca16'

圖示:

 

8》vis.close

這個函數關閉一個特定的窗口。它接受輸入窗口id:win和環境id:eid。使用win=None,即不設置win關閉環境中的所有窗口

關閉上面生成的text窗口

# close text window:
viz.close(win=textwindow)

返回:

''

圖示:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM