-
Notifications
You must be signed in to change notification settings - Fork 19.4k
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
Using tf.data.Dataset API #10110
Comments
This error seems to occur inside your data generator. Are you able to do something like: for x, y in data_gen(...):
continue |
Also, note that with Keras at HEAD and TF 1.8, you can fit from data tensors using: x, y = iterator.get_next()
model.fit(x, y, steps_per_epoch=steps_per_epoch, epochs=epochs) |
Yes I am able to do that. For example, train_gen = data_gen(X=train_images, y=train_labels, nb_epochs=10, sess=sess)
for i,(x,y) in enumerate(train_gen):
print(x.shape, y.shape) The above line outputs:
Also, three more things:
|
@fchollet Maybe you can clarify this for me? Why would I need to use the Dataset API with Keras? Does it provide any functionality that fit_generator on its own does not? Thank you! |
What do you mean?
Please open a new issue.
Use it if your data is already in Dataset format. One reason to use Dataset is that it may offer better performance than multi-process Python generators in some cases. |
@fchollet Is this because Datasets get data into RAM from storage in a more efficient manner or do they load data from RAM into GPU memory in a more efficient manner? |
I was trying to use the Tensorboard callback with hist_freq=1, fitting on tensors from iterator.get_next(), and got the following error:
It's thrown on this line here: https://github.com/keras-team/keras/blob/master/keras/callbacks.py#L867 Would be happy to make another issue, just seemed related to the new tf 1.8 feature |
@fchollet what about model.predict and evaluate, do they support tensor source data? |
@knathanieltucker i noticed from your error message that tensorHandle is allowed, So if we convert the tensors input to tensor handler through tf.get_session_handle(input_tensor), Is the problem solved? |
Yeah I think that would work. A good notebook to test this on would be this one: Because they have the dataset object loaded up. Let me know if y'all don't have time. Otherwise I'll test it in a couple weeks. |
@aakashkumar. Now I have the same issue with you. I solved by putting the worker = 0 in fit_generator. Still don't know why. If worker = 0 , the code will be implemented in main thread. |
Did you find any solution to this issue? I've got the same error while working with Initializable_Iterator in Keras. |
When I try this way, got error as: When feeding symbolic tensors to a model, we expect the tensors to have a static batch size. Got tensor with shape: (None, None) which is caused by |
I was trying to use the
tf Dataset API
with keras but I am getting weird errors. Here is my code:The last line throws this error:
The text was updated successfully, but these errors were encountered: