Skip to content

Data augmentation seemingly not doing anything #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
flauted opened this issue May 6, 2023 · 0 comments
Open

Data augmentation seemingly not doing anything #15

flauted opened this issue May 6, 2023 · 0 comments

Comments

@flauted
Copy link

flauted commented May 6, 2023

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant