PyTorch Author: louwill \

Machine Learning Lab

When conducting deep learning experiments, it is necessary to visually display the training process and results. In addition to the Torch version of TensorBoard, TensorBoardX, There is also a very useful visual artifact called Visdom. Visdom is a flexible tool for creating, organizing, and sharing real-time visualizations of large amounts of training data.

Deep learning model training is usually conducted on remote servers. One of the problems of training on servers is that training cannot be easily visualized. Compared with TensorBoard, visDOM is a visualization tool corresponding to PyTorch.

Installation and Startup

PIP install Visdom can be used to install visdom directly, and then enter the following command in terminal to start visdom service:

python -m visdom.server 
Copy the code

After starting the service, enter the local or remote address, port number 8097, to open the Visdom home page.

The main elements

Visdom interface is simple. Its main elements include Windows, Environments, State, Filter, Views and so on.

Environment: it is used to partition the visualization space. For example, during the visualization of training, we can visualize loss in one environment and the input and output of training in another environment.

Status: VisDOM automatically caches the visual content you create and reloads it when the page is closed.

Filter: Can be used to filter the visual window, fast search.

Views: Visual Windows can be arranged and managed quickly.

The sample application

Visdom places objects that can be visualized in the base module, including single/multiple images, text, speech, video, SVG vector diagrams, attribute grids, Matplotlib drawing objects, serialized state objects, and so on. Basic graphs are provided by Plotly, including scatter diagram, broken line diagram, heat diagram, stem and leaf diagram, bar diagram, boxplot, surface diagram, contour diagram, grid diagram, etc.

Take the Matplotlib drawing object as an example.

import matplotlib.pyplot as plt
from visdom import Visdom
vis = Visdom()
plt.plot(range(100))
vis.matplot(plt)
Copy the code

Visdom displays the following:

For deep learning training, we can insert the visdom visualization module under the Torch training code:

if args.steps_plot > 0 and step % args.steps_plot == 0:
    image = inputs[0].cpu().data
    vis.image(image,f'input (epoch: {epoch}, step: {step}) ')
    vis.image(outputs[0].cpu().max(0) [1].data, f'output (epoch: {epoch}, step: {step}) ')
    vis.image(targets[0].cpu().data, f'target (epoch: {epoch}, step: {step}) ')
    vis.image(loss, f'loss (epoch: {epoch}, step: {step}) ')
Copy the code

The above modules are inserted into VOC 2012 semantic segmentation training, and the results are as follows:

Changes in Loss during training can also be monitored:

Visdom was born for PyTorch and is generally an optimized visualization tool for deep learning training.

References:

Github.com/facebookres… \

Machine learning online manual for Machine learning Deep Learning Notes album for AI Basics download (PDF update25Set) Machine learning basics of Mathematics album get a discount website knowledge planet coupon, copy the link directly open: HTTPS://t.zsxq.com/yFQV7am site QQ group 1003271085, join wechat group please scan code like articles, click a look
Copy the code