Generative adversarial network (GAN) spec #
This module gives TorchLean a small, total GAN interface:
Generatormaps latent noise to synthetic observations;Discriminatormaps observations to scalar "realness" scores; and- the default objective is least-squares GAN (LSGAN), written with existing MSE specs.
We choose LSGAN as the baseline spec because it is total, compact, and verifier-friendly. Classical
logistic GAN losses can be built on top of the same Generator/Discriminator records, but they
need additional domain discipline around log.
References:
- Goodfellow et al. (2014), "Generative Adversarial Nets".
- Mao et al. (2017), "Least Squares Generative Adversarial Networks".
Implementation status #
nn.models.Generative.generator and nn.models.Generative.discriminator
(NN/API/Models/Generative.lean) are independent executable builders; they are not constructed
from these records and no theorem relates them to this file. The theorems that exist are about
these definitions alone: the loss decompositions and zero-loss characterizations in
NN/MLTheory/Generative/Latent/GAN.lean.
Generator G_θ : z ↦ x_fake.
- forward : TorchLean.Tensor α latent → TorchLean.Tensor α obs
Produce a synthetic observation from latent noise.
Instances For
Discriminator/critic D_φ : x ↦ score, represented as a scalar tensor.
- forward : TorchLean.Tensor α obs → TorchLean.Tensor α Spec.Shape.scalar
Score an observation. For LSGAN, scores are regressed toward
0or1.
Instances For
Pair of generator and discriminator components forming a GAN-style model.
- generator : Generator α latent obs
Latent-to-observation generator.
- discriminator : Discriminator α obs
Observation-to-score discriminator.
Instances For
Run the generator on latent noise to produce a synthesized observation.
Instances For
Discriminator score on a fake sample G(z).
Instances For
Discriminator score on a real sample.
Instances For
Scalar tensor filled with 1, the LSGAN "real" target.
Instances For
Scalar tensor filled with 0, the LSGAN "fake" target.
Instances For
Fake scoring expands to discriminator-after-generator.
Least-squares discriminator loss:
MSE(D(x_real), 1) + MSE(D(G(z)), 0).
Instances For
Least-squares generator loss:
MSE(D(G(z)), 1).
Instances For
The LSGAN discriminator objective is the sum of real and fake score-regression terms.
The first term pushes $D(x_{\mathrm{real}})$ toward $1$, the second pushes $D(G(z))$ toward $0$.
Naming the decomposition here gives examples and proof files one stable reference point for the game
semantics, so nothing downstream has to unfold discriminatorLoss by hand.