Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does `tf.data.Dataset.take()` return random sample?

Tags:

tensorflow

Different calls of tf.data.Dataset.take() return different batches from the given dataset. Are those samples chosen randomly or is there another mechanism at play?

This is all the more confusing that the documentation makes no reference as to the randomness of the sampling.

like image 767
Tfovid Avatar asked Oct 31 '19 15:10

Tfovid


1 Answers

Most probably, you might be using data.shuffle() before tf.data.Dataset.take().

Commenting that out should make the iterator behave as intended: take the same results over and over for each iterator run.

-- Or if you used an api that automatically shuffles without asking like image_dataset_from_directory

shuffle: Whether to shuffle the data. Default: True. 
If set to False, sorts the data in alphanumeric order.

You would have to explicitly set shuffle=False when creating the dataset

like image 54
Tensorflow Support Avatar answered Sep 23 '22 23:09

Tensorflow Support