Visualization of training process based on tensorboard on Python

we know that pytorch itself comes with a data visualization tool, but when I used the visualization tool, I found that when I trained to use it, it would suddenly get stuck. It turned out that Pytorch incorporated the Tensorboard feature, and I read some blogs that said it was very easy to implement, so It took me some time to research and implement the change, so I Shared it again.

1. Configure the environment:

since we used pytorch to train the model before, tensorflow has never been installed, but if we use tensorboard, it will report an error if only tensorboard is installed. Also, note that the version to be installed should be at least version 1.14.
conda install tensorflow==1.14 will install the tensorboard

2. Tensorboard programming

from torch.utils.tensorboard import SummaryWriter
writer = SummaryWriter()
writer add_scalar(‘ Loss/train ‘, train_loss.avg, epoch)
writer.add_scalar(‘ lr ‘, lr, (‘ images’, grid, epoch)
grid = vutils.make_grid(image)
self.write.add_image (‘ images’, grid, epoch)

3. Visualize

, if done correctly, will generate a run folder under the current folder, which contains a file with many English letters.
at this point you in the terminal input tensorboard – logdir = runs will be
at this point, you can click on the url into the HTTP. But when I used it, I found that it didn’t work.
tensorboard –logdir=run absolute path, this is ok, you can try both!

Read More: