Skip to content
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

[AIR] Allow user to pass model to TensorflowCheckpoint.get_model #31203

Merged
merged 6 commits into from
Jan 4, 2023

Conversation

bveeramani
Copy link
Member

@bveeramani bveeramani commented Dec 19, 2022

Signed-off-by: Balaji Veeramani balaji@anyscale.com

Why are these changes needed?

When you resume training a TensorFlow model, you may need to create an unnecessary lambda to load model weights. This is because TensorflowCheckplint.get_model expects a model definition, but you may have already constructed your model. This PR improves the UX by letting users directly pass a model to get_model.

Before

def train_loop_per_worker():
    ...

    model = tf.keras.applications.MobileNetV3Small(input_shape=(3, 260, 260))
    if checkpoint is not None:
        model = checkpoint.get_model(lambda: model)

After

def train_loop_per_worker():
    ...

    model = tf.keras.applications.MobileNetV3Small(input_shape=(3, 260, 260))
    if checkpoint is not None:
        model = checkpoint.get_model(model)

Related issue number

Closes #31290

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
@bveeramani bveeramani requested a review from a team as a code owner December 19, 2022 23:57
doc/source/conf.py Outdated Show resolved Hide resolved
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Copy link
Contributor

@amogkam amogkam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! left some small comments.

python/ray/train/tensorflow/tensorflow_checkpoint.py Outdated Show resolved Hide resolved
python/ray/train/tensorflow/tensorflow_checkpoint.py Outdated Show resolved Hide resolved
python/ray/train/tensorflow/tensorflow_checkpoint.py Outdated Show resolved Hide resolved
python/ray/train/tensorflow/tensorflow_checkpoint.py Outdated Show resolved Hide resolved
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
@amogkam amogkam merged commit c83a8c7 into ray-project:master Jan 4, 2023
@bveeramani bveeramani deleted the get-model branch January 4, 2023 00:23
AmeerHajAli pushed a commit that referenced this pull request Jan 12, 2023
…31203)

When you resume training a TensorFlow model, you may need to create an unnecessary lambda to load model weights. This is because TensorflowCheckplint.get_model expects a model definition, but you may have already constructed your model. This PR improves the UX by letting users directly pass a model to get_model.

Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
tamohannes pushed a commit to ju2ez/ray that referenced this pull request Jan 25, 2023
…ay-project#31203)

When you resume training a TensorFlow model, you may need to create an unnecessary lambda to load model weights. This is because TensorflowCheckplint.get_model expects a model definition, but you may have already constructed your model. This PR improves the UX by letting users directly pass a model to get_model.

Signed-off-by: Balaji Veeramani <balaji@anyscale.com>
Signed-off-by: tmynn <hovhannes.tamoyan@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[AIR] Pass model to TensorflowCheckpoint.get_model
3 participants