Skip to content

How to save model? #31

Closed
Closed

Description

@meownoid

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

Activity

  1. andremoeller commented on Dec 27, 2017

    @andremoeller
    Contributor

    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?

  2. yangaws commented on Jan 16, 2018

    @yangaws
    Contributor

    @meownoid

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

  3. ricoms commented on Aug 2, 2018

    @ricoms

    @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.

  4. added a commit that references this issue on Nov 15, 2018
  5. KobaKhit commented on Feb 25, 2020

    @KobaKhit

    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.

  6. laurenyu commented on Feb 25, 2020

    @laurenyu
    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions