Only one image comes out of the 9 x9 plot even though `data_augmenter()` passes the tests

Hi everyone!

In the W2A2 exercise 1 plot, I get my function to pass – no problem – but then this quote comes:

From one cute animal, to 9 variations of that cute animal, in three lines of code. Now your model has a lot more to learn from.

I only see the same image plotted over and over by the code segment –

data_augmentation = data_augmenter()

for image, _ in train_dataset.take(1):
    plt.figure(figsize=(10, 10))
    first_image = image[0]
    for i in range(9):
        ax = plt.subplot(3, 3, i + 1)
        augmented_image = data_augmentation(tf.expand_dims(first_image, 0))
        plt.imshow(augmented_image[0] / 255)

Does anyone else have a similar observation?

As you see, this exercise is to create 9 images from one single image by applying “horizontal flip” and “rotation” randomly. In this sense, all should be similar, but “slightly” different.
If all images are exactly same, then, there is a possibility that the augmenter is not working correctly.
(I’m curious, since the previous exercise already validated layers for this sequential model… )

@anon57530071 Thanks for writing. I think there are two issues happening:

  1. The images appear identical (not even slightly the same) – I also opened up another thread on this here
  2. the for loop in that plot appears to only be plotting the same augmented image 9 times, which was my main question here. I thought maybe I was missing something and wanted to ask.

If your data_augmenter() function works correctly, your nine images should look something like this:

I read your other thread. In that thread, you’ve modified the code that displays the images.

This is the code you should use:

What proof can you offer that your data_augmenter() function works correctly?

@TMosh I also DM’ed you my answer privately.

Nevermind. Restarting my kernel and running my code fixed it. There must have been some kind of a problem with my old kernel.

See my private message about an error in the code you sent me.

Thanks @TMosh . Looks like my code was still working because they’ve “over-loaded” the operator somehow. I agree with you though.