A PCA-like Autoencoder

Saïd Ladjal, Alasdair Newson, Chi-Hieu PhamarXiv 2019

Abstract

An autoencoder is a neural network which data projects to and from a lower dimensional latent space, where this data is easier to understand and model. The autoencoder consists of two sub-networks, the encoder and the decoder, which carry out these transformations. The neural network is trained such that the output is as close to the input as possible, the data having gone through an information bottleneck: the latent space. This tool bears significant resemblance to Principal Component Analysis (PCA), with two main differences. Firstly, the autoencoder is a non-linear transformation, contrary to PCA, which makes the autoencoder more flexible and powerful. Secondly, the axes found by a PCA are orthogonal, and are ordered in terms of the amount of variability which the data presents along these axes. This makes the interpretability of the PCA much greater than that of the autoencoder, which does not have these attributes. Ideally, then, we would like an autoencoder whose latent space consists of independent components, ordered by decreasing importance to the data. In this paper, we propose an algorithm to create such a network. We create an iterative algorithm which progressively increases the size of the latent space, learning a new dimension at each step. Secondly, we propose a covariance loss term to add to the standard autoencoder loss function, as well as a normalisation layer just before the latent space, which encourages the latent space components to be statistically independent. We demonstrate the results of this autoencoder on simple geometric shapes, and find that the algorithm indeed finds a meaningful representation in the latent space. This means that subsequent interpolation in the latent space has meaning with respect to the geometric properties of the images.

Introduction

In representation learning, autoencoders are widely used to compress data into a "latent space" bottleneck and reconstruct the original input. However, standard autoencoders often produce "black box" latent spaces where dimensions are entangled. Unlike Principal Component Analysis (PCA)—a classical linear technique where axes are orthogonal and ordered by explained variance—a standard autoencoder’s latent dimensions lack inherent order or physical interpretability. Tweaking one value in the latent code often changes multiple attributes of the reconstructed object simultaneously. This research introduces a "PCA-Like Autoencoder" designed to bridge the gap between the non-linear flexibility of deep learning and the structured interpretability of PCA.

Methodology

The proposed architecture achieves PCA-like properties through two primary innovations:

1. Iterative Greedy Training

Instead of training a multi-dimensional latent space simultaneously, the network is trained progressively. The process begins with a latent space of size 1. Once this dimension is optimized, it is "frozen," and a second dimension is added. Only the new components are trained in the subsequent step. This hierarchy forces the network to capture the most significant variance in the first dimension, followed by the next most important features in subsequent dimensions, mimicking the eigenvalue ordering in PCA.

2. Covariance Loss and Normalization

To ensure statistical independence between latent dimensions, a custom covariance loss term is added to the standard reconstruction error. To facilitate optimization, a modified Batch Normalization layer is inserted immediately before the latent space, ensuring the codes maintain a zero mean. The resulting model uses a convolutional architecture with six hidden layers and LeakyReLUs.

Experimental Results

The model was evaluated on synthetic datasets where ground truth parameters are known, allowing for direct verification of latent axis alignment.

A sample 2D ellipse from the dataset, where parameters like axis length are varied.

Datasets

  • 2D Ellipses: Binary images varying in two parameters (major and minor axes).
  • 3D Ellipses: Images varying in three parameters (axes plus rotation).
  • Disks with Grayscale: Images varying in radius and brightness.
A sample 3D ellipse demonstrating rotation, a key parameter the model aims to isolate in the latent space.

Key Findings

The PCA Autoencoder successfully replicated PCA’s importance hierarchy and achieved disentanglement without supervised labels. In the 2D ellipse dataset, the first latent axis consistently controlled the surface area, while the second controlled the axis ratio. In the 3D case, the model isolated surface area in the first dimension and orientation in the others. In contrast, standard autoencoders produced unpredictable morphing during latent space interpolation, mixing size and rotation.

Discussion and Future Work

While successful on geometric shapes, the model encountered limitations with the grayscale disk dataset, where it struggled to perfectly separate radius from brightness. This suggests that strictly learning one dimension at a time may be too restrictive for certain data types.

Future research will explore learning in "packets" of dimensions to accommodate inherently multi-dimensional features (e.g., spatial coordinates). Additionally, the authors aim to scale this approach to complex natural images, such as faces, to investigate its ability to capture high-level visual hierarchies.

Summary updated

BibTeX
@misc{ladjal2019pca,
  author = {Saïd Ladjal and Alasdair Newson and Chi-Hieu Pham},
  title = {{A PCA-like Autoencoder}},
  year = {2019},
  eprint = {1904.01277},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1904.01277},
}
Figure