Latent Space
A latent space is the space of internal codes or variables a model uses to represent data. Its dimensions and geometry depend on the model and training objective; it need not be smaller than the input or neatly organized by human meaning.
An autoencoder can map a handwritten digit image to a code, then use a decoder to reconstruct an image from that code. In Keras’s variational autoencoder example, the code has two dimensions, so points can be plotted and decoded into a grid of generated digits.
The code’s coordinates are not necessarily labels such as “roundness” and “slant.” Training shapes the representation to serve its objective. Moving between points can produce changing outputs, but arbitrary points are not guaranteed to decode into meaningful examples. A two-dimensional teaching example is also not evidence that all latent spaces have two dimensions.
This matters when interpreting similarity. An embedding is a representation of an item; the space describes the possible representations and their relationships. Nearby points may be useful for retrieval, but distance only reflects the learned representation and chosen comparison. Test whether that neighborhood captures the distinctions your task needs.
Sources
- Keras: Variational AutoEncoder — Builds a two-dimensional latent code for digit images, with an encoder, decoder and sampled grid.
Go deeper
- Keras: Convolutional autoencoder for image denoising docs
Follow an encoder-decoder path and compare reconstructions while learning a denoising task.