6.6.1 Generative Models Roadmap: Sample, Decode, Review
Generative models create new samples instead of only predicting labels. The practical loop is: sample a latent code, decode it, review the output, and compare versions.
Look at the Generation Flow First
Section titled “Look at the Generation Flow First”

| Concept | First meaning |
|---|---|
| latent vector | compact hidden input used for generation |
| decoder / generator | turns latent code into an output |
| discriminator | judges real vs generated in GANs |
| VAE | learns a smoother latent space |
| review | generated output still needs human and metric checks |
Run One Tiny Decoder
Section titled “Run One Tiny Decoder”Create generative_first_loop.py and run it after installing torch.
import torch
torch.manual_seed(0)latent = torch.randn(2, 4)decoder = torch.nn.Sequential(torch.nn.Linear(4, 6), torch.nn.Tanh())generated = decoder(latent)
print("latent_shape:", tuple(latent.shape))print("generated_shape:", tuple(generated.shape))print("value_range:", round(generated.min().item(), 3), round(generated.max().item(), 3))Expected output:
latent_shape: (2, 4)generated_shape: (2, 6)value_range: -0.863 0.695This is not a real generator yet. It shows the core shape idea: small latent vectors can be decoded into larger outputs.

Learn in This Order
Section titled “Learn in This Order”| Order | Read | What to focus on |
|---|---|---|
| 1 | 6.6.2 GAN | generator, discriminator, adversarial balance |
| 2 | 6.6.3 VAE | encoder, decoder, latent space |
Evidence to Keep
Section titled “Evidence to Keep”Keep one generation review note:
- Latent Shape
- what compact code enters the generator/decoder
- Output Shape
- what sample-like object comes out
- Quality Check
- does it look plausible or reconstruct well?
- Diversity Check
- are outputs varied, or collapsing?
- Trust Rule
- generated output always needs review
Pass Check
Section titled “Pass Check”You pass this roadmap when you can explain the difference between predicting a label and generating a sample, and describe why generated outputs need review rather than blind trust.
Check reasoning and explanation
- A passing answer connects tensors, model layers, loss,
backward(), and optimizer updates into one training loop. - The evidence should include a runnable mini experiment, tensor-shape checks, and a loss or validation curve you can explain.
- A good self-check names one failure mode such as shape mismatch, no loss decrease, overfitting, data leakage, or using Attention/Transformer words without explaining the data flow.