TL;DR
A representation is a new way of describing an input, as a list of numbers the model computes for itself. Representation learning means training a model so that these numbers are useful, usually because they make the final task easy: a simple classifier on top can then do the job. Instead of hand-designing features, you let gradient descent shape them.
Where you'll see it: the hidden layers of image classifiers, the word vectors inside language models, and the pretrained encoders that get reused for search, recommendation and transfer to new tasks.
Intuition
Rewriting the data until the answer is obvious
Imagine trying to sort red and blue marbles that are scattered on a table in a tangled pattern. You cannot separate them with one straight cut. Now imagine someone gives you a new map of the table where the marbles are already in two clean clusters. The same marbles, in a different description, and the sorting task is trivial.
That is the whole idea. The raw input (pixels, letters, sensor readings) is hard to act on directly. A representation is a transformed description of the same input, and a good one makes the next step easy. Representation learning is the search for that transformation, done automatically from data.
Why not just design the features?
For a long time, practitioners wrote feature extractors by hand. An edge detector, a histogram of colours, a count of word pairs. This works, but a person has to guess which features matter, and the guesses rarely transfer well to a new problem.
A neural network can learn the features as part of training. Each hidden layer produces a new vector, and the layers closer to the output tend to capture more abstract properties. In an image model the first layers respond to edges and textures, the middle ones to parts such as eyes or wheels, and the last ones to whole objects. Nobody programmed those stages. They emerged because they reduce the training loss.
- h1 = ReLU(x)
- h2 = ReLU(x - 1)
Two views of one goal
There are two ways to say what a representation is for. The first is compression: keep the information in the input that matters and throw away the rest. The second is usefulness: keep whatever helps the next task, even if it throws away a lot of detail. Modern systems mostly chase the second, and the best representations are the ones that transfer, meaning they still help on tasks the model was never directly trained on.
The math
Let be an input vector. An encoder is a function with parameters that maps the input to a representation . The representation is a vector of length , where is usually smaller than the input length but not always. The encoder is learned, so is set by minimising a loss.
A common choice is to make the encoder a stack of layers, as in a feedforward network. Write the encoder as a composition , where each is one layer. Then the representation at depth is
Every intermediate is a representation. A task head sits on top of the last one.
The training objective
Training minimises a loss over all parameters, the encoder and the head together:
Here is the number of training examples, and are input and label of example , and is the per-example loss. Gradient descent updates using the gradient of this loss, which Backpropagation computes layer by layer. The representation is never given a target directly. It is shaped only by the gradient flowing back from the final task.
Linear probes
A standard way to measure a representation is the linear probe. Freeze , then fit only a linear head . If a simple linear model reaches high accuracy on , the information needed for the task is present and easy to read. If it does not, either the information is missing or it is tangled.
Self-supervised objectives
Often there are no labels. A common trick is to invent a task from the data itself, for example predicting a masked word from its neighbours, or deciding whether two augmented views came from the same image. The loss still has the form above, but the targets come from the data. This is the core of self-supervised learning, and it is one of the main reasons representation learning scales: unlabelled data is cheap.
For contrastive methods, one popular form is the InfoNCE loss. For a positive pair and a set of negatives , with similarity (the cosine similarity, a normalised dot product) and temperature ,
The loss is small when the positive pair is more similar than every negative. Pulling positives together and pushing negatives apart is what gives the representation its structure.
Worked examples
Take the four binary inputs of XOR. The label is 1 when the two bits differ: , , , . No straight line in the raw input separates the 1s from the 0s.
Use a hidden layer of two ReLU units, and .
- Compute the representation of each input.
- : , , so .
- and : , , so for both.
- : , , so .
- The two inputs with label 1, and , now share one point, and the label-0 points and sit on either side of it along .
- Look for a linear score that works in the new space, predicting label 1 when . Try and .
- : . Below 0.5, label 0, correct.
- : . Above 0.5, label 1, correct.
- : . Below 0.5, label 0, correct.
- Interpretation: the input was not separable in its own coordinates, but after one learned layer a single linear rule classifies all four points correctly. The representation did the hard work, and the classifier on top is trivial. This is the mechanism the rest of the lesson relies on.
Suppose an embedding has learned three-dimensional vectors for three words. The numbers are invented for the example:
Measure similarity with cosine similarity, .
- Dot product king and queen: .
- Norms: , and .
- Cosine of king and queen: .
- Dot product king and apple: . Norm of apple: .
- Cosine of king and apple: .
- Interpretation: king and queen score 0.985 and king and apple score 0.311. The learned space puts related words near each other, and the distance is a usable signal for search, clustering or a downstream classifier, without anyone having written a rule about royalty or fruit.
Tradeoffs and failure modes
Representation learning is the default in most modern systems, but it has costs that the features-by-hand approach did not.
| Situation | Problem | Better choice |
|---|---|---|
| Very little labelled data | The encoder overfits, or the head memorises noise | Start from a pretrained encoder and fine-tune, or use a linear probe on frozen features |
| Task is simple and well understood | A learned encoder is costly and opaque | Hand-built features with a linear model |
| Need to explain each decision | Learned directions have no fixed meaning | Simpler models, or probing and attribution tools after the fact |
| Representation collapses | All inputs map to nearly the same vector, and the head still learns something | Contrastive negatives, a predictor head, or stop-gradient tricks in self-supervised training |
| Representation learns a shortcut | It uses background or texture instead of the object | More varied data, augmentation, or checks on held-out groups |
| Representation does not transfer | It is tuned so tightly to one task that nearby tasks fail | Evaluate with several probes, not only the training task |
The main practical failure is treating a good training score as proof of a good representation. Freeze the encoder and run a linear probe on a different dataset. That test catches most of the problems in the table.
History
The idea that a network's hidden units should learn useful features is older than deep learning. Early connectionist work in the 1980s, including the popularisation of backpropagation by Rumelhart, Hinton and Williams in 1986, showed that hidden layers could learn internal codes for the task.
In the mid-2000s, researchers including Geoffrey Hinton and Yoshua Bengio reported that deep networks could be trained more effectively by pretraining one layer at a time on unlabelled data. This revived interest in learned representations as a separate goal. Bengio, Courville and Vincent's 2013 review gave the field a shared vocabulary and argued that good representations should disentangle the factors that explain the data.
What made the idea dominant was scale. Convolutional networks trained on large labelled image sets in the early 2010s produced features that transferred to many other vision tasks. Word2vec, published by Mikolov and colleagues in 2013, showed that simple prediction tasks on large text could give word vectors with useful geometry. Later, large self-supervised language and vision models made the pretrain-then-adapt pattern standard. Today most applied systems reuse a learned encoder rather than training one from scratch.
Check yourself
QuestionIn one sentence, what does a representation do for the classifier that sits on top of it?Show answer
It rewrites the input as a new vector in which the task is easier, so a simple head, often a linear one, can do the final job. The representation carries the difficulty, and the head only reads the answer off it.
QuestionA hidden layer maps the four XOR inputs to the points (0,0), (1,0), (1,0) and (2,1). Compute the output of the linear rule w = (1, -2), b = 0 for each point, and say whether the classifier is correct.Show answer
For the output is . For it is . For it is . The label for is 1, and the labels for and are both 0, so with the threshold 0.5 all three values match. The fourth input maps to as well, so it gets output 1, which is correct for XOR. The classifier is correct on every input.
QuestionYou have 200 labelled images and a large pretrained encoder. You want a classifier. Should you train the encoder from scratch, freeze it and fit a linear probe, or fine-tune it? Explain the choice.Show answer
Training from scratch on 200 images almost certainly overfits, because the encoder has far more parameters than the data can support. A linear probe on frozen features is the safest first step: it has few parameters and tests whether the pretrained representation already separates the classes. If the probe is not good enough, fine-tune with a small learning rate, and check against a validation split, since fine-tuning can destroy useful structure if it moves too far.
QuestionA self-supervised model reaches very low training loss, but every image in a held-out set maps to nearly the same vector. What went wrong, and what would you change?Show answer
The representation has collapsed. The objective can be minimised without the encoder keeping any information about the input, so it found a trivial solution. The fix is to add a mechanism that prevents this, such as negative examples in a contrastive loss, a predictor head with stop-gradient, or a variance regularisation term. After any change, check the spread of the representations on held-out data, not only the training loss.