RAMS icon indicating copy to clipboard operation
RAMS copied to clipboard

Data augmentation seemingly not doing anything

Open flauted opened this issue 2 years ago • 0 comments

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?

flauted avatar May 06 '23 14:05 flauted