Keras with TensorBoard

The example demonstrates the integration of Trains into code which uses Keras and TensorBoard. It trains a simple deep neural network on the Keras built-in MNIST dataset. It builds a sequential model using a categorical crossentropy loss objective function, specifies accuracy as the metric, and uses two callbacks: a TensorBoard callback and a model checkpoint callback. When the script runs, it creates an experiment named Keras with TensorBoard example 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.


Histograms for layer density appear in the RESULTS tab, PLOTS tab.


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


Text printed to the console for training progress, as well as all other console output, appear 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

In the experiment details, ARTIFACTS tab, Input Model area, you can see Trains logging of the configuration we connected in the code.

task.connect_configuration({'test': 1337, 'nested': {'key': 'value', 'number': 1}})

This configuration only demonstrates how to connect a configuration. It is not used.

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), you can see the following:

  • In the model details GENERAL tab you can see:
    • The output model location (URL).
    • Model snapshots / checkpoint model locations (URLs).
    • Experiment creating the model.
    • Other general information about the model.
  • The output model configuration, which appears in the model details NETWORK tab.
  • Class label enumeration - In the example code, we create a class label enumeration dictionary, and connect it to the experiment by calling the Task.set_model_label_enumeration method.
    labels = dict(('digit_%d' % i, i) for i in range(10))
    Class enumeration appears in the model details LABELS tab.