truncation trick
**Truncation Trick** is a sampling technique for GANs that improves the visual quality and realism of generated samples by constraining the latent vector to lie closer to the center of the latent distribution, trading sample diversity for individual sample quality. When sampling from StyleGAN's W space, truncation reweights the latent code toward the mean: w' = w̄ + ψ·(w - w̄), where ψ ∈ [0,1] is the truncation parameter and w̄ is the mean latent vector.
**Why Truncation Trick Matters in AI/ML:**
The truncation trick provides a **simple, controllable quality-diversity tradeoff** for GAN sampling, enabling practitioners to select the optimal operating point between maximum diversity (full distribution) and maximum quality (near-mean samples) for their specific application.
• **Center of mass bias** — The center of the latent distribution corresponds to the "average" or most typical image; samples near the center tend to be higher quality because the generator has seen more training examples mapping to this region, while peripheral samples are less well-learned
• **Truncation parameter ψ** — ψ = 1.0 samples from the full distribution (maximum diversity, some low-quality samples); ψ = 0.0 produces only the mean image (zero diversity, "average" output); ψ = 0.5-0.8 typically gives the best quality-diversity balance
• **W space vs Z space** — Truncation in StyleGAN's W space (intermediate latent) is more effective than in Z space because W is more disentangled; truncating in W smoothly moves attributes toward their mean rather than creating entangled artifacts
• **Per-layer truncation** — Different truncation values can be applied at different generator layers: stronger truncation on coarse layers (ensuring standard pose/structure) with weaker truncation on fine layers (preserving texture diversity)
• **FID vs. Precision-Recall** — Truncation improves Precision (quality/realism of individual samples) at the cost of Recall (coverage of the real data distribution); the optimal ψ for FID balances these competing objectives
| Truncation ψ | Diversity | Quality | FID | Use Case |
|--------------|-----------|---------|-----|----------|
| 1.0 | Maximum | Variable | Higher | Research, distribution coverage |
| 0.8 | High | Good | Near-optimal | General generation |
| 0.7 | Moderate-High | Very Good | Often optimal | Production, demos |
| 0.5 | Moderate | Excellent | Variable | Curated content |
| 0.3 | Low | Near-perfect | Higher (low diversity) | Hero images |
| 0.0 | None (mean only) | Average face | Worst | N/A |
**The truncation trick is the essential sampling control for GANs that enables practitioners to smoothly trade diversity for quality by constraining latent codes toward the distribution center, providing intuitive, single-parameter control over the quality-diversity spectrum that is universally used in GAN demos, applications, and evaluation to achieve the best possible sample quality.**