-
Notifications
You must be signed in to change notification settings - Fork 6k
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] add to_air_checkpoint method for inference only workload. #25444
Merged
Merged
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
882cedd
[air] add to_air_checkpoint method for inference only workload.
xwjiang2010 ffdae88
Merge branch 'master' of https://github.com/ray-project/ray into pred…
xwjiang2010 b53b28f
fix
xwjiang2010 19db155
Add docs.
xwjiang2010 487855e
remove file
xwjiang2010 7b65cfe
fix lint
xwjiang2010 7d153b3
add more
xwjiang2010 38a04fe
Merge branch 'master' of https://github.com/ray-project/ray into pred…
xwjiang2010 57104c9
fix merge.
xwjiang2010 5586ba0
up
xwjiang2010 f1d23fa
fix merge.
xwjiang2010 b4207cf
up
xwjiang2010 2bc24ee
Update use-pretrained-model.rst
xwjiang2010 5bac3f8
Update use_pretrained_model.py
xwjiang2010 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from ray.ml.predictors.integrations.tensorflow.tensorflow_predictor import ( | ||
TensorflowPredictor, | ||
) | ||
from ray.ml.predictors.integrations.tensorflow.utils import to_air_checkpoint | ||
|
||
__all__ = ["TensorflowPredictor"] | ||
__all__ = ["TensorflowPredictor", "to_air_checkpoint"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from typing import Optional | ||
|
||
from tensorflow import keras | ||
|
||
from ray.ml.checkpoint import Checkpoint | ||
from ray.ml.constants import MODEL_KEY, PREPROCESSOR_KEY | ||
from ray.ml.preprocessor import Preprocessor | ||
|
||
|
||
def to_air_checkpoint( | ||
model: keras.Model, preprocessor: Optional[Preprocessor] = None | ||
) -> Checkpoint: | ||
"""Convert a pretrained model to AIR checkpoint for serve or inference. | ||
|
||
Args: | ||
model: A pretrained model. | ||
preprocessor: Stateless preprocessor only. The preprocessing logic will | ||
be applied to serve/inference. | ||
""" | ||
checkpoint = Checkpoint.from_dict( | ||
{PREPROCESSOR_KEY: preprocessor, MODEL_KEY: model.get_weights()} | ||
) | ||
return checkpoint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this have to be a stateless preprocessor only? This can be a stateful preprocessor that's already been fit right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rephrased..