Rotation Prediction
Rotation prediction spins each photo by a random right angle and asks the network which way, forcing it to learn what upright objects look like.
Why Does This Exist?
Orientation understanding hides inside every recognition task: dogs have legs below heads, skies sit above ground, text reads left to right. Supervised labels teach these facts incidentally and expensively. A free exercise targeting orientation directly would front-load the most universal visual knowledge.
Rotation prediction is that exercise. Spin each image by a multiple of degrees, ask the network for the angle, and backpropagate. Upright-ness must be learned to score above chance, and upright-ness transfers everywhere. The exercise family is pretext tasks, inside the framework of self-supervised learning.
Think of It Like This
A gallery guard spotting hung paintings
A gallery guard learns every painting so well they notice instantly when one hangs sideways overnight. They never studied art history; thousands of walk-throughs built an expectation of upright for every frame, and violations pop out.
The network is the guard and rotations are the nightly pranks. Expectation of upright is the transferable knowledge. It fails on symmetric art: circular canvases hang any way without offence, and no guard catches those, which is the symmetry limit below.
How It Actually Works
For image , sample uniformly and rotate by degrees. The network outputs four logits; loss is cross-entropy against :
Only multiples of degrees avoid interpolation artefacts that would leak the answer through blur patterns. After pretraining, the classification head is discarded and convolutional features transfer to detection and segmentation with far less labelled data.
Worked example
Logits for true . Exponentials sum to ; probabilities . Loss is . The network is percent sure of degrees from cues like sky position and text baseline, exactly the upright knowledge downstream tasks reuse.
Code
Rotation loss on one spun photo, the complete exercise step.
import numpy as np
def rotation_loss(logits: np.ndarray, k: int) -> float: """Cross-entropy against the known spin index.""" e = np.exp(logits - logits.max()) # shift for numerical safety return round(float(-np.log(e[k] / e.sum())), 2)
print(rotation_loss(np.array([1.2, 2.5, 0.3, -0.5]), 1)) # -> 0.36 confidentprint(rotation_loss(np.array([0.1, 0.1, 0.1, 0.1]), 2)) # -> 1.39 pure chanceWatch Out For
Symmetric images with no correct answer
Balls, top-down textures, and centred flowers look identical under rotation. The exercise punishes correct networks for unanswerable questions, injecting pure noise into gradients.
Filter near-symmetric images from pretraining or accept the noise floor. Chance-level subsets do not indicate broken training, only unanswerable homework.
Interpolation artefacts from non-right angles
Rotate by degrees and resampling blur patterns correlate with the angle, handing the network a cheat code written in pixels. Scores soar while features learn resampling, not objects.
Stick to exact multiples of degrees with nearest-exact transforms. Audit with artefact-free validation before celebrating accuracy.
The Quick Version
- Rotation prediction classifies spins of , , , degrees with free labels.
- Our logits give percent confidence on the true spin for loss .
- Chance-level guessing scores , the floor every run must beat.
- Upright-ness learned this way transfers to detection and segmentation.
- Symmetric images and interpolated angles are the two homework traps.