A GAN that draws digits
Why it matters On pictures, the generator needs to build an image up from a few numbers, the opposite of what a CNN does. The same pieces you know from Module 10 (convolution and 2x upsampling) do it, in reverse order.
The course's digit GAN, DCGAN style. Its generator:
- 16 noise numbers, a dense layer to 2 x 2 x 32 numbers, ReLU: a tiny 2 x 2 picture with 32 channels.
- Upsample 2x (each pixel becomes a 2 x 2 block) to 4 x 4, a 3 x 3 convolution to 32 channels, ReLU.
- Upsample to 8 x 8, a 3 x 3 convolution to 16 channels, ReLU.
- A 3 x 3 convolution to 1 channel, then sigmoid: 8 x 8 pixels in 0..1.
Upsampling followed by a convolution does the job of a transposed convolution, the layer most papers name, and avoids its checkerboard artefacts.
Training it took the course minutes on a laptop, far too long for a lesson, so you load the recorded weights. info['along'] shows how its samples improved during training. Your job: write the generator's forward pass, then judge what it draws with the Module 15 judge.
Words and symbols in this lesson
- GAN
- generative adversarial network: a generator and a discriminator trained against each other
- generator (G)
- the network that turns noise into a sample
Write generate(z, P): z is an E.T of shape (n, 16); return an E.T of shape (n, 8, 8, 1). Use E.matmul, E.add, E.reshape, E.relu, E.upsample2, E.conv and E.sigmoid. Then fill scores with the closeness and variety of 500 samples, and share with the share of samples read as each digit. Each layer in P is a pair (weights, biases): P['g1'] = (W, b), and a conv layer adds its bias after E.conv.
Spotted a problem in this lesson? Report it · Ask about this lesson
This exercise opens soon
Finish the lesson before it and this one unlocks. The whole course is free, no account needed, and you can read this lesson right now.
This browser is blocking cookies for learn.floati.life, so lessons you finished here cannot open in order. Allow cookies for this site and reload.