tensorflow / tensorflow/datasets

`shuffle_files` and `shuffle_reshuffle_each_iteration` is ignored.

Open
#3,034 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
4.6k
Forks
1.6k
Avg merge
3h 54m
Merged PRs (30d)
1

Description

Short description

shuffle_files and shuffle_reshuffle_each_iteration parameter of tfds.load() is ignored. The result dataset never get shuffled.

Environment information
  • Summary: It's Google Colab
  • Operating System: Linux 1803a98d124d 4.19.112+ #1 SMP Thu Jul 23 08:00:38 PDT 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Python version: Python 3.6.9
  • tensorflow-datasets/tfds-nightly version: Reproducible with 4.0.1, 4.2.0, 4.2.0+nightly (2021-02-14)
  • tensorflow/tf-nightly version: 2.4.1
  • Does the issue still exists with the last tfds-nightly package?: Yes
Reproduction instructions
import tensorflow_datasets as tfds

options = tf.data.Options()
options.experimental_deterministic = False

ds = tfds.load(
    'mnist',
    split='test',
    batch_size=32,
    shuffle_files=True,
    read_config=tfds.ReadConfig(
        options=options,
        shuffle_seed=123,
        shuffle_reshuffle_each_iteration=True,
    ),
)

for entry in ds.take(2):
    print(entry['label'])
print()
for entry in ds.take(2):
    print(entry['label'])
print()
for entry in ds.take(2):
    print(entry['label'])
Actual output
tf.Tensor([2 0 4 8 7 6 0 6 3 1 8 0 7 9 8 4 5 3 4 0 6 6 3 0 2 3 6 6 7 4 9 3], shape=(32,), dtype=int64)
tf.Tensor([8 7 5 4 2 5 8 5 5 2 9 2 4 2 7 0 5 1 0 7 9 9 9 6 5 8 8 6 9 9 5 4], shape=(32,), dtype=int64)

tf.Tensor([2 0 4 8 7 6 0 6 3 1 8 0 7 9 8 4 5 3 4 0 6 6 3 0 2 3 6 6 7 4 9 3], shape=(32,), dtype=int64)
tf.Tensor([8 7 5 4 2 5 5 8 5 2 9 2 4 2 7 0 5 1 0 7 9 9 9 6 5 8 8 6 9 9 5 4], shape=(32,), dtype=int64)

tf.Tensor([2 0 4 8 7 6 0 6 3 1 8 0 7 9 8 4 5 3 4 0 6 6 3 0 2 3 6 6 7 4 9 3], shape=(32,), dtype=int64)
tf.Tensor([8 7 5 4 2 5 5 8 5 2 9 2 4 2 7 0 5 1 0 7 9 9 9 6 5 8 8 6 9 9 5 4], shape=(32,), dtype=int64)
Expected behavior

The dataset should be shuffled, and it must be reshuffled on each epoch.

Additional context

This is the 3rd day I started using Tensorflow.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided tfds.load() reproduction with MNIST, focusing on shuffle_files, shuffle_reshuffle_each_iteration, and ReadConfig. Done means the resulting dataset is shuffled and produces a different order on each epoch when reshuffling is enabled.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
data, machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.