Skip to content

Data augmentation seemingly not doing anything #15

Description

@flauted

Hello @fsalv ,

I'm curious about the random flips and rotations.

In training.py, LL119-121:

        if data_aug:
            train_ds.map(random_rotate, num_parallel_calls=tf.data.experimental.AUTOTUNE)
            train_ds.map(random_flip, num_parallel_calls=tf.data.experimental.AUTOTUNE)

I believe .map is NOT an in-place operator so I don't think this is doing anything. To check this, we can adapt the example from the Tensorflow documentation here: https://www.tensorflow.org/api_docs/python/tf/data/Dataset#map

from tensorflow.data import Dataset
dataset = Dataset.range(1, 6)  # ==> [ 1, 2, 3, 4, 5 ]
dataset.map(lambda x: x + 1)
list(dataset.as_numpy_iterator())  # [1, 2, 3, 4, 5]   map had no effect

dataset = Dataset.range(1, 6)  # ==> [ 1, 2, 3, 4, 5 ]
dataset = dataset.map(lambda x: x + 1)
list(dataset.as_numpy_iterator())  # [2, 3, 4, 5, 6]  expected output

Does this seem like a bug to you? If so, could you please advise if you think your pretrained models were affected?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions