0
0
Computer Visionml~10 mins

GAN for image generation in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the noise input shape for the GAN generator.

Computer Vision
noise_shape = ([1],)
Drag options to blanks, or click blank then click option'
A100
B28
C256
D64
Attempts:
3 left
💡 Hint
Common Mistakes
Using image dimensions like 28 or 64 instead of noise vector size.
Confusing noise shape with output image shape.
2fill in blank
medium

Complete the code to compile the GAN generator model with the Adam optimizer.

Computer Vision
generator.compile(optimizer=[1], loss='binary_crossentropy')
Drag options to blanks, or click blank then click option'
A'adagrad'
B'adam'
C'rmsprop'
D'sgd'
Attempts:
3 left
💡 Hint
Common Mistakes
Using SGD which may be slower to converge.
Using RMSprop or Adagrad which are less common for GANs.
3fill in blank
hard

Fix the error in the discriminator training step by completing the code to train on real images.

Computer Vision
d_loss_real = discriminator.train_on_batch(real_images, [1])
Drag options to blanks, or click blank then click option'
Anp.full((batch_size, 1), 0.5)
Bnp.random.rand(batch_size, 1)
Cnp.zeros((batch_size, 1))
Dnp.ones((batch_size, 1))
Attempts:
3 left
💡 Hint
Common Mistakes
Using zeros which label fake images.
Using random or 0.5 labels which confuse training.
4fill in blank
hard

Fill both blanks to generate fake images and label them for discriminator training.

Computer Vision
noise = np.random.normal(0, 1, (batch_size, [1]))
fake_labels = np.[2]((batch_size, 1))
Drag options to blanks, or click blank then click option'
A100
Bones
Czeros
Dfull
Attempts:
3 left
💡 Hint
Common Mistakes
Using ones for fake labels instead of zeros.
Using wrong noise vector size.
5fill in blank
hard

Fill all three blanks to create a dictionary of losses for GAN training metrics.

Computer Vision
losses = {'d_loss_real': d_loss_real, 'd_loss_fake': d_loss_fake, '[1]': g_loss}
print(f"Discriminator real loss: {losses['d_loss_real']}")
print(f"Discriminator fake loss: {losses['d_loss_fake']}")
print(f"[2] loss: {losses['[3]']}")
Drag options to blanks, or click blank then click option'
Ag_loss
BGenerator
DDiscriminator
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Discriminator' label for generator loss.
Mismatching dictionary keys and print labels.