ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing
ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing

All Courses

Autoencoders and Representation Learning
Chapter 1: Foundations of Representation Learning
Review of Unsupervised Learning Principles
Limitations of Linear Dimensionality Reduction
Introduction to Manifold Learning Techniques
The Need for Non-linear Feature Extraction
Information Bottleneck Theory Primer
Mathematical Preliminaries Refresher
Chapter 2: The Classic Autoencoder Architecture
Encoder Network Design
The Bottleneck Layer
Decoder Network Design
Reconstruction Loss Functions
Mathematical Formulation of Basic Autoencoders
Implementation Considerations and Frameworks
Building a Simple Autoencoder: Hands-on Practical
Chapter 3: Regularized Autoencoders for Robust Representations
Addressing Overfitting in Autoencoders
Sparse Autoencoders: L1 and KL Divergence
Denoising Autoencoders Architecture and Training
Contractive Autoencoders Formulation
Comparison of Regularization Techniques
Implementing Denoising Autoencoders: Hands-on Practical
Implementing Sparse Autoencoders: Hands-on Practical
Chapter 4: Variational Autoencoders for Generative Modeling
Generative Limitations of Deterministic Autoencoders
Probabilistic Encoders and Decoders
The Latent Variable Model Perspective
The Reparameterization Trick Explained
Deriving the Evidence Lower Bound (ELBO)
KL Divergence Term Analysis
Reconstruction Loss Term in VAEs
Conditional Variational Autoencoders (CVAEs)
Implementing a VAE for Image Generation: Practice
Chapter 5: Advanced Autoencoder Architectures
Convolutional Autoencoders for Spatial Data
Recurrent Autoencoders for Sequential Data
Adversarial Autoencoders (AAEs)
Vector Quantized Variational Autoencoders (VQ-VAEs)
Transformer-Based Autoencoders Overview
Comparing Advanced Architectures
Implementing Convolutional Autoencoders: Practice
Chapter 6: Understanding and Manipulating Latent Spaces
Visualizing Latent Spaces with t-SNE and UMAP
Properties of Learned Representations
Disentangled Representations Theory
Techniques for Promoting Disentanglement
Interpolation and Traversal in Latent Space
Arithmetic Operations in Latent Space
Evaluating Representation Quality Metrics
Latent Space Visualization and Analysis: Hands-on Practical
Chapter 7: Applications and Training Strategies
Autoencoders for Anomaly Detection
Dimensionality Reduction and Data Compression Uses
Autoencoders for Pre-training Deep Networks
Image Denoising and Inpainting Applications
Sequence-to-Sequence Autoencoders Overview
Advanced Optimization Algorithms
Learning Rate Schedules and Adjustment
Hyperparameter Tuning Strategies
Implementing Anomaly Detection with Autoencoders: Practice

Probabilistic Encoders and Decoders

Standard autoencoders, while proficient at reconstruction, struggle with generating novel data. Their deterministic nature often results in latent spaces that are not continuous or structured enough for meaningful sampling. Generating realistic samples requires moving from mapping an input xxx to a single point zzz in the latent space and back to a single reconstruction x′x'x′.

Variational Autoencoders introduce a probabilistic perspective to both the encoding and decoding processes, laying the groundwork for effective generative modeling. Instead of deterministic mappings, we work with probability distributions.

Probabilistic Encoders: Mapping Inputs to Latent Distributions

In a standard autoencoder, the encoder fff maps an input xxx directly to a latent code z=f(x)z = f(x)z=f(x). In contrast, the VAE encoder doesn't output a single point zzz. Instead, it outputs parameters for a probability distribution over the latent space, conditioned on the input xxx. This distribution, denoted as qϕ(z∣x)q_\phi(z|x)qϕ​(z∣x), represents our belief about the likely latent codes zzz that could have generated the input xxx. The parameters of the encoder network are denoted by ϕ\phiϕ.

Typically, qϕ(z∣x)q_\phi(z|x)qϕ​(z∣x) is chosen to be a multivariate Gaussian distribution with a diagonal covariance matrix. This simplifies calculations and works well in practice. Therefore, for a given input xxx, the encoder network (parameterized by ϕ\phiϕ) outputs two vectors:

  1. A vector of means, μϕ(x)\mu_\phi(x)μϕ​(x).
  2. A vector of variances, σϕ2(x)\sigma^2_\phi(x)σϕ2​(x) (often, the network outputs the log-variances, log⁡σϕ2(x)\log \sigma^2_\phi(x)logσϕ2​(x), for numerical stability).

The approximate posterior distribution is then:

qϕ(z∣x)=N(z∣μϕ(x),diag(σϕ2(x)))q_\phi(z|x) = \mathcal{N}(z | \mu_\phi(x), \text{diag}(\sigma^2_\phi(x)))qϕ​(z∣x)=N(z∣μϕ​(x),diag(σϕ2​(x)))

Here, N(z∣μ,Σ)\mathcal{N}(z | \mu, \Sigma)N(z∣μ,Σ) denotes a Gaussian distribution over zzz with mean μ\muμ and covariance Σ\SigmaΣ. Using a diagonal covariance matrix means we assume conditional independence between the dimensions of the latent variable zzz, given the input xxx.

Why is this probabilistic encoding significant?

  • Capturing Uncertainty: It acknowledges that there might be multiple plausible latent representations zzz for a given input xxx.
  • Regularization: As we will see later when discussing the VAE objective (the ELBO), this probabilistic encoding allows us to regularize the latent space by encouraging qϕ(z∣x)q_\phi(z|x)qϕ​(z∣x) to be close to a chosen prior distribution p(z)p(z)p(z) (usually a standard Gaussian N(0,I)\mathcal{N}(0, I)N(0,I)). This encourages the encoder to utilize the latent space efficiently and continuously, making it suitable for sampling.
  • Sampling: During training, instead of passing a fixed zzz to the decoder, we sample zzz from the distribution qϕ(z∣x)q_\phi(z|x)qϕ​(z∣x). This requires a special technique (the reparameterization trick, covered later) to allow gradient backpropagation.

Probabilistic Decoders: Generating Data from Latent Codes

Similar to the encoder, the VAE decoder also adopts a probabilistic view. A standard decoder ggg takes a latent code zzz and outputs a single reconstruction x′=g(z)x' = g(z)x′=g(z). The VAE decoder, parameterized by θ\thetaθ, takes a latent variable zzz (sampled from qϕ(z∣x)q_\phi(z|x)qϕ​(z∣x) during training, or from the prior p(z)p(z)p(z) for generation) and outputs the parameters of a probability distribution over the data space xxx. This distribution is denoted as pθ(x∣z)p_\theta(x|z)pθ​(x∣z). It represents the likelihood of observing data xxx given the latent code zzz.

The choice of the distribution pθ(x∣z)p_\theta(x|z)pθ​(x∣z) depends on the nature of the data xxx:

  • Continuous Data (e.g., normalized image pixels): A common choice is a multivariate Gaussian distribution. The decoder network might output the mean μθ(z)\mu_\theta(z)μθ​(z), and the covariance could be assumed to be fixed (e.g., σ2I\sigma^2 Iσ2I where σ2\sigma^2σ2 is a hyperparameter or learned) or also output by the network.

    pθ(x∣z)=N(x∣μθ(z),σ2I)p_\theta(x|z) = \mathcal{N}(x | \mu_\theta(z), \sigma^2 I)pθ​(x∣z)=N(x∣μθ​(z),σ2I)

    Maximizing the log-likelihood log⁡pθ(x∣z)\log p_\theta(x|z)logpθ​(x∣z) under this assumption corresponds to minimizing the Mean Squared Error (MSE) between the input xxx and the generated mean μθ(z)\mu_\theta(z)μθ​(z), up to a constant factor.

  • Binary Data (e.g., black and white images): A common choice is a product of independent Bernoulli distributions. The decoder network outputs a vector of probabilities pθ(z)p_\theta(z)pθ​(z), where each element represents the probability of the corresponding dimension of xxx being 1.

    pθ(x∣z)=∏i=1Dpθ,i(z)xi(1−pθ,i(z))1−xip_\theta(x|z) = \prod_{i=1}^{D} p_{\theta, i}(z)^{x_i} (1 - p_{\theta, i}(z))^{1-x_i}pθ​(x∣z)=i=1∏D​pθ,i​(z)xi​(1−pθ,i​(z))1−xi​

    where DDD is the dimensionality of xxx. Maximizing the log-likelihood log⁡pθ(x∣z)\log p_\theta(x|z)logpθ​(x∣z) in this case corresponds to minimizing the Binary Cross-Entropy (BCE) loss between the input xxx and the output probabilities pθ(z)p_\theta(z)pθ​(z).

This probabilistic decoder provides a principled way to define the reconstruction quality. Instead of just minimizing a distance metric, we aim to maximize the likelihood of the original data xxx under the distribution generated by the decoder, given the latent code zzz. This fits naturally into the overall probabilistic framework of VAEs and the derivation of their objective function.

Simplified flow of a Variational Autoencoder, highlighting the probabilistic nature of the encoder (qϕ(z∣x)q_\phi(z|x)qϕ​(z∣x)) and decoder (pθ(x∣z)p_\theta(x|z)pθ​(x∣z)). The encoder maps input xxx to parameters of a latent distribution, from which zzz is sampled. The decoder maps zzz to parameters of an output distribution, modeling the likelihood of the data.

By defining both the encoder and decoder probabilistically, VAEs establish a formal connection to latent variable models and enable the derivation of a well-principled objective function, the Evidence Lower Bound (ELBO), which balances data reconstruction with latent space regularization. This structure helps VAEs learn latent spaces suitable for generating new data. We will examine the full model perspective and the ELBO derivation in the subsequent sections.

  • Auto-Encoding Variational Bayes, Diederik P Kingma, Max Welling, 2013 International Conference on Learning Representations (ICLR) DOI: 10.48550/arXiv.1312.6114 - This paper introduced the Variational Autoencoder, presenting its probabilistic encoder and decoder framework for generative modeling.
  • Deep Learning, Ian Goodfellow, Yoshua Bengio, and Aaron Courville, 2016 (MIT Press) - This textbook provides a thorough treatment of deep learning, including a section that explains Variational Autoencoders and their probabilistic components in detail.
  • Variational Autoencoders (VAEs), Aditya Grover, 2018 CS236: Deep Generative Models Course Notes (Stanford University) - Course materials from Stanford University offering a structured explanation of Variational Autoencoders, covering probabilistic encoding and decoding.

© 2026 ApX Machine Learning