Paper · 2022-05-21 · cs.CV, cs.AI, cs.LG
Knowledge Distillation from A Stronger Teacher
DIST distills from a stronger teacher by matching only the Pearson correlation of softmax outputs: across classes per instance and across instances per class, instead of the exact KL match. Author-reported: ResNet-18 student from a ResNet-34 teacher reaches 72.07% top-1 on ImageNet (KD 70.66%); gains also on COCO and Cityscapes.
Knowledge distillationObject detectionSemantic segmentationdistillationclassificationobject-detectionsemantic-segmentation
arXivPDFCodeMarkdown12 min read
AI-compiled by claude-haiku-5-5 on 2026-10-18, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.
In plain words
Knowledge distillation trains a small "student" model to copy a large "teacher" model. The usual way is to make the student's output probabilities match the teacher's exactly. That goes wrong when the teacher is much stronger: the student cannot follow the teacher's exact numbers, and forcing it to try can hurt training.
The paper's idea is to care less about exact values and more about the pattern. If the teacher thinks class A is more likely than class B, and the student agrees on that ordering with a similar spread of confidence, the student has learned what matters. The method measures this with a correlation score, and it looks at the pattern in two directions: across the classes for each example, and across the examples for each class. Training then uses the ordinary label loss plus these two correlation terms.
The payoff, as the authors report it, is better students from strong teachers, with training cost close to standard distillation, on image classification and on two dense prediction tasks, object detection and semantic segmentation.
TL;DR
- Replaces the exact KL match of standard knowledge distillation with Pearson correlation between student and teacher softmax outputs §3.1.
- Two terms: inter-class (per instance, across classes) and intra-class (per class, across instances) §3.1 §3.2.
- Total loss: classification cross-entropy plus the two weighted correlation losses eq. 10.
- Author-reported gains are largest when the teacher is stronger or trained with stronger strategies §4.2 tab. 3 tab. 4.
- Needs only the logits of teacher and student; the appendix gives a short PyTorch implementation app. A.1.
Problem
Vanilla knowledge distillation minimises the KL divergence between the teacher's and student's softmax outputs §2 eq. 1. The paper argues that this exact match is the wrong target when the teacher is strong. Its observations:
- With a stronger teacher, the student's accuracy under vanilla KD can fall below training without KD. The paper points to its Figure 1 for this §1 fig. 1.
- The gap between teacher and student predictions grows when the teacher is trained with a stronger strategy, such as label smoothing, mixup or auto-augmentation. The paper shows this as the KL discrepancy of ResNet-18 and ResNet-50 trained with two strategies §2.1 fig. 2.
- A ResNet-18 student's outputs change little between the two strategies, while the ResNet-50 teacher's do. The authors read this as a capacity limit on the student §2.1.
The paper's claim is that the exact-match objective is "way too overambitious" for these cases, and that preserving the relations between predictions is enough §2.1 §3.
Method
Overview. The student is trained with the usual classification loss plus two relation losses that compare its softmax outputs with the teacher's (which are fixed; the paper calls the teacher pre-trained §2). No feature maps are matched, and no extra layers are added §4.2 app. A.2.
- Turn each model's logits into per-instance class probabilities with a softmax §2 eq. 2. The paper's notation includes a temperature τ in this step; see Pitfalls for what the code does.
- Inter-class relation: for each instance, measure the Pearson correlation between the student's and the teacher's C class probabilities, convert it to a distance, and average over the batch of B instances §3.1 eq. 6 eq. 7 eq. 8.
- Intra-class relation: for each class, measure the Pearson correlation between the student's and the teacher's B instance probabilities for that class, and average over the C classes §3.2 eq. 9.
- Total loss: α times the classification loss, plus β times the inter-class loss, plus γ times the intra-class loss eq. 10. The weights are given in the Hyperparameters table.
Why Pearson: the paper requires the match to be invariant to positive scale and shift of each prediction vector §3.1 eq. 4 eq. 5. Pearson correlation has this property, and cosine similarity has only the scale part. The paper's ablation favours Pearson over cosine tab. 10.
# DIST relation loss [§3.1] [§3.2] [eq. 8] [eq. 9] [app. A.1]
# Input: student_logits, teacher_logits: (B, C)
# Output: scalar relation loss
def dist_loss(student_logits, teacher_logits, beta, gamma):
# Per-instance class probabilities [§2] [eq. 2]
student_probs = softmax(student_logits, dim=1) # (B, C)
teacher_probs = softmax(teacher_logits, dim=1) # (B, C)
# Inter-class: correlate the C class scores of each instance [eq. 8]
inter_loss = 1 - mean(pearson(student_probs, teacher_probs))
# Intra-class: correlate the B instance scores of each class [eq. 9]
intra_loss = 1 - mean(
pearson(student_probs.transpose(0, 1),
teacher_probs.transpose(0, 1)))
# Weighted sum of the two relation terms [§3.2] [eq. 10]
return beta * inter_loss + gamma * intra_loss
# Pearson correlation of each matching row pair [§3.1] [eq. 6] [eq. 7]
def pearson(a, b, eps=1e-8):
# Centre each row [code: segmentation/losses/dist_kd.py#L8-L9]
a_centred = a - mean(a, dim=1, keepdim=True) # (N, K)
b_centred = b - mean(b, dim=1, keepdim=True) # (N, K)
# Cosine similarity of the centred rows, with eps against zero norms
# [code: segmentation/losses/dist_kd.py#L4-L5]
dot = sum(a_centred * b_centred, dim=1)
norms = norm(a_centred, dim=1) * norm(b_centred, dim=1)
return dot / (norms + eps)The total training loss is written in the paper as α·L_cls + β·L_inter + γ·L_intra eq. 10. In the paper, L_cls is the cross-entropy between the student's predictions and the ground-truth labels §2.
Hyperparameters
Loss weights (paper, §4.1):
| Setting | α (cls) | β (inter) | γ (intra) | Where | Notes |
|---|---|---|---|---|---|
| CIFAR-100 and ImageNet, DIST | 1 | 2 | 2 | §4.1 | Stated for Eq. 10 |
| Object detection and segmentation, DIST | 1 | 1 | 1 | §4.1 | Stated: all three equal 1 |
| Vanilla KD baseline | 0.9 | 1 | not applicable | §4.1 eq. 3 | Stated α=0.9, β=1 |
KD temperature: the paper says the default is τ=4 and that ImageNet uses τ=1 instead of τ=4 §4.1. Table 6's caption gives τ=1 for KD on detection tab. 6. See Pitfalls.
DIST temperature: not stated in the paper. The appendix code applies the softmax to raw logits with no temperature app. A.1 fig. 4.
Training strategies, image classification tab. 1:
| Strategy | Dataset | Epochs | Total batch | Initial LR | Optimizer | Weight decay | Label smoothing | EMA | LR schedule | Augmentation |
|---|---|---|---|---|---|---|---|---|---|---|
| A1 | CIFAR-100 | 240 | 64 | 0.05 | SGD | 5e-4 | - | - | ×0.1 at epochs 150, 180, 210 | crop + flip |
| B1 | ImageNet | 100 | 256 | 0.1 | SGD | 1e-4 | - | - | ×0.1 every 30 epochs | crop + flip |
| B2 | ImageNet | 450 | 768 | 0.048 | RMSProp | 1e-5 | 0.1 | 0.9999 | ×0.97 every 2.4 epochs | B1 + RandAugment + random erasing |
| B3 | ImageNet | 300 | 1024 | 5e-4 | AdamW | 5e-2 | 0.1 | - | cosine | B2 + color jitter + mixup + CutMix |
Source: tab. 1. The paper's abbreviations are as in its caption. Strategy A1 uses the same pre-trained models as CRD §4.1.
Teachers and students §4.1 §4.2 tab. 2 tab. 4:
- ImageNet baselines: teachers are torchvision ResNet-34 and ResNet-50 tab. 2.
- Stronger-teacher sweep: ResNet-18 and ResNet-34 students with ResNet-34, 50, 101 and 152 teachers, all under B1 tab. 3.
- Stronger strategies: ResNet-50 teacher at 80.1% trained by the cited timm work, Swin-L teacher at 86.3% pre-trained on ImageNet-22K tab. 4.
- Detection: Cascade Mask R-CNN X101 teaches Faster R-CNN R50; RetinaNet X101 teaches RetinaNet R50 §4.3.
- Segmentation: DeepLabV3-R101 (78.07 mIoU) teaches DeepLabV3-R18 and PSPNet-R18 on Cityscapes §4.4 tab. 7.
Detection and segmentation training schedules: the paper says it uses "standard" training strategies following prior work §4.3 and gives no numbers. Not stated in paper. The segmentation code defaults are in Paper vs code.
Results
Author-reported. All numbers are single runs except the CIFAR-100 rows of tab. 5, which carry standard deviations (the number of runs is not stated).
ImageNet, baseline strategy B1 tab. 2 (Top-1 / Top-5 %):
| Student (teacher) | Metric | Teacher | Student | KD | OFD | CRD | SRRL | Review | DIST |
|---|---|---|---|---|---|---|---|---|---|
| ResNet-18 (ResNet-34) | Top-1 | 73.31 | 69.76 | 70.66 | 71.08 | 71.17 | 71.73 | 71.61 | 72.07 |
| ResNet-18 (ResNet-34) | Top-5 | 91.42 | 89.08 | 89.88 | 90.07 | 90.13 | 90.60 | 90.51 | 90.42 |
| MobileNet (ResNet-50) | Top-1 | 76.16 | 70.13 | 70.68 | 71.25 | 71.37 | 72.49 | 72.56 | 73.24 |
| MobileNet (ResNet-50) | Top-5 | 92.86 | 89.49 | 90.30 | 90.34 | 90.41 | 90.92 | 91.00 | 91.12 |
ImageNet, stronger teachers tab. 3 (ResNet-18 student, baseline 69.76 %, top-1):
| Teacher | Teacher acc. | KD | DIST | Gain |
|---|---|---|---|---|
| ResNet-34 | 73.31 | 71.21 | 72.07 | +0.86 |
| ResNet-50 | 76.13 | 71.35 | 72.12 | +0.77 |
| ResNet-101 | 77.37 | 71.09 | 72.08 | +0.99 |
| ResNet-152 | 78.31 | 71.12 | 72.24 | +1.12 |
ResNet-34 student (baseline 73.31 %, top-1):
| Teacher | Teacher acc. | KD | DIST | Gain |
|---|---|---|---|---|
| ResNet-50 | 76.13 | 74.73 | 75.06 | +0.33 |
| ResNet-101 | 77.37 | 74.89 | 75.36 | +0.47 |
| ResNet-152 | 78.31 | 74.87 | 75.42 | +0.55 |
ImageNet, stronger training strategies tab. 4 (top-1 %; the Swin-T student uses B3, the others B2):
| Teacher (acc.) | Student | Student acc. | KD | RKD | SRRL | DIST |
|---|---|---|---|---|---|---|
| ResNet-50 (80.1) | ResNet-18 | 73.4 | 72.6 | 72.9 | 71.2 | 74.5 |
| ResNet-50 (80.1) | ResNet-34 | 76.8 | 77.2 | 76.6 | 76.7 | 77.8 |
| ResNet-50 (80.1) | MobileNetV2 | 73.6 | 71.7 | 73.1 | 69.2 | 74.4 |
| ResNet-50 (80.1) | EfficientNet-B0 | 78.0 | 77.4 | 77.5 | 77.3 | 78.6 |
| Swin-L (86.3) | ResNet-50 | 78.5 | 80.0 | 78.9 | 78.6 | 80.2 |
| Swin-L (86.3) | Swin-T | 81.3 | 81.5 | 81.2 | 81.5 | 82.3 |
CIFAR-100 tab. 5 (top-1 %, mean ± std). Columns are teacher → student pairs in the order shown in the paper's header:
| Method | WRN-40-2 → WRN-40-1 | ResNet-56 → ResNet-20 | ResNet-32x4 → ResNet-8x4 | ResNet-50 → MobileNetV2 | ResNet-32x4 → ShuffleNetV1 | ResNet-32x4 → ShuffleNetV2 |
|---|---|---|---|---|---|---|
| Teacher | 75.61 | 72.34 | 79.42 | 79.34 | 79.42 | 79.42 |
| Student | 71.98 | 69.06 | 72.50 | 64.6 | 70.5 | 71.82 |
| FitNet | 72.24±0.24 | 69.21±0.36 | 73.50±0.28 | 63.16±0.47 | 73.59±0.15 | 73.54±0.22 |
| VID | 73.30±0.13 | 70.38±0.14 | 73.09±0.21 | 67.57±0.28 | 73.38±0.09 | 73.40±0.17 |
| RKD | 72.22±0.20 | 69.61±0.06 | 71.90±0.11 | 64.43±0.42 | 72.28±0.39 | 73.21±0.28 |
| PKT | 73.45±0.19 | 70.34±0.04 | 73.64±0.18 | 66.52±0.33 | 74.10±0.25 | 74.69±0.34 |
| CRD | 74.14±0.22 | 71.16±0.17 | 75.51±0.18 | 69.11±0.28 | 75.11±0.32 | 75.65±0.10 |
| KD | 73.54±0.20 | 70.66±0.24 | 73.33±0.25 | 67.35±0.32 | 74.07±0.19 | 74.45±0.27 |
| DIST | 74.73±0.24 | 71.75±0.30 | 76.31±0.19 | 68.66±0.23 | 76.34±0.18 | 77.35±0.25 |
Setup: strategy A1, teacher and student from the CRD-style pre-trained models §4.1 tab. 1. The paper's checklist says standard deviations are reported for CIFAR-100 only [checklist].
COCO object detection tab. 6 (box AP, COCO validation set):
| Method | AP | AP50 | AP75 | APS | APM | APL |
|---|---|---|---|---|---|---|
| Two-stage. Teacher: Cascade Mask R-CNN X101 | 45.6 | 64.1 | 49.7 | 26.2 | 49.6 | 60.0 |
| Student: Faster R-CNN R50 | 38.4 | 59.0 | 42.0 | 21.5 | 42.1 | 50.3 |
| KD (τ=1) | 39.7 | 61.2 | 43.0 | 23.2 | 43.3 | 51.7 |
| FKD | 41.5 | 62.2 | 45.1 | 23.5 | 45.0 | 55.3 |
| CWD | 41.7 | 62.0 | 45.5 | 23.3 | 45.5 | 55.5 |
| DIST | 40.4 | 61.7 | 43.8 | 23.9 | 44.6 | 52.6 |
| DIST + mimic | 41.8 | 62.4 | 45.6 | 23.4 | 46.1 | 55.0 |
| One-stage. Teacher: RetinaNet X101 | 41.0 | 60.9 | 44.0 | 23.9 | 45.2 | 54.0 |
| Student: RetinaNet R50 | 37.4 | 56.7 | 39.6 | 20.0 | 40.7 | 49.7 |
| KD (τ=1) | 37.2 | 56.5 | 39.3 | 20.4 | 40.4 | 49.5 |
| FKD | 39.6 | 58.8 | 42.1 | 22.7 | 43.3 | 52.5 |
| CWD | 40.8 | 60.4 | 43.4 | 22.7 | 44.5 | 55.3 |
| DIST | 39.8 | 59.5 | 42.5 | 22.0 | 43.7 | 53.0 |
| DIST + mimic | 40.1 | 59.4 | 43.0 | 23.2 | 44.0 | 53.6 |
The DIST + mimic row adds a mean-squared error between the FPN features of teacher and student §4.3. The paper says this term is a feature loss, so the detection results do not isolate DIST.
Cityscapes semantic segmentation tab. 7 (val mIoU %, ImageNet pre-trained; teacher DeepLabV3-R101 at 78.07):
| Method | DeepLabV3-R18 | PSPNet-R18 |
|---|---|---|
| Student, no distillation | 74.21 | 72.55 |
| SKD | 75.42 | 73.29 |
| IFVD | 75.59 | 73.71 |
| CWD | 75.55 | 74.36 |
| CIRKD | 76.38 | 74.73 |
| DIST | 77.10 | 76.31 |
Ablations (ImageNet, ResNet-18 student, ResNet-34 teacher; §4.5 app. A.3):
| Loss | Inter | Intra | Top-1 % |
|---|---|---|---|
| KD | - | - | 71.21 |
| DIST (KL div.) | no | yes | 70.61 |
| DIST (KL div.) | yes | yes | 71.62 |
| DIST (Pearson) | yes | no | 71.63 |
| DIST (Pearson) | no | yes | 71.55 |
| DIST (Pearson) | yes | yes | 72.07 |
Source: tab. 8. Training with the KD loss alone, without the classification loss tab. 9:
| Method | With cls. loss | Without cls. loss |
|---|---|---|
| KD | 71.21 | 68.12 |
| DIST | 72.07 | 70.65 |
The student's standalone accuracy is 69.76 tab. 9. Cosine similarity versus Pearson, with and without label smoothing tab. 10:
| Method | w/o LS | w/ LS |
|---|---|---|
| Teacher | 73.31 | 73.78 |
| KD (τ=4) | 71.21 | 70.71 |
| KD (τ=1) | 71.49 | 71.37 |
| DIST (cosine) | 71.79 | 71.63 |
| DIST (Pearson) | 72.07 | 72.18 |
Training speed, ResNet-18 student with ResNet-34 teacher, 8 V100 GPUs, batches per second tab. 11: KD 14.28, RKD 11.11, SRRL 12.98, CRD 8.33, DIST 14.19.
Paper vs code
The official repository is hunto/DIST_KD (Apache-2.0), linked from the
abstract. It contains the segmentation code. The classification code is in
a separate repository that the README links as a submodule
(image_classification_sota); it was not cloned here. The paper's
detection code is in MasKD/mmrazor; it was not cloned either. The clone used for this card is at commit
2418f18.
- Loss function. The paper's appendix listing app. A.1 fig. 4 and
segmentation/losses/dist_kd.pyimplement the same inter-class and intra-class functions dist_kd.py. The code adds a 4-D path that reshapes(B, C, H, W)to per-pixel rows dist_kd.py. The paper does not describe that path. - Default weights. The segmentation class defaults to β=1, γ=1 dist_kd.py. The paper gives these for detection and segmentation §4.1.
- Temperature. The segmentation code applies the softmax to raw logits
dist_kd.py. The
--kd-temperatureargument is parsed but never used train_kd.py. The external classification code, fetched through WebFetch fromhunto/image_classification_sota(lib/models/losses/dist_kd.py) and not verified against a clone, has a temperature τ (default 1.0) and scales both terms by τ² [external: image_classification_sota lib/models/losses/dist_kd.py]. The paper does not say which form its ImageNet and CIFAR results use. - Auxiliary head (segmentation). For ResNet student backbones the code
sets
aux = Truetrain_kd.py. The student loss then adds 0.4 times the DIST loss on the auxiliary outputs train_kd.py. The paper does not mention an auxiliary head. - Segmentation schedule. The scripts pass only teacher, student,
backbone, data and paths pspnet_res18.sh.
Their values come from the defaults in
train_kd.py: 40 000 iterations train_kd.py, learning rate 0.02 with polynomial decay (power 0.9, floor 1e-4) train_kd.py train_kd.py, momentum 0.9 train_kd.py, weight decay 5e-4 train_kd.py, total batch 16 split across GPUs train_kd.py, crop 512×1024 train_kd.py. This is inferred from code; the paper does not state these values. - CIFAR-100 WRN-40-2 → WRN-40-1. Table 5 gives DIST 74.73±0.24 tab. 5. The repository README gives 74.43±0.24 for the same pair README.md. The other six CIFAR pairs match.
Pitfalls
- The KD temperature is contradictory. §4.1 says the default is τ=4, then says ImageNet uses τ=1 instead §4.1. The repository README labels the ImageNet KD baseline as "KD (T=4)" README.md. The detection table labels KD as τ=1 tab. 6. Check which temperature a reproduction uses for each baseline before comparing numbers.
- The DIST temperature is not stated. Equations 6 to 10 do not include τ. The appendix code and the segmentation code use raw logits. The external classification code includes τ and τ² (see Paper vs code). An implementation that follows the paper's notation literally is not the same as either code.
- The introduction overstates the Swin-T gain. It says 82.3% on Swin-T is "improving KD by 1%" §1. Table 4 gives KD 81.5 and DIST 82.3, a gain of 0.8 points tab. 4. The "1.0%" in §4.2 is measured against the student without distillation (81.3) §4.2.
- Teacher accuracy for ResNet-50. Table 2 gives 76.16 tab. 2. Table 3 and §2.1 give 76.13 tab. 3 §2.1.
- The detection claim applies to two-stage only. The paper says DIST plus mimic outperforms prior detection KD methods §4.3. In the one-stage table, DIST plus mimic reaches 40.1 AP against CWD's 40.8 tab. 6. In the two-stage table it reaches 41.8 against CWD's 41.7 tab. 6.
- Loss weights are not ablated. DIST uses β+γ=4 on ImageNet and CIFAR, while the KD baseline has β=1 §4.1. The ablations vary which relation terms are on, not their weights §4.5 app. A.3. A gain may partly come from the larger total weight on the distillation term. The paper does not separate the two effects.
- Intra-class term depends on batch composition. The intra-class relation correlates the instance scores of each class across the batch §3.2 eq. 9. The segmentation code applies it across all pixels in the batch dist_kd.py. The paper does not analyse small batches or how the batch is built.
- Degenerate rows. The eps guard in the Pearson computation is the only protection against zero-variance rows dist_kd.py. If a row has equal logits, its centred vector is zero, the correlation becomes 0 and that row contributes a loss of 1. The paper does not discuss this case. This is inferred from the code.
- Variance is reported for CIFAR-100 only. ImageNet, detection and segmentation numbers are single values tab. 2 tab. 4 tab. 6 tab. 7. The checklist says error bars are reported for CIFAR-100 only.
- Limitation. The paper says DIST is less effective on binary classification, because the inter-class relation then has only two terms app. A.6.
- Cost. The paper reports training speed close to vanilla KD on one setup tab. 11. It does not report memory use.
Lineage
- Builds on: standard knowledge distillation, which matches softmax outputs with a KL divergence §2 eq. 1 eq. 3.
- Related relation-based methods named in the appendix: CCKD and RKD (instance relations) and a locality-preserving loss app. A.2. Not carded.
- Compared against in the tables: FitNet, VID, RKD, PKT, CRD, OFD, SRRL, Review, FKD, CWD, IFVD, SKD and CIRKD tab. 2 tab. 5 tab. 6 tab. 7. Not carded.
- Superseded by: not known from this wiki.
Source and license
Adapted from “Knowledge Distillation from A Stronger Teacher” by Tao Huang, Shan You, Fei Wang, Chen Qian, Chang Xu (arXiv:2205.10536), used under CC BY 4.0. Changes: condensed and restructured for implementation, with tables, equations and algorithms taken from the paper and its code, each cited to its source. Not affiliated with or endorsed by the authors. Code citations refer to https://github.com/hunto/DIST_KD at commit 2418f18b1fed (Apache-2.0). Any quoted code is shown under that license.