import numpy as np
writer = SummaryWriter()
for n_iter in range(100):
       writer.add_scalar('Loss/train', np.random.random(), n_iter)
       writer.add_scalar('Loss/test', np.random.random(), n_iter)
       writer.add_scalar('Accuracy/train', np.random.random(), n_iter)
       writer.add_scalar('Accuracy/test', np.random.random(), n_iter)
Expected result:
[image]
class torch.utils.tensorboard.writer.SummaryWriter(log_dir=None, comment='', purge_step=None, max_queue=10, flush_secs=120, filename_suffix='')
Writes entries directly to event files in the log_dir to be
   consumed by TensorBoard.
The SummaryWriter class provides a high-level API to create an
   event file in a given directory and add summaries and events to it.
   The class updates the file contents asynchronously. This allows a
   training program to call methods to add data to the file directly
   from the training loop, without slowing down training.