-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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] Build model in TensorflowPredictor.predict
#25136
Merged
amogkam
merged 7 commits into
ray-project:master
from
bveeramani:tensorflow-predictor-model-build
May 26, 2022
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5406363
Update tensorflow_predictor.py
bveeramani ba33a74
Fix error
bveeramani ed95fc6
Add test
bveeramani 8aa4a3d
Initial commit
bveeramani ad9863c
Update test_tensorflow_predictor.py
bveeramani 861415d
update
amogkam 5543e95
Merge branch 'test-tensorflow-predictor' into tensorflow-predictor-mo…
bveeramani 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
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.
Just for my understanding.. Is it needed for all kinds of models or just Sequential model?
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.
My understanding is that it's for all kinds of models, although I'm not super familiar with TensorFlow so I'm not certain.
The
build
method is bound to theModel
class: https://github.com/keras-team/keras/blob/v2.9.0/keras/engine/training.py#L354There 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.
Hmm in that case our current
test_tensorflow_predictor
test should not be passing 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.
this is what the model definition is for the test
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.
Ah I see it's only needed if we pass in
model_weights
is that 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.
Got it thanks @bveeramani.
Can we add a test for this before merging this in?
Also, just a note, it seems like this is not necessary for if the keras model has an input layer already defined or if the first layer in the model already accepts an input shape. Do you know if there's any side effects to calling build if it's not needed?
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.
You're right. The error doesn't occur if the input layer is defined.
I don't think there are any side effects from calling
build
twice.The reason why the error was occurring for me is because I introduced a
Lambda
layer to handle the extra axis created byto_tf
. However, once we merge #25133, I'll be able to remove theLambda
layer.Given that this PR is no longer necessary for the image examples, do you think we should still add this? I don't think it'll cause any problems, but I'm okay closing this PR to avoid adding complexity to
TensorflowPredictor.predict
.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.
Naive question, are we expecting a user to do the following?
If the above is legit, then we should keep this change?
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.
I'm not entirely sure, but it seems like the input shape isn't specified in at least one TensorFlow example. This PR shouldn't directly hurt us, so maybe we should keep the change.
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.
@amogkam fixed