We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
hard
end_to_end
Simple GAN Generator
Implement the generator part of a simple GAN (Generative Adversarial Network).
The generator maps noise z to a fake sample through two layers:
- Hidden: $h = \text{ReLU}(z \cdot W_1 + b_1)$
- Output: $\text{fake} = \tanh(h \cdot W_2 + b_2)$
The tanh output ensures generated values are in [-1, 1].
Also compute the generator loss. Given a discriminator that outputs a score for the fake sample, the generator loss (non-saturating) is:
$$L_G = -\log(\sigma(D(\text{fake})))$$
where $\sigma$ is sigmoid and $D(\text{fake})$ is given as input.
Input:
-
z: noise vector shape(batch, noise_dim) -
W1: shape(noise_dim, hidden_dim),b1: shape(hidden_dim,) -
W2: shape(hidden_dim, output_dim),b2: shape(output_dim,) -
disc_score: discriminator output for fake, shape(batch, 1)
Output: A dict with “fake” (shape (batch, output_dim)) and “loss” (scalar).
Hints
gan
generator
generative-model
adversarial
Sign in to attempt this problem and view the solution.