sagemaker-python-sdk icon indicating copy to clipboard operation
sagemaker-python-sdk copied to clipboard

How to start training a job from existing model.

Open milodeptrai opened this issue 8 years ago • 5 comments

I am using Tensorflow to train a default MNIST data, the model will be uploaded in S3. After a while, we collect more user's handwritten digits. How can I retrain the existing model that was previously trained using SageMaker Tensorflow(trained with default MNIST data) with the new user's data?

milodeptrai avatar Apr 11 '18 00:04 milodeptrai

I'm not sure if this is what you mean, but if you want to "continue" a training job from checkpoint, set the argument checkpoint_path in your TF Estimator where your last check_point exists. From what I can tell this is what you mean by "retrain" - you are updating the model weights based off new data.

From the Estimator code you can see checkpoint_path is defined as follows:checkpoint_path (str): Identifies S3 location where checkpoint data during model training can be saved (default: None). For distributed model training, this parameter is required.

samuelhkahn avatar Apr 17 '18 17:04 samuelhkahn

Thank Samuel! That's exactly what I need. It works.

However there is an issue with loading the existing checkpoint with training_steps param set at a fix value. For example: First round training, the checkpoint at global_steps=10000 will be stored: mnist_estimator = TensorFlow( entry_point='...', checkpoint_path = checkpoint_path, training_steps=10000, evaluation_steps=10, ...) mnist_estimator.fit(inputs1, wait = True)

Second round of training with different inputs2 mnist_estimator = TensorFlow( entry_point='...', checkpoint_path = checkpoint_path, training_steps=10000, evaluation_steps=10, ...) mnist_estimator.fit(inputs2, wait = True) The training does not seems to run addtional 10000 steps but look like it is compared with global_steps and finish the training.

milodeptrai avatar Apr 20 '18 20:04 milodeptrai

@milodeptrai - I believe that's a TensorFlow issue as global_step is also stored in the checkpoint. I think this is by design.

derekhh avatar Apr 21 '18 00:04 derekhh

Hey @milodeptrai. Is that still an issue for you?

lukmis avatar Apr 27 '18 15:04 lukmis

Closing due to lack of response. Feel free to reopen if necessary!

laurenyu avatar May 02 '18 22:05 laurenyu