liveBook · Manning

Encoder

As explained in Outlier Detection in Python

An encoder is the component of an autoencoder that transforms an input into a compressed representation.

An encoder is the first part of an autoencoder: it transforms an input into a compact representation. Its layers reduce the data to progressively fewer neurons, ending at a bottleneck whose values form an embedding, or latent representation. A decoder then attempts to reconstruct the original input from that representation. section 16.2.1

Figure 16.2 Example of an AE. The neural network learns to condense any input to as many elements as appear in the middle layer and then reconstruct the data to its original values.

The diagram shows where compression ends and reconstruction begins: the narrow middle layer is the encoder’s output. section 16.2.1

For tabular data, an autoencoder processes one row at a time, with inputs corresponding to columns; for images, inputs can correspond to pixels. The goal is not to predict a separate target but to reproduce the input with little loss. Reconstruction error can then help identify potential outliers, rather than establishing that every poorly reconstructed item is a meaningful anomaly. section 16.2.1 section 16.4

Image encoder

A CIFAR10 example normalizes images and defines a TensorFlow Keras encoder with convolutional layers, a flattening step, and a dense layer producing a 1,024-value encoding. An alibi-detect autoencoder then reconstructs images: a boat image is reconstructed closely, while a noise-perturbed version has high reconstruction error and is flagged as an outlier. section 16.4

An encoder also appears in a bidirectional generative adversarial network (BiGAN). There it acts as an inverse mapper, taking data toward the latent vector used by the generator. At prediction time, the encoded data can pass through the generator for a reconstruction comparison and through the discriminator for another outlier signal. This is a related role, not the autoencoder’s symmetric encoder–decoder arrangement. section 16.2.3

How Outlier Detection in Python covers it

How deep it goes
Explains shrinking layers and the bottleneck, then shows an image-network definition without deriving encoder training mathematically.
Examples
Uses tabular rows, image pixels, and a CIFAR10 image encoder tested on an original and noise-perturbed image.
What it assumes
Introduces the bottleneck and latent representation while using neural-network layers and tabular or image inputs as working vocabulary.
What you can do after
Apply it via TensorFlow Keras and alibi-detect to encode images and examine reconstruction-based outlier scores.
How it connects
Links autoencoders, decoders, embeddings, reconstruction error, and bidirectional generative adversarial networks.

Also explained in

Compare how 21 books explain encoder →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Outlier Detection in Python. The section links point to the parts of the book it draws on.