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 thefor 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 basictraining 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 thewith the .
Import the SDK and define your credentials at the beginning of the file (before any function definition).
Now you can create a
KerasCallbackinstance with your credentials, which helps to monitor the experiment in real time. Right before the
model.fitfunction, add the following statements:
missinglink_callback = missinglink.KerasCallback()
(Optional) Give the experiment a name and description. Add the following right after creating the callback:
missinglink_callback.set_properties( display_name='Keras neural network', description='Two dimensional convolutional neural network')
Next, pass the callback that you just created to Keras. Modify the
model.fitfunction to the following statement:
model.fit( x_train, y_train, batch_size=BATCH_SIZE, nb_epoch=EPOCHS, validation_split=VALIDATION_SPLIT, callbacks=[missinglink_callback])
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:
(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.OR
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.
You should have integrated MissingLink's SDK successfully.
- Inspect the resulting .
- Run the new script and see how the MissingLink.ai 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.
Learn more about integrating with Keras to enable the following MissingLink features: