TL;DR
FitNets shows how to compress a wide, deep teacher into a student that is deeper but much thinner. The student first learns to predict a middle layer of the teacher, through a small regressor, and then learns the teacher's outputs as in ordinary Knowledge Distillation. On CIFAR-10 a FitNet with about 2.5 million parameters reaches 91.61%, above its teacher's 90.18% with about 9 million.
Builds on: Knowledge Distillation, Convolutional Neural Network, Mean Squared Error · Leads to: Hint-Based Training, the method this paper introduces
Why it mattered
The paper turned the idea of distillation from a way to shrink a model into a way to train a model that could not be trained directly. Its claim is that a thin, deep network is hard to optimise from random weights, but becomes easier to train once a teacher's middle layer gives it a target. The experiments on CIFAR-10 give a compression rate of 10.44 at 91.06% accuracy, against a teacher with about 9 million parameters at 90.18%, in the paper's Table 5.
The idea of matching intermediate features is now a standard tool in distillation work. The paper introduces the hint-based training recipe that many later compression papers build on, and it is the paper that made the case that depth can be traded for width under a fixed computation budget.
The problem
Deep and wide convolutional networks are accurate but slow and large at inference time. Compression methods existed before 2014. Mimicking a large ensemble with a shallow network (Ba and Caruana, 2014) and distillation (Hinton and colleagues) both reduce the size of the model. But they compress into a student of similar depth, or into a shallower and wider one. Neither uses depth, and depth is what gives deep networks their representations: features are reused and become more abstract at higher layers.
Deep networks are also hard to train. They are long chains of non-linear functions, which makes the loss surface highly non-convex. Earlier work eased this with greedy layer-wise pre-training and with supervision at intermediate layers. The FitNets authors ask whether a teacher's intermediate representation can serve as that supervision, so the student can be deeper than the teacher.
How it works
The method has two stages, run on one teacher and one student.
- Pick the hint and guided layers. The hint is a middle layer of the teacher. The guided layer is a middle layer of the student. The paper chooses the middle layer of each network. A layer deeper in the student gives it less freedom, which risks over-regularising it.
- Add a regressor. The teacher's hint is usually wider than the student's guided layer. A convolutional regressor on top of the guided layer maps its output to the hint's spatial size and channel count, so the two can be compared.
- Stage one: hint training. Starting from random weights for the student's layers up to the guided layer, minimise the squared distance between the hint and the regressed guided output. Only these layers and the regressor are updated.
- Stage two: distillation. Starting from the stage-one weights, train the whole student with the knowledge-distillation objective, which combines the teacher's softened outputs with the true labels.
- Output. The final model is the student's own layers. The regressor is discarded.
A tiny instance: the hint is , the guided output is , and the regressor weights are . The regressor output is , the gap is , and the hint loss is . Hold the regressor fixed and take one gradient step with learning rate . The gradient with respect to the guided output is , so the guided output drops from to . The regressor now gives , the gap is , and the loss falls to . The full walkthrough with more numbers is in Hint-Based Training.
flowchart TD A["Trained teacher"] --> B["Hint: middle layer"] C["Random student"] --> D["Guided: middle layer"] D --> E["Convolutional regressor"] E --> F["Hint loss"] B --> F F --> G["Stage one: update student to guided layer"] G --> H["Stage two: distillation of the whole student"] H --> I["Thin, deep FitNet"]
The math
The hint loss, in the paper's notation, is
where is the teacher's network up to the hint layer, is the student's network up to the guided layer, and is the regressor with weights . The paper requires the outputs of and to be comparable, so both use the same non-linearity.
Stage one (Algorithm 1 in the paper) minimises over the student's weights up to the guided layer and over . Stage two minimises the knowledge-distillation objective, the paper's Eq. (2), over all of the student's weights , starting from the stage-one values.
The regressor's size is the reason for the convolutional form. With hint size and channels, and guided size and channels, a fully connected regressor needs
weights. A convolutional regressor with kernel chosen so that needs only
weights, which is much smaller because is far smaller than the spatial product in the first expression.
The paper also argues that hint training is a form of curriculum learning. The teacher's cross-entropy term in the distillation objective weights examples the teacher is confident about more strongly, so easy examples push the student harder early on. This is the link to Curriculum Learning.
Results
CIFAR-10 (Table 1). The FitNet has about 2.5M parameters and reaches 91.61%. The teacher has about 9M and 90.18%. The paper's comparison points are maxout at 90.65%, network in network at 91.2%, and deeply-supervised networks at 91.78%. A deeply-supervised version of the same 19-layer student, trained with labels at intermediate layers, reached 88.2%. The paper reports that the FitNet matches the best methods while having far fewer parameters.
CIFAR-100 (Table 2). The FitNet reaches 64.96% against the teacher's 63.54%, with about 2.5M against about 9M parameters. Deeply-supervised networks reach 65.43%.
SVHN (Table 3). A 13-layer FitNet with about 1.5M parameters has 2.42% misclassification, against 2.38% for the teacher with about 4.9M parameters. The paper says this is comparable accuracy with only 32% of the teacher's capacity. Deeply-supervised networks reach 1.92%.
MNIST (Table 4). A student twice as deep as the teacher, with about 8% of its parameters, is compared under three training methods on about 30K parameters. Standard backpropagation gives 1.9% error, knowledge distillation 0.65%, and hint-based training 0.51%. The teacher, with about 361K parameters, has 0.55%.
Speed and compression (Table 5). On CIFAR-10 the paper measures inference time on a GPU. FitNet 1, with about 250K parameters, is 13.36 times faster than the teacher with 89.01% accuracy. FitNet 2, with about 862K parameters, reaches 91.06% at 4.64 times the speed. FitNet 4, with about 2.5M parameters, reaches 91.61% at 1.52 times the speed and a compression rate of 3.60.
Training depth (Section 4.1, Figure 2). On CIFAR-10 with a budget of about 30M multiplications, standard backpropagation could not train networks with more than 5 layers, knowledge distillation reached 7 layers, and hint training trained 13-layer networks. At 7 layers, hints raise test accuracy from 89.45% to 90.1%.
AFLW (Section 3.4). On a face-patch classifier with a teacher error of 4.21%, FitNet 1, with 15 times fewer multiplications, drops from 4.58% error with distillation to 2.55% with hints.
Limits. The experiments are on small images (CIFAR, SVHN, MNIST, 16 by 16 face patches) with mostly maxout convolutional networks (the face task uses ReLU networks), and the speed numbers are on one GPU. The choice of hint and guided layer is made by hand and is not searched. The paper does not claim the method works for every architecture, only that it works on the ones it tests.
Reading guide
- Introduction. Needs Knowledge Distillation and Convolutional Neural Network. The motivation is depth versus width, and the cited prior work on greedy pre-training and intermediate supervision.
- Section 2.1, review of distillation. Needs Knowledge Distillation, Softmax Temperature, Cross-Entropy Loss and Kullback–Leibler Divergence.
- Section 2.2, hint-based training. Needs Hint-Based Training, Mean Squared Error and Chain Rule. Read the regressor paragraph carefully; it explains the parameter count.
- Section 2.3, stage-wise training. Needs Backpropagation and Stochastic Gradient Descent. Algorithm 1 is the full recipe.
- Section 2.4, curriculum learning. Needs Curriculum Learning.
- Section 3, results. Needs Overfitting for the train versus test comparisons. The tables are the main evidence.
- Section 4.2, trade-off. Needs Model Compression and Gradient Descent for the speed claims.
- Appendix A, architectures. Needs Convolutional Neural Network; the exact layer counts and channel sizes are here.
Check yourself
QuestionIn one sentence, what are the two stages of FitNets training?Show answer
QuestionThe paper's CIFAR-10 FitNet has about 2.5M parameters and reaches 91.61%. The teacher has about 9M and reaches 90.18%. What is the parameter ratio, and what is the accuracy gap in points?Show answer
QuestionWhy does the paper use a convolutional regressor instead of a fully connected one?Show answer
QuestionA student is deeper and thinner than its teacher. Standard backpropagation fails to train it past 5 layers in the paper's budget. Which change does the paper report makes a 13-layer network trainable?Show answer
QuestionOn SVHN, the 13-layer FitNet is compared with a teacher. Why is a 2.42% versus 2.38% error result still a success for the method?Show answer
Sources
- Romero et al., "FitNets: Hints for Thin Deep Nets" (2014), arXiv: https://arxiv.org/abs/1412.6550
- Hinton, Vinyals and Dean, "Distilling the Knowledge in a Neural Network" (2015), arXiv: https://arxiv.org/abs/1503.02531