"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)

why the output is random? I mean when i repeat it, it does not end to same bunch of images.

It is just iterating through the input dataset. If you restart the whole notebook, it will restart at the same point. But if you re-execute just that cell, it steps through the dataset.

1 Like

thanks for your immediate answer.

It worth looking at that logic to see how this is working. Notice that train_dataset is a BatchDataset object. It is defined with a batch size of 32. So when you do the take(1) method that you see in the first display loop and in the display loop for the data augmenter section, you are getting 32 images in each case (one minibatch). In the first case, it loops through and shows you 9 of them. In the data augmenter case, you can see that it only uses the first image from the batch of 32.

So you aren’t really seeing all the images, but every 32nd one, when you execute the data augmenter “show images” cell multiple times.

1 Like