TensorFlow MNIST

The tensorflow_mnist.py example demonstrates the integration of Trains into code which uses TensorFlow and Keras to trains a neural network on the Keras built-in MNIST handwritten digits dataset. It builds a TensorFlow Keras model, and trains and tests it with the following:

When the script runs, it creates an experiment named Tensorflow v2 mnist with summaries, which is associated with the examples project.


The loss and accuracy metric scalar plots appear in the RESULTS tab, SCALARS tab, along with the resource utilization plots, which are titled :monitor: machine.


The TensorFlow DEFINES are are automatically logged when tensorflow is used. The appear in the HYPER PARAMETERS tab.


All console output appears in the RESULTS tab, LOG tab.


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

Input model

Since the model is created in the code and running this example script for the first time stores the model information in Trains Server, MODEL NAME and CREATING EXPERIMENT in the Input Model area are blank (expand the image below). There is no model name or creating experiment.

When the first run completes, it store the model, and later runs of this example script will use it. In those later runs, the stored model and this creating experiment will appears in this section. If you run the script, you see it.

Output model

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

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

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

These appear in the model details GENERAL tab.