vqvae_gen(pretrained: bool = False, overrides: object = {})Construct a VQ-VAE with the full training objective and a sampler.
Same trunk as vqvae, wrapped with the three-term objective of
van den Oord et al., 2017 — reconstruction, codebook, and
-weighted commitment — plus a convenience sampler over
the uniform codebook prior.
Model Size
Parameters
pretrainedbool= FalseNo weights are published for this family; passing
True raises
rather than returning a randomly initialised model.**overridesobject= {}Optional
VQVAEConfig field overrides forwarded into the
underlying config. Pass recon_loss="bce" for Bernoulli
likelihoods on [0, 1] data, or commitment_cost=... to
retune .Returns
VQVAEForImageGenerationVQ-VAE wrapped with the full objective and prior sampler.
Notes
Reference: van den Oord, Vinyals, and Kavukcuoglu, "Neural Discrete Representation Learning", NeurIPS, 2017 (arXiv:1711.00937).
Training objective:
generate samples the uniform prior the model was trained
against, not a learned one — the paper fits a PixelCNN over the latent
grid for its figures. Samples from the uniform prior are expected to
be incoherent; see VQVAEForImageGeneration.
Examples
>>> import lucid
>>> from lucid.models.generative.vqvae import vqvae_gen
>>> model = vqvae_gen().eval()
>>> x = lucid.randn((1, 3, 32, 32))
>>> out = model(x)
>>> out.sample.shape, out.perplexity.shape
((1, 3, 32, 32), ())