Model Pipeline - GAN concept (generator and discriminator)
A GAN has two parts: a generator that creates fake data, and a discriminator that tries to tell real from fake. They learn together to make the generator better at fooling the discriminator.
A GAN has two parts: a generator that creates fake data, and a discriminator that tries to tell real from fake. They learn together to make the generator better at fooling the discriminator.
Loss
1.2 |*
1.0 | **
0.8 | ***
0.6 | ****
0.4 | ****
0.2 | **
+---------
1 5 10 15 20 Epochs| Epoch | Loss ↓ | Accuracy ↑ | Observation |
|---|---|---|---|
| 1 | 1.20 | 0.50 | Discriminator starts guessing randomly; generator produces poor images |
| 5 | 0.85 | 0.65 | Discriminator improves; generator starts making better images |
| 10 | 0.60 | 0.75 | Generator fools discriminator more often; loss decreases steadily |
| 15 | 0.45 | 0.82 | Training stabilizes; generator creates realistic images |
| 20 | 0.35 | 0.88 | Generator and discriminator reach good balance |
What is the main role of the generator in a GAN?
Which of the following is the correct way to define a simple generator model in TensorFlow Keras?
def make_generator_model():
model = tf.keras.Sequential([
tf.keras.layers.Dense(7*7*256, use_bias=False, input_shape=(100,)),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.LeakyReLU(),
tf.keras.layers.Reshape((7, 7, 256)),
tf.keras.layers.Conv2DTranspose(128, 5, strides=1, padding='same', use_bias=False),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.LeakyReLU(),
tf.keras.layers.Conv2DTranspose(1, 5, strides=2, padding='same', activation='tanh')
])
return model
Given the following code snippet for a discriminator model, what will be the output shape after the last Conv2D layer?
model = tf.keras.Sequential([
tf.keras.layers.Conv2D(64, 5, strides=2, padding='same', input_shape=(28, 28, 1)),
tf.keras.layers.LeakyReLU(),
tf.keras.layers.Dropout(0.3),
tf.keras.layers.Conv2D(128, 5, strides=2, padding='same'),
tf.keras.layers.LeakyReLU(),
tf.keras.layers.Dropout(0.3),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(1)
])
Identify the error in this GAN training step code snippet:
noise = tf.random.normal([batch_size, noise_dim])
generated_images = generator(noise, training=True)
real_output = discriminator(real_images, training=True)
fake_output = discriminator(generated_images, training=False)
loss = generator_loss(fake_output) + discriminator_loss(real_output, fake_output)
You want to improve a GAN to generate clearer images. Which combined approach is best?
Pass the test and this pattern moves unknown