-
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
Dataset with Keras Functional Model: tuple index out of range uin steps_per_epoch #35925
Comments
Was able to reproduce the issue. Please find the Gist here. Thanks! |
I don't think this feature is supposed to work in 2.0 but can't confirm. But here is the error from there:
|
I tried changing my model to Sequential to circumvent this error, and the error still occurs. Has anyone found a way around this? |
@dendrondal The only way I've found around it is not using tf.data at all and using a plain Python generator. @amahendrakar Should I submit a PR for the tf.keras.model doc's since they say they support tf.data datasets but that is incorrect? |
Hi. I faced the same problem. Is there any solution or workaround? |
Perhaps this thread can help. |
I experienced the same problem when trying to train an autoencoder with only a single input. In my case the problem was solved my mapping the function def autoencoder_sample(x):
return x, x in a final step, even though the second example is basically ignored, keras In the OP's example the issue might be solved with by using However, it is clear that the current error message is cryptic and does not help the user to find a solution. |
I faced the same problem. Is there any solution or workaround update ? |
Also struggling with this! Any workarounds? |
No solution, I've fallen back to using python generators instead of trying to use the tf.dataset. In reference to an earlier comment (thanks for the advice though!) I was using this with custom code, following the tensorflow guide to creating datasets, but used the tfds lib here to make a really small working example so no need for extensive custom code in the issue. |
@jguhlin Hi, i faced the same issue a few days ago, could you please provide some info on how did you manage to use plain python generator function? Did you need to create your own batching mechanism and yield batches from the generator? thx. |
@FabHub Yes, I'm just using a generator and skipping the tf datasets integration. In the generator, I'm creating the batches and yielding those. Have to handle shuffling and the like manually. |
Ok, just wanted to make sure, whether there is not some more advanced solution :) , thanks a lot for quick reply. |
@FabHub Check the keras docs, it will tell you what to provide from the generator. |
any progress? |
I also have the same issue. |
@F-29 @MihailMihaylov97, I only used @jguhlins solution. I created simple data generator function that iterates over dataset, yields tuple (x, y) and created dataset like this: tf.data.Dataset.from_generator(generator_function ...). Unfortunately in my case, I had to create data that are in uniform shape and store them on a disk prior to train process, couldn't cut the samples in my case on-the-fly. I needed to do this in order to perform shuffling properly and also use full potential of dataset. Hope it helps. |
@FabHub thank you for the reply. I switched to tensorflow estimators, and it works just fine. |
Encountered the same issue with another tfds dataset. Adding |
While trying to reproduce your issue in Tf Nightly, encountered different error, please find the gist here.Thanks! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you. |
Closing as stale. Please reopen if you'd like to work on this further. |
System information
Yes
Describe the current behavior
Passing in a dataset to model.fit from a model generated with tf.Keras layers results in IndexError: tuple index out of range. Error both with custom TFRecord dataset and datasets derived from tensorflow-datasets installed via pip. Looks like it is in the standardize_input_data function but since it is an instance of DatasetV2 it should not be hitting that if statement...
Describe the expected behavior
Keras models should accept tf DataSets.
Code to reproduce the issue
Other info / logs
The text was updated successfully, but these errors were encountered: