Skip to content

Integration with a TensorFlow Neural Network (With Estimators)

This topic shows you how to integrate the MissingLink SDK with a multilayer perception TensorFlow neural network that is trained on the MNIST dataset.


  • You must have TensorFlow installed in the same working environment that MissingLink SDK is installed. The SDK doesn't enforce TensorFlow as one of its dependencies.

  • You must have created a new project. Follow the instructions in Creating a project.


Ensure that you can successfully run the basic basic script training script. In the steps that follow below, the basic script is integrated with the MissingLink SDK to enable remote monitoring of the training, validation, and testing process.

Compare the basic script with the integrated script.

Write code

  1. Import the SDK and define your credentials at the beginning of the file (before any function definition).

    import missinglink
  2. Now create a TensorFlowProject instance with your credentials, which helps to monitor the experiment in real time. In the run_training function and before the training loop, add the following statement:

    missinglink_project = TensorFlowProject()
  3. First, create a hook factory from within the model_fn:

    hooks = missinglink_project.estimator_hooks(
        display_name='MNIST multilayer perception',
        description='Two fully connected hidden layers',

    Parameter descriptions

    • display_name (optional): Name to be dislayed on the experiment
    • description (optional): Experiment description
    • hyperparams (optional): Hyperparams for the experiment will be logged when the experiment starts
  4. Still inside the model_fn function, create a hook for training and a hook for testing:

    training_hooks = None
    if mode == tf.estimator.ModeKeys.TRAIN:
        train_hook = hooks.create_train_hook(
            monitored_metrics={'loss': loss}
        training_hooks = [train_hook]
    evaluation_hooks = None
    if mode == tf.estimator.ModeKeys.EVAL:
        test_hook = hooks.create_test_hook(expected=labels, predicted=predictions)
        evaluation_hooks = [test_hook]
  5. Pass the hooks to the creation of EstimatorSpec:

    return tf.estimator.EstimatorSpec(

You should have integrated MissingLink's SDK successfully.

  • Inspect the resulting integrated script.
  • Run the new script and see how the dashboard helps with monitoring the experiment. A description follows.

Web dashboard monitoring

You can monitor your experiment on your MissingLink dashboard.

Click on the experiment to view your metric graphs.

Next steps

Learn more about integrating with TensorFlow to enable the following MissingLink features: