Skip to content

How to save model? #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
meownoid opened this issue Dec 25, 2017 · 5 comments
Closed

How to save model? #31

meownoid opened this issue Dec 25, 2017 · 5 comments

Comments

@meownoid
Copy link
Contributor

How can I save model after the model.fit()so next time I could load and deploy it using model.deploy()?

@andremoeller
Copy link
Contributor

andremoeller commented Dec 27, 2017

Hi @meownoid ,

Model artifacts from a training job are uploaded to S3 when training completes, so the model is already saved. You can use attach() with the training job name from fit() to deploy this model:

def attach(cls, training_job_name, sagemaker_session=None, **kwargs):
"""Attach to an existing training job.
Create an Estimator bound to an existing training job. After attaching, if
the training job has a Complete status, it can be ``deploy()`` ed to create
a SageMaker Endpoint and return a ``Predictor``.
If the training job is in progress, attach will block and display log messages
from the training job, until the training job completes.
Args:
training_job_name (str): The name of the training job to attach to.
sagemaker_session (sagemaker.session.Session): Session object which manages interactions with
Amazon SageMaker APIs and any other AWS services needed. If not specified, the estimator creates one
using the default AWS configuration chain.
**kwargs: Additional kwargs passed to the :class:`~sagemaker.estimator.Estimator` constructor.
Returns:
sagemaker.estimator.Framework: ``Estimator`` with the attached training job.
"""

Does this answer your question?

@yangaws
Copy link
Contributor

yangaws commented Jan 16, 2018

@meownoid

I will close the issue now. Feel free to reply if you have any further questions.

@yangaws yangaws closed this as completed Jan 16, 2018
laurenyu pushed a commit to laurenyu/sagemaker-python-sdk that referenced this issue May 31, 2018
@ricoms
Copy link

ricoms commented Aug 2, 2018

@andremoeller, that is true if you did the training on the SageMaker, but in my example, I did not. I train everything in EC2 instances, then saved the architecture file in json format and the weights in h5 format.

Is there any way that I can deploy and estimator to SageMaker from this files?

I'm following this material: https://github.com/samir-souza/ai-workshop/blob/master/lab/03_ImageClassification/ImageClassificationFashionMNIST.ipynb my application is similar.

apacker pushed a commit to apacker/sagemaker-python-sdk that referenced this issue Nov 15, 2018
Added: Introduction to PCA, Linear Learner, and PCA notebooks
@KobaKhit
Copy link

Follow up here. What format does sagemaker save models in? To be more precise, after you unzip the model.tar.gz what is the resulting format of the model file. It does not seem to be mleap. Was wondering if its possible to load the model.tar.gz produced by sagemaker training job using an mleap like library.

@laurenyu
Copy link
Contributor

@KobaKhit the format of the model depends on how you trained the image, e.g. if you use TensorFlow, then the model is saved in the format specified by your training script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants