liveBook · Manning

Encoder

As explained in Math and Architectures of Deep Learning

The neural-network component that maps an input to a latent-space distribution.

An encoder is a neural-network component that maps an input into a smaller latent representation, preserving essential features while discarding variable information. In an autoencoder, it produces a latent vector; in a variational autoencoder, it produces the parameters of a latent-space distribution. section 10.5.1 section 14.7.1

For an image, the encoder commonly chains convolution, ReLU, and max-pooling layers so height and width shrink progressively. A final flattening and linear layer maps the resulting features to the latent dimension. The decoder reconstructs the input, and training minimizes reconstruction error. section 14.5

A VAE encoder does not directly emit one latent point. For a Gaussian family, it emits a mean and covariance or variance, samples a latent vector from that distribution during training, and uses the mean directly during inference. Reconstruction loss preserves input fidelity, while KL-divergence loss encourages a compact latent distribution. section 14.7.1 section 14.7.2

A typical encoder-centered computation proceeds as follows:

  • For a VAE, reparameterize the Gaussian sample as z = μ + εσ so backpropagation can learn the encoder parameters. section 14.7.8

MNIST autoencoder and VAE

With 28×28 MNIST digits and a two-dimensional latent space, an autoencoder can reconstruct images but may learn a sparse, widely spread latent space. A VAE adds KL regularization, producing a more compact latent space while retaining useful reconstructions. section 14.7.8

How Math and Architectures of Deep Learning covers it

How deep it goes
Explains convolutional architecture, latent distributions, reparameterized sampling, and reconstruction and KL-divergence losses.
Examples
Uses convolutional image encoders, PyTorch modules, MNIST digits, Gaussian latent distributions, and two-dimensional latent-space plots.
What you can do after
Build an encoder-based autoencoder or VAE with PyTorch and train it through reconstruction and regularization losses.
How it connects
Connects encoders to latent space, embeddings, decoders, autoencoders, variational autoencoders, reconstruction loss, and KL divergence.

Also explained in

Compare how 21 books explain encoder →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Math and Architectures of Deep Learning. The section links point to the parts of the book it draws on.