-
Notifications
You must be signed in to change notification settings - Fork 19.5k
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
Allow tensors in tf.Dataset
s to have different dimensions.
#19318
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #19318 +/- ##
==========================================
- Coverage 80.14% 75.73% -4.41%
==========================================
Files 341 366 +25
Lines 36163 40193 +4030
Branches 7116 7814 +698
==========================================
+ Hits 28982 30442 +1460
- Misses 5578 8064 +2486
- Partials 1603 1687 +84
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Thanks for the PR!
@@ -4,6 +4,8 @@ | |||
from keras.api_export import keras_export | |||
from keras.utils import tree | |||
|
|||
NUM_SAMPLES_FOR_TENSOR_SPEC = 4 |
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 not just 2?
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.
Also, these are batches, not samples
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 don't know, I just figured the odds of detecting different shapes would be better with more examples (but it will never be 100% correct).
I will rename.
Also, I need to add unit tests.
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.
The 2 main use cases are for images and sequences. In both cases you have a very high likelihood that 2 consecutive batches will have different image sizes or sequence lengths if they are dynamic. So IMO 2 is good enough and minimizes overhead. Of course, it's not 100% accurate, as you say.
The shape for the `tf.TensorSpec` for the `tf.Dataset` is determined by inspecting several batches and keeping dimensions that are common. Fixes keras-team#19124
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.
LGTM, thank you!
The shape for the
tf.TensorSpec
for thetf.Dataset
is determined by inspecting several batches and keeping dimensions that are common.Fixes #19124