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 and have its credentials:
project_tokenready. Otherwise, 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.
Import the SDK and define your credentials at the beginning of the file (before any function definition).
import missinglink OWNER_ID = 'Your owner id' PROJECT_TOKEN = 'Your project token'
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( owner_id=OWNER_ID, project_token=PROJECT_TOKEN)
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:
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)
You should have integrated MissingLink's SDK successfully.
- Inspect the resulting integrated script.
- 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: