craft
craft

Reputation: 555

RandomShuffleQueue functionality with tf.data.Dataset

I want to replace my old RandomShuffleQueue approach with the tf.data.Dataset. For some background: I am generating data on runtime, putting it in the queue and then taking it out randomly.

I don't see a way to do that with the tf.data.Dataset, because I would always need to generate data while I don't have a way to put the new data into the Dataset. Something like repeat won't help me because that just always work on the Dataset with the same elements that I put beforehand.

Any ideas how I get the Queue functionality into the tf.data.Dataset? Basically if I have a queue/buffer in tf.data.DataSet, how do I refill it with the new data?

Upvotes: 0

Views: 70

Answers (1)

Vlad-HC
Vlad-HC

Reputation: 4757

If I understood you correctly, it sounds like a perfect match for Dataset.from_generator(). You can add Dataset.shuffle() afterwards, if you would like to make a buffer and take randomly elements out of it.

Upvotes: 1

Related Questions