This example illustrates how to use a TensorFlow Python script to train a classification model on the MNIST dataset. You train the model using SageMaker and inference with AWS Lambda.
This project contains source code and supporting files for a serverless application that you can deploy with the notebook. It includes the following files and folders.
- tensorflow_script_mode_training_in_sagemaker_and_serving_with_lambda.ipynb - Notebook to run training with SageMaker, and deploy the Lambda function.
- container - The container directory has all the components you need to package the sample Lambda function.
- events - Invocation events that you can use to invoke the function.
You'll be running the TensorFlow script mode training with SageMaker, and serving with AWS Lambda notebook to train a TensorFlow classification model on the MNIST dataset.
You can run this notebook in SageMaker Notebook instance
This notebooks is identical to the original TensorFlow script mode training and serving notebook, except the fact that you'll deploy the model in Lambda function.
- In the Lambda Console, select Configure test events from the Test events dropdown.
- For Event Name, enter InferenceTestEvent.
- Copy the event JSON from here and paste in the dialog box.
- Choose Create.
After saving, you see InferenceTestEvent in the Test list. Now choose Test.
You see the Lambda function inference result, log output, and duration: