Visdom visualization loss curve, etc. are applied in the training code
visdom install
pip installl visdom
The following options can be provided to the server:
-port:运行服务器的端口。
-hostname:运行服务器的主机名。
-base_url:基本服务器的URL(默认=/)。
-env_path:要重载的序列化会话的路径。
-logging_level:日志记录级别(默认=INFO)。接受标准文本和数字日志记录值。
-readonly:标记以只读模式启动服务器。
-enable_login:标记以设置服务器的身份验证,需要用户名和密码才能登录。
-force_new_cookie:标记以重置服务器使用的安全cookie,从而使当前的登录cookie无效。需要-enable_login开启。
When the -enable_login flag is supplied, the server requires the user to prompt for credentials using a terminal. Alternatively, you can set the VISDOM_USE_ENV_CREDENTIALSenv variable and then provide your username and password via the VISDOM_USERNAME and VISDOM_PASSWORDenv variables without manually interacting with the terminal.
usage: visdom [-h] [-port port] [--hostname hostname]
[-base_url base_url] [-env_path env_path]
[-logging_level logger_level] [-readonly]
[-enable_login] [-force_new_cookie]
[-use_frontend_client_polling] [-bind_local]
[-eager_data_loading]
Start the visdom server.
optional arguments:
-h, --help show this help message and exit
-port port port to run the server on.
--hostname hostname host to run the server on.
-base_url base_url base url for server (default = /).
-env_path env_path path to serialized session to
reload.
-logging_level logger_level
logging level (default = INFO). Can
take logging level name or int
(example: 20)
-readonly start in readonly mode
-enable_login start the server with authentication
-force_new_cookie start the server with the new
cookie, available when -enable_login
provided
-use_frontend_client_polling
Have the frontend communicate via
polling rather than over websockets.
-bind_local Make server only accessible only
from localhost.
-eager_data_loading Load data from filesystem when
starting server (and not lazily upon
first request).
code used in
-
Start the visdom service first, run it in the terminal
python -m visdom.server
, and open it in the browserhttp://localhost:8097/
-
Add visdom to the training code
from visdom import Visdom
self.viz = Visdom(env="yht_win")
# 初始化
self.viz.line([0.], # y
[0.], # x
win="train_loss",
name='loss',
opts=dict(title="train_loss", xlabel='iters',ylabel='loss', legend=['loss']))
self.viz.line([0.], [0.], win="lr", name='lr',
opts=dict(title="lr", xlabel='iters', ylabel='lr', legend=['lr']))
self.viz.line([[0., 0.]], [0.], win="f1&acc",
opts=dict(title="f1&acc", xlabel='iters', ylabel='f1&acc', legend=['f1', "acc"]))
# 在训练代码中,将每一步更新的loss在窗口显示
self.viz.line([loss.cpu().detach().numpy()], [max_iter*epoch + i],
win="train_loss", update="append", opts=dict(title="train_loss"))
# 一个窗口显示两条
self.viz.line([[mean_f1, mean_acc]], [max_iter*epoch+i], win="f1&acc", update="append", opts=dict(title="f1&acc"))
self.viz.line([lr], [max_iter*epoch+i], win="lr", update="append", opts=dict(title="lr"))