# Autoencoder

Schematic structure of an autoencoder with 3 fully-connected hidden layers.

An autoencoder is an artificial neural network used for unsupervised learning of efficient codings.[1][2] The aim of an autoencoder is to learn a representation (encoding) for a set of data, typically for the purpose of dimensionality reduction. Recently, the autoencoder concept has become more widely used for learning generative models of data.[3][4] Some of the most powerful AI in the 2010s involves stacking sparse autoencoders in a deep learning network.[5]

## PurposeEdit

An autoencoder learns to compress data from the input layer into a short code, and then uncompress that code into something that closely matches the original data. This forces the autoencoder to engage in dimensionality reduction, for example by learning how to ignore noise. Some architectures use stacked sparse autoencoder layers for image recognition. The first autoencoder might learn to encode easy features like corners, the second to analyze the first layer's output and then encode less local features like the tip of a nose, the third might encode a whole nose, etc., until the final autoencoder encodes the whole image into a code that matches (for example) the concept of "cat".[5] An alternative use is as a generative model: for example, if a system is manually fed the codes it has learned for "cat" and "flying", it may attempt to generate an image of a flying cat, even if it has never seen a flying cat before.[3][6]

## StructureEdit

Architecturally, the simplest form of an autoencoder is a feedforward, non-recurrent neural network very similar to the multilayer perceptron (MLP) – having an input layer, an output layer and one or more hidden layers connecting them – but with the output layer having the same number of nodes as the input layer, and with the purpose of reconstructing its own inputs (instead of predicting the target value ${\displaystyle Y}$  given inputs ${\displaystyle X}$ ). Therefore, autoencoders are unsupervised learning models.

An autoencoder always consists of two parts, the encoder and the decoder, which can be defined as transitions ${\displaystyle \phi }$  and ${\displaystyle \psi ,}$  such that:

${\displaystyle \phi :{\mathcal {X}}\rightarrow {\mathcal {F}}}$
${\displaystyle \psi :{\mathcal {F}}\rightarrow {\mathcal {X}}}$
${\displaystyle \phi ,\psi ={\underset {\phi ,\psi }{\operatorname {arg\,min} }}\,\|X-(\psi \circ \phi )X\|^{2}}$

In the simplest case, where there is one hidden layer, the encoder stage of an autoencoder takes the input ${\displaystyle \mathbf {x} \in \mathbb {R} ^{d}={\mathcal {X}}}$  and maps it to ${\displaystyle \mathbf {z} \in \mathbb {R} ^{p}={\mathcal {F}}}$ :

${\displaystyle \mathbf {z} =\sigma (\mathbf {Wx} +\mathbf {b} )}$

This image ${\displaystyle \mathbf {z} }$  is usually referred to as code, latent variables, or latent representation. Here, ${\displaystyle \sigma }$  is an element-wise activation function such as a sigmoid function or a rectified linear unit. ${\displaystyle \mathbf {W} }$  is a weight matrix and ${\displaystyle \mathbf {b} }$  is a bias vector. After that, the decoder stage of the autoencoder maps ${\displaystyle \mathbf {z} }$  to the reconstruction ${\displaystyle \mathbf {x'} }$  of the same shape as ${\displaystyle \mathbf {x} }$ :

${\displaystyle \mathbf {x'} =\sigma '(\mathbf {W'z} +\mathbf {b'} )}$

where ${\displaystyle \mathbf {\sigma '} ,\mathbf {W'} ,{\text{ and }}\mathbf {b'} }$  for the decoder may differ in general from the corresponding ${\displaystyle \mathbf {\sigma } ,\mathbf {W} ,{\text{ and }}\mathbf {b} }$  for the encoder, depending on the design of the autoencoder.

Autoencoders are also trained to minimise reconstruction errors (such as squared errors):

${\displaystyle {\mathcal {L}}(\mathbf {x} ,\mathbf {x'} )=\|\mathbf {x} -\mathbf {x'} \|^{2}=\|\mathbf {x} -\sigma '(\mathbf {W'} (\sigma (\mathbf {Wx} +\mathbf {b} ))+\mathbf {b'} )\|^{2}}$

where ${\displaystyle \mathbf {x} }$  is usually averaged over some input training set.

If the feature space ${\displaystyle {\mathcal {F}}}$  has lower dimensionality than the input space ${\displaystyle {\mathcal {X}}}$ , then the feature vector ${\displaystyle \phi (x)}$  can be regarded as a compressed representation of the input ${\displaystyle x}$ . If the hidden layers are larger than the input layer, an autoencoder can potentially learn the identity function and become useless. However, experimental results have shown that autoencoders might still learn useful features in these cases.[7]:19

### VariationsEdit

Various techniques exist to prevent autoencoders from learning the identity function and to improve their ability to capture important information and learn richer representations:

#### Denoising autoencoderEdit

Denoising autoencoders take a partially corrupted input whilst training to recover the original undistorted input. This technique has been introduced with a specific approach to good representation.[8] A good representation is one that can be obtained robustly from a corrupted input and that will be useful for recovering the corresponding clean input. This definition contains the following implicit assumptions:

• The higher level representations are relatively stable and robust to the corruption of the input;
• It is necessary to extract features that are useful for representation of the input distribution.

To train an autoencoder to denoise data, it is necessary to perform preliminary stochastic mapping ${\displaystyle \mathbf {x} \rightarrow \mathbf {\tilde {x}} }$  in order to corrupt the data and use ${\displaystyle \mathbf {\tilde {x}} }$  as input for a normal autoencoder, with the only exception being that the loss should be still computed for the initial input ${\displaystyle {\mathcal {L}}(\mathbf {x} ,\mathbf {{\tilde {x}}'} )}$  instead of ${\displaystyle {\mathcal {L}}(\mathbf {\tilde {x}} ,\mathbf {{\tilde {x}}'} )}$ .

#### Sparse autoencoderEdit

Autoencoders were originally invented in the 1980s; however, the initial versions were difficult to train, as the encodings have to compete to set the same small set of bits. This was solved by "sparse autoencoding". In a sparse autoencoder, there are actually more (rather than fewer) hidden units than inputs, but only a small number of the hidden units are allowed to be active at the same time.[5]

Sparsity may be achieved by additional terms in the loss function during training (by comparing the probability distribution of the hidden unit activations with some low desired value),[9] or by manually zeroing all but the few strongest hidden unit activations (referred to as a k-sparse autoencoder).[10]

#### Variational autoencoder (VAE)Edit

Variational autoencoder models inherit autoencoder architecture, but make strong assumptions concerning the distribution of latent variables. They use variational approach for latent representation learning, which results in an additional loss component and specific training algorithm called Stochastic Gradient Variational Bayes (SGVB).[3] It assumes that the data is generated by a directed graphical model ${\displaystyle p(\mathbf {x} |\mathbf {z} )}$  and that the encoder is learning an approximation ${\displaystyle q_{\phi }(\mathbf {z} |\mathbf {x} )}$  to the posterior distribution ${\displaystyle p_{\theta }(\mathbf {z} |\mathbf {x} )}$  where ${\displaystyle \mathbf {\phi } }$  and ${\displaystyle \mathbf {\theta } }$  denote the parameters of the encoder (recognition model) and decoder (generative model) respectively. The objective of the variational autoencoder in this case has the following form:

${\displaystyle {\mathcal {L}}(\mathbf {\phi } ,\mathbf {\theta } ,\mathbf {x} )=D_{\mathrm {KL} }(q_{\phi }(\mathbf {z} |\mathbf {x} )\Vert p_{\theta }(\mathbf {z} ))-\mathbb {E} _{q_{\phi }(\mathbf {z} |\mathbf {x} )}{\big (}\log p_{\theta }(\mathbf {x} |\mathbf {z} ){\big )}}$

Here, ${\displaystyle D_{\mathrm {KL} }}$  stands for the Kullback–Leibler divergence. The prior over the latent variables is usually set to be the centred isotropic multivariate Gaussian ${\displaystyle p_{\theta }(\mathbf {z} )={\mathcal {N}}(\mathbf {0,I} )}$ ; however, alternative configurations have also been recently considered, e.g. [11]

#### Contractive autoencoder (CAE)Edit

Contractive autoencoder adds an explicit regularizer in their objective function that forces the model to learn a function that is robust to slight variations of input values. This regularizer corresponds to the Frobenius norm of the Jacobian matrix of the encoder activations with respect to the input. The final objective function has the following form:

${\displaystyle {\mathcal {L}}(\mathbf {x} ,\mathbf {x'} )+\lambda \sum _{i}||\nabla _{x}h_{i}||^{2}}$

### Relationship with principal component analysis (PCA)Edit

If linear activations are used, or only a single sigmoid hidden layer, then the optimal solution to an autoencoder is strongly related to principal component analysis (PCA).[12][13] The weights of the autoencoder span the same vector subspace as the one spanned by the first ${\displaystyle p}$  principal components, and the output of the autoencoder is an orthogonal projection onto this subspace. The autoencoder weights are not equal to the principal components, and are generally not orthogonal, yet the principal components may be recovered from them using singular value decomposition.[14]

## TrainingEdit

The training algorithm for an autoencoder can be summarized as

For each input x,
Do a feed-forward pass to compute activations at all hidden layers, then at the output layer to obtain an output ${\displaystyle \mathbf {x'} }$
Measure the deviation of ${\displaystyle \mathbf {x'} }$  from the input ${\displaystyle \mathbf {x} }$  (typically using squared error),
Backpropagate the error through the net and perform weight updates.

An autoencoder is often trained using one of the many variants of backpropagation (such as conjugate gradient method, steepest descent, etc.). Though these are often reasonably effective, there are fundamental problems with the use of backpropagation to train networks with many hidden layers. Once errors are backpropagated to the first few layers, they become minuscule and insignificant. This means that the network will almost always learn to reconstruct the average of all the training data.[citation needed] Though more advanced backpropagation methods (such as the conjugate gradient method) can solve this problem to a certain extent, they still result in a very slow learning process and poor solutions. This problem can be remedied by using initial weights that approximate the final solution. The process of finding these initial weights is often referred to as pretraining.

Stephen Luttrell, while based at RSRE, developed a technique for unsupervised training of hierarchical self-organizing neural nets with "many hidden layers",[15] which are equivalent to deep autoencoders. Geoffrey Hinton developed an alternative pretraining technique for training many-layered deep autoencoders. This method involves treating each neighbouring set of two layers as a restricted Boltzmann machine so that the pretraining approximates a good solution, then using a backpropagation technique to fine-tune the results.[16] This model takes the name of deep belief network.

## ReferencesEdit

1. ^ Modeling word perception using the Elman network, Liou, C.-Y., Huang, J.-C. and Yang, W.-C., Neurocomputing, Volume 71, 3150–3157 (2008), doi:10.1016/j.neucom.2008.04.030
2. ^ Autoencoder for Words, Liou, C.-Y., Cheng, C.-W., Liou, J.-W., and Liou, D.-R., Neurocomputing, Volume 139, 84–96 (2014), doi:10.1016/j.neucom.2013.09.055
3. ^ a b c Auto-Encoding Variational Bayes, Kingma, D.P. and Welling, M., ArXiv e-prints, 2013 arxiv.org/abs/1312.6114
4. ^ Generating Faces with Torch, Boesen A., Larsen L. and Sonderby S.K., 2015 torch.ch/blog/2015/11/13/gan.html
5. ^ a b c Domingos, Pedro (2015). "4". The Master Algorithm: How the Quest for the Ultimate Learning Machine Will Remake Our World. Basic Books. "Deeper into the Brain" subsection. ISBN 978-046506192-1.
6. ^ "New algorithm can create movies from just a few snippets of text". Science | AAAS. 23 February 2018. Retrieved 12 April 2018.
7. ^ Bengio, Y. (2009). "Learning Deep Architectures for AI" (PDF). Foundations and Trends in Machine Learning. 2. doi:10.1561/2200000006.
8. ^ Vincent, Pascal; Larochelle, Hugo; Lajoie, Isabelle; Bengio, Yoshua; Manzagol, Pierre-Antoine (2010). "Stacked Denoising Autoencoders: Learning Useful Representations in a Deep Network with a Local Denoising Criterion". The Journal of Machine Learning Research. 11: 3371–3408.
9. ^ sparse autoencoders (PDF)
10. ^ k-sparse autoencoder, arXiv:
11. ^ Harris Partaourides and Sotirios P. Chatzis, “Asymmetric Deep Generative Models,” Neurocomputing, vol. 241, pp. 90-96, June 2017. [1]
12. ^ Bourlard, H.; Kamp, Y. (1988). "Auto-association by multilayer perceptrons and singular value decomposition". Biological Cybernetics. 59 (4–5): 291–294. doi:10.1007/BF00332918. PMID 3196773.
13. ^ Chicco, Davide; Sadowski, Peter; Baldi, Pierre (25 October 2014). "Deep Autoencoder Neural Networks for Gene Ontology Annotation Predictions". ACM. pp. 533–540. doi:10.1145/2649387.2649442 – via ACM Digital Library.
14. ^ Plaut, E (2018). "From Principal Subspaces to Principal Components with Linear Autoencoders". arXiv. 1804.10253.
15. ^ S.P. Luttrell, Hierarchical self-organising networks, 1st International Conference on Artificial Neural Networks, London, UK, October 1989.
16. ^ Reducing the Dimensionality of Data with Neural Networks (Science, 28 July 2006, Hinton & Salakhutdinov)