Tensorflow Moving From Framework Mode To Script Mode
Migrating scripts from Framework Mode to Script Mode
This notebook's CI test result for us-west-2 is as follows. CI test results in other regions can be found at the end of the notebook.
This notebook focuses on how to migrate scripts using Framework Mode to Script Mode.
Set up the environment
Download the MNIST dataset
Upload the data
We use the sagemaker.Session.upload_data function to upload our datasets to an S3 location. The return value inputs identifies the location -- we will use this later when we start the training job.
Construct an entry point script for training
On this example, we assume that you aready have a Framework Mode training script named mnist.py:
The training script mnist.py include the Framework Mode functions model_fn, train_input_fn, eval_input_fn, and serving_input_fn. We need to create a entrypoint script that uses the functions above to create a tf.estimator:
Changes in the SageMaker TensorFlow estimator
We need to create a TensorFlow estimator pointing to train.py as the entrypoint:
Deploy the trained model to prepare for predictions
The deploy() method creates an endpoint (in this case locally) which serves prediction requests in real-time.
Invoking the endpoint
Clean-up
Deleting the local endpoint when you're finished is important since you can only run one local endpoint at a time.
Notebook CI Test Results
This notebook was tested in multiple regions. The test results are as follows, except for us-west-2 which is shown at the top of the notebook.