Lably
Skip to content

Autoencoder

Neural network that learns efficient data encoding in an unsupervised manner

  • 15 min read
  • 5 chapters
Autoencoder schema
Michela Massi · CC BY-SA 4.0

Related on Lably

Through Neural network (machine learning), Unsupervised learning and Machine learning

Variants exist which aim to make the learned representations assume useful properties. Examples are regularized autoencoders (sparse, denoising and contractive autoencoders), which are effective in learning representations for subsequent classification tasks, and variational autoencoders, which can be used as generative models. Autoencoders are applied to many problems, including facial recognition, feature detection, anomaly detection, and learning the meaning of words. In terms of data synthesis, autoencoders can also be used to randomly generate new data that is similar to the input (training) data.

Mathematical principles

Definition

An autoencoder is defined by the following components:

Two sets: the space of encoded messages Z; the space of decoded messages X. Typically X and Z are Euclidean spaces, that is, X=Rm,Z=Rn with m>n.

Two parametrized families of functions: the encoder family Eϕ:X→Z, parametrized by ϕ; the decoder family Dθ:Z→X, parametrized by θ.

For any x∈X, we usually write z=Eϕ(x), and refer to it as the code, the latent variable, latent representation, latent vector, etc. Conversely, for any z∈Z, we usually write x′=Dθ(z), and refer to it as the (decoded) message.

Usually, both the encoder and the decoder are defined as multilayer perceptrons (MLPs). For example, a one-layer-MLP encoder Eϕ is:

Eϕ(x)=σ(Wx+b)

where σ is an element-wise activation function, W is a "weight" matrix, and b is a "bias" vector.

Training an autoencoder

An autoencoder, by itself, is simply a tuple of two functions. To judge its quality, we need a task. A task is defined by a reference probability distribution μref over X, and a "reconstruction quality" function d:X×X→[0,∞], such that d(x,x′) measures how much x′ differs from x.

With those, we can define the loss function for the autoencoder asL(θ,ϕ):=Ex∼μref[d(x,Dθ(Eϕ(x)))]The optimal autoencoder for the given task (μref,d) is then arg⁡minθ,ϕL(θ,ϕ). The search for the optimal autoencoder can be accomplished by any mathematical optimization technique, but usually by gradient descent. This search process is referred to as "training the autoencoder".

In most situations, the reference distribution is just the empirical distribution given by a dataset {x1,...,xN}⊂X, so thatμref=1N∑i=1Nδxi

where δxi is the Dirac measure, the quality function is just L2 loss: d(x,x′)=‖x−x′‖22, and ‖⋅‖2 is the Euclidean norm. Then the problem of searching for the optimal autoencoder is just a least-squares optimization:minθ,ϕL(θ,ϕ),where L(θ,ϕ)=1N∑i=1N‖xi−Dθ(Eϕ(xi))‖22

Interpretation

An autoencoder has two main parts: an encoder that maps the message to a code, and a decoder that reconstructs the message from the code. An optimal autoencoder would perform as close to perfect reconstruction as possible, with "close to perfect" defined by the reconstruction quality function d.

The simplest way to perform the copying task perfectly would be to duplicate the signal. To suppress this behavior, the code space Z usually has fewer dimensions than the message space X.

Such an autoencoder is called undercomplete. It can be interpreted as compressing the message, or reducing its dimensionality.

At the limit of an ideal undercomplete autoencoder, every possible code z in the code space is used to encode a message x that really appears in the distribution μref, and the decoder is also perfect: Dθ(Eϕ(x))=x. This ideal autoencoder can then be used to generate messages indistinguishable from real messages, by feeding its decoder arbitrary code z and obtaining Dθ(z), which is a message that really appears in the distribution μref.

If the code space Z has dimension larger than (overcomplete), or equal to, the message space X, or the hidden units are given enough capacity, an autoencoder can learn the identity function and become useless. However, experimental results found that overcomplete autoencoders might still learn useful features.

In the ideal setting, the code dimension and the model capacity could be set on the basis of the complexity of the data distribution to be modeled. A standard way to do so is to add modifications to the basic autoencoder, to be detailed below.

Sign in to keep reading

4 more chapters are free with a Lably account.

More in Computing and communication