liveBook · Manning

Probability distribution

As explained in Build a Text-to-Image Generator (from Scratch)

A probability distribution describes the possible values of a random variable and the probabilities associated with those values.

A probability distribution describes possible values and the probabilities associated with them. In generative models, it represents uncertainty rather than forcing an input to become one fixed value: a VAE encoder produces a distribution in latent space, while a translator's generator produces probabilities over the target vocabulary. section 9.1.1 section 2.3.3

The distribution plays different practical roles across model architectures:

  • A VAE encoder parameterizes a normal distribution, typically with a mean and variance, instead of producing one deterministic latent vector. section 9.1.1 section 11.2.2
  • Sampling from the latent distribution lets the decoder reconstruct varied outputs and encourages smooth interpolation between data points. section 9.1.1 section 11.2.2
  • A transformer generator outputs a distribution over vocabulary tokens and selects the next token autoregressively from prior tokens and encoder output. section 2.3.3

Image encoding

An image encoder can produce a normal distribution in a compact latent space, such as a mean and variance for each latent position. Sampling from it gives the decoder a latent representation from which it reconstructs the image. section 9.1.1

Figure 9.2 How a VAE compresses images to representations in the lower-dimensional (latent) space and then reconstructs the images. A VAE consists of an encoder and a decoder. The encoder compresses images (e.g., with a size of 3 × 512 × 512) into a lower-dimensional space (i.e., the latent space, where images have a size of, e.g., 4 × 64 × 64). The decoder takes the encoded images in the latent space and reconstructs the images to the original high-resolution space (with a size of 3 × 512 × 512 in this example).

Trace the encoder's compression into a 4 × 64 × 64 latent representation and the decoder's reconstruction into a 3 × 512 × 512 image. section 9.1.1

How Build a Text-to-Image Generator (from Scratch) covers it

How deep it goes
Traces parameterization, sampling, reconstruction, and vocabulary prediction, but defers a formal treatment of VAEs.
Examples
Uses normal latent distributions for images and target-vocabulary distributions for German-to-English token generation.
What you can do after
Evaluate how models encode uncertainty, sample representations, reconstruct images, and select tokens sequentially.
How it connects
Connects probability distributions to VAEs, encoders, decoders, latent spaces, sampling, transformers, and autoregressive generation.

Also explained in

Compare how 27 books explain probability distribution →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Text-to-Image Generator (from Scratch). The section links point to the parts of the book it draws on.