-
Notifications
You must be signed in to change notification settings - Fork 74k
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
Jpeg decoding (for example when loading TFRecords from files) causes error on TPU when trying to fit a model #41590
Comments
I also tried to change label to |
Was able to reproduce the issue with TF v2.2. Please find the gist of it here. Thanks! |
The error is not reproducible with MirroredStrategy so I think this is TPU specific. Based on the error it looks like you're passing in some dynamic shape. I wonder if the following has something to do with it? But the encoded/decoded dataset has None for the height and width. |
Try explicitly setting the size after you decode, using tf.reshape. I think that should work.
|
@nikitamaia thanks! that helped |
Closing this issue since a solution was found. Explicit size is needed for TPUs. |
System information
I'm not sure that this is a bug, but I've encountered this weird behaviour with my .tfrec dataset and made simple code to reproduce it. This problem only exists at TPU.
Firstly I initialize TPU:
Then I run the following code, which creates tf.data.Dataset of dummy images, encodes it to jpeg and back, then normalizes to float32 and makes batches.
I receive the following output which ends with exception:
When I remove these two lines:
Then it works:
However shapes and types of dataset batches remain the same:
To fix this error I tried to case labels to tf.int64, but error still occurs. I tried to run this code on CPU version of Colab (removing
with strategy.scope():
), and then it works perfectly. So I guess the problem is in TPU and jpeg encoding-decoding.The text was updated successfully, but these errors were encountered: