Skip to content
Jigsaw self-supervised CNN
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
data clean Oct 27, 2016
jigsaw flake8 Oct 27, 2016
scripts calculate final average distance for perm-gen sciprt Oct 16, 2016
.gitignore refactor to make prediction / representation calculation easier Oct 19, 2016 flake8 Oct 27, 2016
TODO add filter visualisation Oct 24, 2016
setup.cfg flake + readme Oct 15, 2016

Jigsaw CNN

A chainer implementation of self-supervised jigsaw CNNs. The authors have published their caffe implementation


The jigsaw CNN learn a representation by reassembling an image from it's patches.

Random crop

This is achieved by:

  1. randomly cropping a square from the image.
  2. segmenting the crop into 9 patches (with more random crops).
  3. permuting the patches
  4. predict what permutation was applied to the patches.

Random patches

With the aim of learning about structure, colour and texture without labels.


python -m jigsaw.train --gpu 3 "/path/to/train/*.jpg" "/path/to/test/*.jpg"

Note that the path globs must be quoted or the shell we expand them. Images will automatically be rescaled, cropped and turned into patches at runtime. Check --help for more details. Training on the cpu is not supported, you must specify a gpu ID.


This is what the first layer filters look like after 350k batches. They look good but need some more fine tuning.



To identify an n-permutation we only need n-1 elements so I've made the task harder by randomly zero'ing one of the patches (i.e dropout for patches). Permutations are generated in a different manner than specified in the paper but the average hamming distance is almost the same at 0.873 (see scripts/

The architecture we use to generate patch representations is closer to ZFNet than AlexNet

Training could be made faster by precalculating batches.

You can’t perform that action at this time.