ArticleslgStudy

mathematics

Variational autoencoder

Variational autoencoder is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Variational autoencoder rather than just read about it. In short: In machine learning, a variational autoencoder (VAE) is an artificial neural network architecture introduced by Diederik P. Kingma and Max Welling in 2013.

Variational autoencoder — main illustration
Variational autoencoder — illustration

Key takeaways

  • Variational autoencoder belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Variational autoencoder to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Variational autoencoder from memory before moving on to harder problems.

Reference excerpt

In machine learning, a variational autoencoder (VAE) is an artificial neural network architecture introduced by Diederik P. Kingma and Max Welling in 2013. It is part of the families of probabilistic graphical models and variational Bayesian methods. In addition to being seen as an autoencoder neural network architecture, variational autoencoders can also be studied within the mathematical formulation of variational Bayesian methods, connecting a neural encoder network to its decoder through a probabilistic latent space (for example, as a multivariate Gaussian distribution) that corresponds to the parameters of a variational distribution. Thus, the encoder maps each point (such as an image) from a large complex dataset into a distribution within the latent space, rather than to a single point in that space. The decoder has the opposite function, which is to map from the latent space to the input space, again according to a distribution (although in practice, noise is rarely added during the decoding stage). By mapping a point to a distribution instead of a single point, the network can avoid overfitting the training data. Both networks are typically trained together with the usage of the reparameterization trick, although the variance of the noise model can be learned separately. Although this type of model was initially designed for unsupervised learning, its effectiveness has been proven for semi-supervised learning and supervised learning.

Overview of architecture and operation A variational autoencoder is a generative model with a prior and noise distribution respectively. Usually such models are trained using the expectation-maximization meta-algorithm (e.g. probabilistic PCA, (spike & slab) sparse coding). Such a scheme optimizes a lower bound of the data likelihood, which is usually computationally intractable, and in doing so requires the discovery of q-distributions, or variational posteriors. These q-distributions are normally parameterized for each individual data point in a separate optimization process. However, variational autoencoders use a neural network as an amortized approach to jointly optimize across data points. In that way, the same parameters are reused for multiple data points, which can result in massive memory savings. The first neural network takes as input the data points themselves, and outputs parameters for the variational distribution. As it maps from a known input space to the low-dimensional latent space, it is called the encoder. The decoder is the second neural network of this model. It is a function that maps from the latent space to the input space, e.g. as the means of the noise distribution. It is possible to use another neural network that maps to the variance, however this can be omitted for simplicity. In such a case, the variance can be optimized with gradient descent. To optimize this model, one needs to know two terms: the "reconstruction error", and the Kullback–Leibler divergence (KL-D). Both terms are derived from the free energy expression of the probabilistic model, and therefore differ depending on the noise distribution and the assumed prior of the data, here referred to as p-distribution. For example, a standard VAE task such as IMAGENET is typically assumed to have a gaussianly distributed noise; however, tasks such as binarized MNIST require a Bernoulli noise. The KL-D from the free energy expression maximizes the probability mass of the q-distribution that overlaps with the p-distribution, which unfortunately can result in mode-seeking behaviour. The "reconstruction" term is the remainder of the free energy expression, and requires a sampling approximation to compute its expectation value. More recent approaches replace Kullback–Leibler divergence (KL-D) with various statistical distances, see "Statistical distance VAE variants" below.

Formulation From the point of view of probabilistic modeling, one wants to maximize the likelihood of the data x {\displaystyle x} by their chosen parameterized probability distribution p θ ( x ) = p ( x | θ ) {\displaystyle p_{\theta }(x)=p(x|\theta )} . This distribution is usually chosen to be a Gaussian N ( x | μ , σ ) {\displaystyle N(x|\mu ,\sigma )} which is parameterized by μ {\displaystyle \mu } and σ {\displaystyle \sigma } respectively, and as a member of the exponential family it is easy to work with as a noise distribution. Simple distributions are easy enough to maximize, however distributions where a prior is assumed over the latents z {\displaystyle z} results in intractable integrals. Let us find p θ ( x ) {\displaystyle p_{\theta }(x)} via marginalizing over z {\displaystyle z} .

p θ ( x ) = ∫ z p θ ( x , z ) d z , {\displaystyle p_{\theta }(x)=\int _{z}p_{\theta }({x,z})\,dz,}

where p θ ( x , z ) {\displaystyle p_{\theta }({x,z})} represents the joint distribution under p θ {\displaystyle p_{\theta }} of the observable data x {\displaystyle x} and its latent representation or encoding z {\displaystyle z} . According to the chain rule, the equation can be rewritten as

… excerpt ends here. Continue reading the full article.

Illustrations

Variational autoencoder: The basic scheme of a variational autoencoder. The model receives 
  
    
      
        x
      
    
    {\displaystyle x}
  
 as input. The encoder compresses it into the latent space. The decoder receives as input the information sampled from the latent space and produces 
  
    
      
        
          
            x
            ′
          
        
      
    
    {\displaystyle {x'}}
  
 as similar as possible to 
  
    
      
        x
      
    
    {\displaystyle x}
  
.
The basic scheme of a variational autoencoder. The model receives x {\displaystyle x} as input. The encoder compresses it into the latent space. The decoder receives as input the information sampled from the latent space and produces x ′ {\displaystyle {x'}} as similar as possible to x {\displaystyle x} .
Variational autoencoder: The scheme of the reparameterization trick. The randomness variable 
  
    
      
        
          ε
        
      
    
    {\displaystyle {\varepsilon }}
  
 is injected into the latent space 
  
    
      
        z
      
    
    {\displaystyle z}
  
 as external input. In this way, it is possible to backpropagate the gradient without involving stochastic variable during the update.
The scheme of the reparameterization trick. The randomness variable ε {\displaystyle {\varepsilon }} is injected into the latent space z {\displaystyle z} as external input. In this way, it is possible to backpropagate the gradient without involving stochastic variable during the update.
Variational autoencoder: The scheme of a variational autoencoder after the reparameterization trick
The scheme of a variational autoencoder after the reparameterization trick

Worked examples

Example 1 — a first encounter with Variational autoencoder

Start with the simplest possible case. Write down what Variational autoencoder claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Variational autoencoder before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Variational autoencoder ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Variational autoencoder

In research
Variational autoencoder appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Variational autoencoder in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Variational autoencoder is common in secondary-school and first-year university syllabi. It links to neighbouring topics 2013 in artificial intelligence, Bayesian statistics, Dimension reduction, so understanding it makes those chapters shorter.
In everyday life
Look for Variational autoencoder outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Variational autoencoder in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Variational autoencoder means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Variational autoencoder out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Variational autoencoder in simple terms?

In machine learning, a variational autoencoder (VAE) is an artificial neural network architecture introduced by Diederik P. Kingma and Max Welling in 2013.

Why does Variational autoencoder matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Variational autoencoder?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Variational autoencoder.

Tags

  • 2013 in artificial intelligence
  • Bayesian statistics
  • Dimension reduction
  • Graphical models
  • Neural network architectures
  • Supervised learning
  • Unsupervised learning

Keep exploring