PyTorch with TensorBoard

The pytorch_tensorboard.py example demonstrates the integration of Trains into code which uses PyTorch and TensorBoard. It trains a simple deep neural network on the PyTorch built-in MNIST dataset. It creates a TensorBoard SummaryWriter object to log scalars during training, scalars and debug samples during testing, and a test text message to the console (a test message to demonstrate Trains). When the script runs, it creates an experiment named pytorch with tensorboard which is associated with the examples project.

Scalars

In the example script, the train and test functions call the TensorBoard SummaryWriter.add_scalar method to log loss. These scalars appear in the RESULTS tab, SCALARS tab, along with the resource utilization plots, which are titled :monitor: machine.

Debug samples

The test function calls the TensorBoard SummaryWriter.add_image method to log debug image samples. These images appear in the RESULTS tab, DEBUG SAMPLES tab.

Hyperparameters

Command line arguments, which are automatically logged when argparse is used, appear in the HYPER PARAMETERS tab.

Log

Text printed to the console for training progress, as well as all other console output, appear in the RESULTS tab, LOG tab.

Artifacts

Trains tracks the input and output model with the experiment, but the Trains Web (UI) shows the model details separately.

Input model

In the experiment details, ARTIFACTS tab, Input Model area, you can see Trains logging of the input model. Since the example script imports the input model, Trains stores input model data in Trains Server.

In the model details (which appear when you click the model name, expand image above), GENERAL tab, you can see the following:

  • The input model location (URL).
  • Model snapshots / checkpoint model locations (URLs).
  • Experiment creating the model.
  • Other general information about the model.

Output model

Trains logs the output model, providing the model name and output model configuration in ARTIFACTS tab, Output Model area.

In the model details (which appear when you click the model name, expand image above), GENERAL tab you can see the following:

  • The output model location (URL).
  • Model snapshots / checkpoint model locations (URLs).
  • Experiment creating the model.
  • Other general information about the model.