Skip to content

Integration with a Keras Neural Network

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

The following steps are covered:

  • Define a project callback with your credentials.
  • Create a new experiment.
  • Give the experiment a name and description.
  • Pass the callback to Keras.
  • Add a test scope.


You can also consider trying the step-by-step tutorial for integrating the MissingLink SDK with an existing Keras example.


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

  • You must have created a new project. If not, follow the instructions in Creating a project.


Ensure that you can successfully run the basic 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 you can create a KerasCallback instance with your credentials, which helps to monitor the experiment in real time. Right before the function, add the following statements:

    missinglink_callback = missinglink.KerasCallback()
  3. (Optional) Give the experiment a name and description. Add the following right after creating the callback:

      display_name='Keras neural network',
      description='Two dimensional convolutional neural network')
  4. Next, pass the callback that you just created to Keras. Modify the function to the following statement:
      x_train, y_train, batch_size=BATCH_SIZE,
      nb_epoch=EPOCHS, validation_split=VALIDATION_SPLIT,


    At this point, you have performed the train and validation stages of running the experiment. Running the test stage is optional and can be done in the next step:

  5. (Optional) To add a test scope, replace the evaluation with MissingLink's test scope and evaluate the model as usual within the test scope as detailed below.

    with missinglink_callback.test(model):
      score = model.evaluate(x_test, y_test)

    with missinglink_callback.test(model):
      score = model.evaluate_generator(test_generator)

    If you do implement a testing context, MissingLink automatically adds a confusion matrix and a table of standard test metrics, all viewable under the Test tab for the experiment.


    If you are using custom metrics, there are additional steps that you need to perform to see them in the dashboard. For more information, see Visualization of Keras Custom Metrics.

    If there's a testing context, MissingLink automatically adds a confusion matrix and a table of standard test metrics under the Test tab

You should have integrated MissingLink's SDK successfully.

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

Web dashboard monitoring

You can monitor your experiment on your MissingLink dashboard.

monitor your Keras experiment on your MissingLink dashboard

Click on the experiment to view your metric graphs.

Click on the Keras experiment to view your metric graphs

Next steps

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