C4 W2 A2: Image augmentation not working

def data_augmenter():

data_augmentation = tf.keras.Sequential([RandomFlip("horizontal"),RandomRotation(0.2)])

return data_augmentation

I used the above code for the augmentation but it worked just once on the image. When I tried for the second and third times it wasn’t applying any augmentation on the image. Whats the reason behind it???

All you have done there is define a separate Keras sequential model.
Models are used for training - they aren’t stand-alone functions.

When I used the code data_augmentator()(train_x[i], training =true) the code works fine and It applies the augmentation. But when the code has data_augmentator()(train_x[i]) it doesn’t work.

Which week number and assignment are you working on? You didn’t include that info in your post.

Course 4 week 2 assignment of Mobile net V2.

Thanks, I’ve updated the thread title. I’ll check into your issue shortly.

You do not need to add any code that uses data_augmenter() directly.

Its use is limited to this shortcut in the function definition:

You should not modify that line of code.

Within the alpaca_model() function, you only use data_augmentation() on the “inputs” variable, like it says here in the code comments:

# apply data augmentation to the inputs

That’s not the correct usage. And, “data_augmentator()” does not exist. The function is “data_augmentation()”.

And it doesn’t need the “training” parameter.