How to load trained model in amazon sagemaker?

Question:

I am following this example on how to train a machine learning model in Amazon-sagemaker.

So after calling the fit function the model should be saved in the S3 bucket?? How can you load this model next time?

Answer:

This can be done by using the sagemaker library combined with the Inference Model.

The options you’re passing in are:

  • image – This is the ECR image you’re using for inference (which should be for the algorithm you’re trying to use). Paths are available here.
  • model_data – This is the path of where your model is stored (in a tar.gz compressed archive).
  • role – This is the arn of a role that is capable of both pulling the image from ECR and getting the s3 archive.

Once you’ve successfully done this you will need to setup an endpoint, this can be done by performing the following in your notebook through the deploy function.

Leave a Reply