Hello community.
I have a question about the first ungraded lab: C4_W4_Lab_1_First_GAN
My question is about the discriminator training data:
# ... training loop declaration
# infer batch size from the training batch
batch_size = real_images.shape[0]
# Train the discriminator - PHASE 1# Create the noise
noise = tf.random.normal(shape=[batch_size, random_normal_dimensions])
# Use the noise to generate fake images
fake_images = generator(noise)
# Create a list by concatenating the fake images with the real ones
mixed_images = tf.concat([fake_images, real_images], axis=0) # <---------- HERE
# Create the labels for the discriminator# 0 for the fake images# 1 for the real images
discriminator_labels = tf.constant([[0.]] * batch_size + [[1.]] * batch_size)
# Ensure that the discriminator is trainable
discriminator.trainable = True
# Use train_on_batch to train the discriminator with the mixed images and the discriminator labels
discriminator.train_on_batch(mixed_images, discriminator_labels)
It bothers me that the training batch will have all the fake images together and then all the real images. Won’t that produce overfitting?
Or is it the case that when train_on_batch is called on the discriminator there is a bundled-in shuffling mechanism?
If the discriminator consistently receives batches where the first half contains only fake images and the second half only real images, it might learn to distinguish based on the position in the batch rather than learning the actual features that distinguish real from fake images. This could lead to poor generalization.
Am I overthinking this?