# Unsupervised Representation Learning by Predicting Image Rotations

Image rotation prediction teaches ConvNets useful features without labels

Spyros Gidaris, Praveer Singh, Nikos Komodakis · arXiv · 2018-3-21

- **Problem** Supervised ConvNets need massive labeled datasets, which are expensive to build. Earlier self-supervised pretext tasks transfer reasonably well but still do not match supervised features.
- **Method** RotNet trains a ConvNet to recognize which of four rotations (0, 90, 180 or 270 degrees) was applied to an input image. Its intermediate feature maps are then reused for other tasks.
- **Results** With unsupervised pre-training, RotNet reaches 54.4% mAP on PASCAL VOC 2007 detection, 2.4 points below the supervised case.

## Labels that come from the images themselves

Supervised ConvNets learn strong visual features when trained on large labeled collections, but manual annotation is expensive and hard to scale to the visual data available today. Self-supervised learning avoids this cost by defining a pretext task whose targets come from the images or videos themselves. Earlier pretext tasks include colorization, relative patch position and egomotion estimation; they transfer reasonably well to other vision tasks but still do not match supervised representations.

Rotation differs from those tasks because the target is a geometric transformation that the experimenter applies, so the label is known for every input without any annotation. The egomotion method regresses a camera transformation from two consecutive frames, whereas the rotation approach classifies a single image that has been rotated. The authors argue that a network can only tell which rotation was applied if it understands which objects appear in the image, where they are and what pose they have.

## Rotation classification as the training objective

The ConvNet model F outputs a probability for each of K discrete geometric transformations, and its learnable parameters are denoted θ. Each training image X is passed through every transformation g(X\|y), so one image yields K training inputs whose labels y are known by construction. For each image, the loss is \\( \\mathrm{loss}(X\_i,\\theta)=-\\frac{1}{K}\\sum\_{y=1}^{K}\\log F\_y\\bigl(g(X\_i\|y)\\mid\\theta\\bigr) \\), so each term scores the probability the model assigns to the label y of its own rotated copy, and the minus sign makes the loss positive.

The objective is \\( \\min\_{\\theta}\\ \\frac{1}{N}\\sum\_{i=1}^{N}\\mathrm{loss}(X\_i,\\theta) \\), averaged over the N training images and minimized over θ.

For this paper K is 4, and the transformations are image rotations \\( g(X\|y)=\\mathrm{Rot}(X,(y-1)90) \\), where Rot(X, φ) rotates X by φ degrees. During training the four rotated copies of an image are fed to the network together, which the authors report gave better results than sampling one random rotation per visit; the batch therefore holds four times as many images as the batch size.

The 90, 180 and 270 degree rotations are built from flip and transpose operations: 90 degrees is a transpose followed by a vertical flip, 180 degrees is a vertical flip followed by a horizontal flip, and 270 degrees is a vertical flip followed by a transpose. Once pre-training is done, the rotation labels are no longer needed; a separate classifier is trained on feature maps from one block of the RotNet model to measure the features.

## Why rotations and not other transformations

Rotations by multiples of 90 degrees can be implemented with flip and transpose operations that leave no easily detectable low-level artifacts, so the network has no simple shortcut to learn. Scale and aspect-ratio changes would need resizing routines, and the authors note that these leave easily detectable image artifacts.

The task is well posed because human-captured photographs usually show objects in an upright position, so the rotation applied can be read from the content of most images. The authors make one exception: images that only depict round objects leave the rotation ambiguous. Object scale, in contrast, varies widely in human-captured images, so a scale-based task would be less clearly defined.

The method has the same computational cost as supervised learning and converges at a similar speed, which the authors report to be much faster than image reconstruction approaches; their AlexNet model trains in around 2 days on a single Titan X GPU. Because the approach does not need special image pre-processing to avoid trivial features, it can reuse the parallelization schemes built for supervised learning.

## What the rotation classifier attends to

The attention maps are built from a convolutional layer by raising each feature activation to a power p and summing the activations at each spatial location of the feature map. The powers are p = 1 for conv1, p = 2 for conv2 and p = 4 for conv3, and the maps show where the network concentrates when it classifies an input.

For a model trained on rotation recognition, the attention focuses on object parts such as eyes, noses, tails and heads. The authors report that the regions attended to by the rotation model roughly match those of a supervised object recognition model.

The first-layer AlexNet filters from the rotation task are mostly oriented edge filters at several orientations and frequencies, and the authors observe more variety than in the filters from supervised object recognition. These are visual inspections of individual models, so they support the argument qualitatively rather than measuring it.

## CIFAR-10: which block and how many rotations

Three models with 3, 4 and 5 convolutional blocks were trained, and a classifier with three fully connected layers was trained on the feature maps of each block.

In Table 1 the 2nd conv block gives the highest accuracy at each depth: 88.26 for the 3-block model, 89.06 for the 4-block model and 89.76 for the 5-block model. Blocks after the 2nd one lose accuracy, which the authors attribute to these blocks becoming more specific to the rotation prediction task. The authors assume that a more complex head allows earlier features to stay less specific to rotation prediction; this is an assumption, not a tested result.

Table 2 varies the rotation set for the 2nd block of the 4-block model: four rotations give 89.06, eight rotations at multiples of 45 degrees give 88.51, the pair 0 and 180 degrees gives 87.46 and the pair 90 and 270 degrees gives 85.52. The eight-rotation tasks were built with image warping and cropping of the central square, so that the empty image areas introduced by rotation are excluded.

The authors attribute the advantage of four rotations to two rotations supplying too little supervision and eight rotations being hard to tell apart, with the extra angles possibly adding visual artifacts. Among the two-rotation settings, the 90 and 270 degree pair scores lower, which the authors attribute to that model never seeing the 0 degree orientation used during object recognition.

## CIFAR-10 against a supervised NIN and other unsupervised methods

In Table 3 the RotNet model uses the first two conv blocks from rotation pre-training and trains its third block on the object labels, which is compared with a fully supervised NIN of the same architecture. With the conv classifier RotNet reaches 91.16, against 92.80 for the supervised NIN, a gap of 1.64 percentage points. With the non-linear classifier on frozen features it reaches 89.06, and fine-tuning the RotNet features during object training raises the results to 91.73 and 92.17.

A randomly initialized frozen stack of two NIN conv blocks with a conv classifier reaches 72.50.

The other unsupervised rows use different architectures, so the authors describe the comparison as indicative: Roto-Scat with SVM 82.3, ExemplarCNN 84.3, DCGAN 82.8 and Scattering 84.7. The per-class accuracies of the unsupervised and supervised models are given in appendix Table 9.

## Limited labels on CIFAR-10

A 4-block RotNet is first trained on rotation prediction with the full CIFAR-10 training images and no labels, and the feature maps of its 2nd conv block are used as input. The object classifier is a stack of convolutional layers shaped like the 3rd NIN block, followed by a linear classifier, all randomly initialized, and it is trained on 20, 100, 400, 1000 or 5000 labeled examples per category.

A supervised model trained only on the same labeled examples serves as the comparison, and 5000 examples per category is the extreme case of the entire CIFAR-10 training set.

As the number of examples decreases, the gap in favor of the unsupervised-pretrained model increases.

## ImageNet and Places with frozen features

The AlexNet RotNet is trained on ImageNet without labels, and for each layer non-linear layers are trained to perform the 1000-way ImageNet classification task, with the conv5 case training fc6, fc7 and fc8. Under this protocol RotNet reaches 50.0 top-1 accuracy from conv4 and 43.8 from conv5. The highest unsupervised entries in that table are Context at 45.6 for conv4 and NAT at 36.0 for conv5.

The authors report an improvement of more than 4 percentage points at conv4 and around 8 at conv5.

With linear logistic regression on spatially resized frozen features, RotNet reaches 38.7 at conv3, 38.2 at conv4 and 36.5 at conv5 on ImageNet, against 50.5 for the ImageNet-label model at conv5. The authors report improvements over prior unsupervised methods in this linear setting.

On Places205, which has 205 classes, logistic regression is trained on frozen features from the RotNet pre-trained on ImageNet, and the classes were not seen during that pre-training. At conv5 RotNet reaches 33.7 top-1 accuracy, while the Places-label model reaches 44.6 at conv5. At conv1 and conv2 Jigsaw Puzzles and Counting score higher than RotNet, while at conv5 RotNet is above the listed unsupervised entries.

The AlexNet variant here has no local response normalization, dropout or grouped convolutions, includes batch normalization, and was trained with SGD at batch size 192 for 30 epochs.

## PASCAL VOC classification, detection and segmentation

Table 7 uses frameworks from earlier work: classification either fixes the features before conv5 (the fc6-8 column) or fine-tunes the whole model (the all column), and detection uses multi-scale training with single-scale testing.

The detection score of 54.4 is 2.4 points below the supervised case, which is 56.8 in the ImageNet-label entry. The authors report that the method surpasses the competing unsupervised methods across these tasks, while narrowing the gap with the supervised case.

## Limits of the evidence

The CIFAR-10 analyses use Network-In-Network models and the ImageNet and Places analyses use AlexNet variants, so results across these settings are not directly interchangeable. The comparisons with other unsupervised methods involve different architectures and are described by the authors as indicative only.

The rotation-count study is reported on CIFAR-10 only, and the eight-rotation variant relies on image warping with cropping, which the authors link to possible visual artifacts. Rotations are ambiguous for images that show only round objects, an exception the authors note.

The semi-supervised advantage appears in the tested range only below 1000 examples per category, and it uses a single feature block on CIFAR-10. The Places evaluation uses linear classifiers only, and the explanation for the deeper-head effect is an assumption of the authors.

## Paper info

- **Authors**: Spyros Gidaris, Praveer Singh, Nikos Komodakis
- **Venue**: arXiv · Preprint
- **First published**: 2018-3-21
- **Added**: 2026-11-12
- **Updated**: 2018-3-21
- **Version**: v1
- **arXiv**: 1803.07728
- **Category**: cs.CV · cs.LG
- **Original paper terms**: [arXiv non-exclusive 1.0](https://arxiv.org/licenses/nonexclusive-distrib/1.0/)
- **What we show**: Paper info and commentary

[Original paper ↗](https://arxiv.org/abs/1803.07728v1) · [PDF ↗](https://arxiv.org/pdf/1803.07728v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Quote from the paper

Spyros Gidaris, Praveer Singh, Nikos Komodakis (2018). Unsupervised Representation Learning by Predicting Image Rotations. arXiv:1803.07728v1. https://arxiv.org/abs/1803.07728v1

**BibTeX**

```
@misc{gidaris2018unsupervised,
  title = {{Unsupervised Representation Learning by Predicting Image Rotations}},
  author = {Spyros Gidaris and Praveer Singh and Nikos Komodakis},
  year = {2018},
  eprint = {1803.07728},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1803.07728v1}
}
```

## Other paper commentary

- [HuBERT: Self-Supervised Speech Representation Learning by Masked Prediction of Hidden Units](https://refivu.com/en/papers/4fe3f455-0287-4182-b603-63ebb7e4b5fc-hubert-self-supervised-speech-representation-learning-by.md)
- [Robust Recovery of Subspace Structures by Low-Rank Representation](https://refivu.com/en/papers/14c27646-6e22-4f5b-b820-67e75508bf84-robust-recovery-of-subspace-structures-by-low-rank.md)
- [Improved Baselines with Momentum Contrastive Learning](https://refivu.com/en/papers/b3c4bdf4-000b-4115-9c61-4869e9e62ccc-improved-baselines-with-momentum-contrastive-learning.md)
- [DeepSDF: Learning Continuous Signed Distance Functions for Shape Representation](https://refivu.com/en/papers/b9c76a95-d60f-4b38-98c6-45cfaa2bcd30-deepsdf-learning-continuous-signed-distance-functions-for.md)
- [SimCSE: Simple Contrastive Learning of Sentence Embeddings](https://refivu.com/en/papers/be6ac7d7-6b80-4ef3-905e-9b7eecc4765c-simcse-simple-contrastive-learning-of-sentence-embeddings.md)
- [Supervised Contrastive Learning](https://refivu.com/en/papers/a5818cfe-00fa-4e85-a38e-cdce6aa6cad5-supervised-contrastive-learning.md)
- [A Critical Review of Recurrent Neural Networks for Sequence Learning](https://refivu.com/en/papers/0e786415-0fad-4e73-b947-9aa88bb3aed0-a-critical-review-of-recurrent-neural-networks-for.md)
- [Deeply-Recursive Convolutional Network for Image Super-Resolution](https://refivu.com/en/papers/93708dc4-53eb-4a15-aff5-a1add13038bd-deeply-recursive-convolutional-network-for-image-super.md)
- [Sparse Subspace Clustering: Algorithm, Theory, and Applications](https://refivu.com/en/papers/cf801d50-c51a-4e90-bfdb-a39a2831b982-sparse-subspace-clustering-algorithm-theory-and-applications.md)
- [FixMatch: Simplifying Semi-Supervised Learning with Consistency and Confidence](https://refivu.com/en/papers/27ff414d-b089-4a7d-a1a9-f034b06aaeeb-fixmatch-simplifying-semi-supervised-learning-with.md)
- [BERT4Rec: Sequential Recommendation with Bidirectional Encoder Representations from Transformer](https://refivu.com/en/papers/aebeacc7-489d-4871-a367-3a0b5ad01794-bert4rec-sequential-recommendation-with-bidirectional.md)
- [Deep Learning for Generic Object Detection: A Survey](https://refivu.com/en/papers/6b64d3ea-110c-4de2-b0a0-60ecbb1444e1-deep-learning-for-generic-object-detection-a-survey.md)

## Terms in this paper

- [ImageNet](https://refivu.com/en/terms/5eadad128667-imagenet)
- [Object detection](https://refivu.com/en/terms/113bfdb14049-object-detection)
- [Semantic segmentation](https://refivu.com/en/terms/00dfce7ec404-semantic-segmentation)
- [Top-1 accuracy](https://refivu.com/en/terms/653c0b9eaa58-top-1-accuracy)
- [mAP](https://refivu.com/en/terms/477dad058d88-map)
- [AlexNet](https://refivu.com/en/terms/e5142ede4de4-alexnet)
- [PASCAL VOC](https://refivu.com/en/terms/f661ede6fa9d-pascal-voc)
- [object recognition](https://refivu.com/en/terms/7189055bcf66-object-recognition)
- [ConvNet](https://refivu.com/en/terms/9c07e24759a9-convnet)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/44e2c7d7-5798-499b-99ea-bd1b30e157b3-unsupervised-representation-learning-by-predicting-image)
