Suppressing Uncertainties for Large-Scale Facial Expression Recognition
- Publication
- CVPR 2020Conference
- First submitted to arXiv
- arXiv:2002.10392
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{faceanalysisscn2020,
title = {{Suppressing Uncertainties for Large-Scale Facial Expression Recognition}},
author = {Kai Wang and Xiaojiang Peng and Jianfei Yang and Shijian Lu and Yu Qiao},
year = {2020},
eprint = {2002.10392},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2002.10392}
}
A man with wide eyes and an open mouth. RAF-DB labels this face "sadness."
The SCN paper uses this image as a demonstration. The authors deliberately changed its label to "neutral," and partway through training, the network changed the label on its own, to "surprise." Of the three labels, "neutral" is the wrong one planted by hand; as for which of the remaining two, sadness or surprise, is right, ten people looking at it might give several answers.
Expression datasets are full of faces like this. Expressions are ambiguous in themselves, photos may be blurry or occluded, and every annotator judges in their own way. Scrape hundreds of thousands of faces from the web to label, and inconsistent or even wrong labels are close to inevitable. Deep networks, meanwhile, have enough capacity to memorize every wrong one.
SCN (Self-Cure Network) wants the network to deal with this itself. The authors are Kai Wang and Xiaojiang Peng (co-first authors) and Yu Qiao of the Shenzhen Institutes of Advanced Technology, Chinese Academy of Sciences, along with Jianfei Yang and Shijian Lu of Nanyang Technological University in Singapore; the same group had built RAN the year before, which used facial-region attention to handle occlusion and pose. SCN has the network give every training image a "trustworthiness" score, uses it to suppress the influence of suspicious samples, and then relabels the samples the network is confident about within the most suspicious group. All three happen only during training; at inference it's just an ordinary ResNet-18.
Defining the Problem
The expression recognition exam
Facial expression recognition (FER) takes a cropped face and outputs an expression class. The most common setup has seven classes, the six basic expressions (surprise, fear, disgust, happiness, sadness, anger) plus neutral; some datasets add contempt, for eight.
This paper uses three datasets.
- RAF-DB: about thirty thousand faces collected from the web, each voted on by about 40 trained annotators. Only the subset of basic expressions plus neutral is used, 12,271 training and 3,068 test images, reporting overall accuracy, the fraction of the test set answered correctly.
- FERPlus: FER2013's 48×48 grayscale faces, revoted by 10 crowdsourced annotators, eight classes. 28,709 training images and 3,589 each for validation and test, reporting overall accuracy. SCN takes the top-voted class as the label.
- AffectNet: over a million images gathered with search engines, of which about 450,000 were labeled by 12 trained annotators, the vast majority by only one person. Eight classes. The official validation set has 500 images per class and everyone uses it as the test set; since every class has the same count, "mean per-class accuracy" and overall accuracy are the same number.
The three datasets were annotated in different ways, so their labels differ in how far they can be trusted, which comes back when we read the experiments.
Where uncertainty comes from
The authors split the sources of uncertainty into four kinds. The expression itself is ambiguous, somewhere between surprise and fear, say; the image quality is poor, low-resolution, blurry, or blocked by a hand or glasses; the annotations are inconsistent, with different people giving the same face different answers; and the label is simply wrong.
These samples hurt training in three ways. The network overfits to these possibly wrong labels; memorizing them distorts the features it learns; and when the error rate is high, training may not even converge in the early stage.
Noisy labels already have plenty of approaches in general image classification. Some need a small set of known-clean data to evaluate the other labels; some estimate a transition matrix for "which class the true class gets flipped to"; MentorNet trains a separate teacher network to decide which samples the student should look at. On the expression side, IPA2LT deals with annotation inconsistency across datasets.
The most direct idea is to give each sample a weight , multiply it into the sample's loss, and let the network learn the weights. That fails, because the network only has to push every to 0 to make the loss 0. Methods like MentorNet get around this with alternating optimization, training the network with the weights fixed, then updating the weights with the network fixed.
SCN wants end-to-end training, no clean subset, and no extra computation at inference. How do you learn the weights so they don't all collapse to 0?
Solving the Problem
The big picture

A batch of faces is first detected and aligned by MTCNN, resized to and fed into ResNet-18, which yields one 512-dimensional feature per face from the last pooling layer. From there, three paths.
- Importance weighting: one fully connected layer plus a sigmoid computes a weight between 0 and 1 for each face, which multiplies the classifier's logits.
- Rank regularization: sort the batch's weights from high to low, split them into a high group and a low group, and require the two groups' means to differ by at least a margin.
- Relabeling: within the low group, if the network's most confident class beats the original label's probability by a clear margin, swap the label.
Weights on the logits
The feature of face is . The importance weight is equation (1) of the paper:
is a fully connected layer from 512 dimensions to 1, and is the sigmoid. The paper calls it self-attention, but really each image computes a scalar from its own features; the samples in a batch don't exchange any information.
SCN multiplies this onto the logits. With the classifier weights of class , the Logit-Weighted Cross-Entropy (WCE) of equation (2) in the paper is
is the original label, the number of classes and the batch size. The formulation is borrowed from a paper on noise in face recognition (Hu et al.).
Why doesn't this collapse to 0? Break one image's loss apart. Write for class 's original logit and for the softmax probability after multiplying by , dropping the subscript :
As approaches 0, every class's probability becomes and the loss becomes ; with seven classes that's . Pushing it to 0 leaves the loss stuck at 1.95, not at 0.
Now differentiate with respect to :
The first term is the average of the logits under the current predicted distribution, and the second is the logit of the labeled class. If the labeled class's logit is above this average, the derivative is negative and a larger lowers the loss; if it's below, the derivative is positive and the network will want to shrink . So what learns is, roughly, "whether the network currently agrees with this label."
Work it through for one face. Suppose the classifier gives some face seven logits (surprise 0.2, fear −0.5, disgust 0.1, happiness −1.0, sadness 2.0, anger 0.3, neutral 1.0), so the network thinks it looks most like sadness, then neutral. Keep these logits and try three labels:

- Labeled sadness: it agrees with the network's judgment, and the loss falls from 1.95 all the way to 0.69 at ; the larger , the better.
- Labeled neutral: the network's second choice, and the loss falls and then rises, with its minimum at .
- Labeled happiness: the network disagrees most, and the loss rises from 1.95 all the way to 3.69; the network is best off pushing to 0.
also decides how hard this image pulls on the network. The gradient of WCE with respect to the logits is , with an extra factor of in front. For the neutral label, the gradient's length is 0.97 at and only 0.27 at . Low-weight samples naturally have less influence on the backbone and the classifier.
The paper states that WCE "has a positive correlation with" . By the derivation above, the loss rises with only when the label's logit is below the weighted average; when the label is the network's top pick, the two move in opposite directions all the way.
is still there at inference, but it's positive, and multiplying every class's logit by it doesn't change which class is largest, so the predictions are the same as without this branch; the paper also says SCN adds no inference cost.
There's a loop here. The size of depends on whether the classifier agrees with the label, and the classifier is trained on these very labels. Early in training the classifier is still weak, so neither its agreement nor its disagreement means much; and once the classifier memorizes a wrong label, follows along and gives it a high score too.
Rank regularization
With WCE alone, the values can land anywhere between 0 and 1, or all bunch together. The authors add a rule that forces them apart.
Sort a batch's weights from high to low; the top are the high group and the rest the low group, with means
The rank regularization loss (RR-Loss) is equation (3) of the paper:
If the two means differ by less than , the shortfall is the penalty. The total loss is , with defaults , , .
Run it on the weights of the six faces in the flowchart: 0.93, 0.87, 0.68, 0.64, 0.56, 0.46. With , the official code takes images as the high group:
The gap is 0.27, above 0.15, so and this term does nothing at all for training.
Now take a batch whose weights are bunched together, 0.80, 0.78, 0.76, 0.75, 0.72, 0.70. and , a gap of 0.0625, so the loss is . Here the gradient pushes each weight in the high group up with a force of and pulls each in the low group down with a force of , prying the two groups apart. The paper's batch is 1,024, so the high group has about 716 images and the low group about 308.
This constraint looks only at the two groups' means and backs off as soon as the gap is big enough. In the official repo's issue #3 (March 2020), someone reported that RR-Loss is almost always 0, and the author replied "because of the constraint is so weak," adding that stronger ones would be explored later.
Relabeling
The low group holds two kinds of samples. One is genuinely ambiguous, where any label could be defended; the other is mislabeled, where the network is actually quite sure it's some other class. Relabeling handles the second kind, with equation (5) of the paper:
is the probability of the class with the highest softmax probability, and is that class; is the probability of the original label's class, and is the original label. defaults to 0.2, starting from epoch 10. Changed labels are written back to the dataset and used for training from the next epoch on; if the change is right, the image's recovers and it leaves the low group. The network cures its own illness, which is where the name "Self-Cure" comes from.
Back to the logits from before, with the label neutral. The probabilities here are computed by weighting with and then applying softmax, which is how both the paper's flowchart and the official code do it.
- : sadness 0.501, neutral 0.184, a gap of 0.316, above 0.2, so the label changes to sadness.
- : sadness 0.300, neutral 0.182, a gap of 0.118, no change.
- : sadness 0.229, neutral 0.170, a gap of 0.059, no change.
The smaller , the flatter the softmax and the more the gap between the two probabilities gets squeezed. Following this equation (this note's derivation), the samples pushed lowest are in fact the hardest to get past ; the ones that get relabeled are mostly those that land in the low group without their having been pushed too low.

The face from the opening is in the first column of this figure. The first row is the result of training with RAF-DB's original labels, and all eight faces are weighted above 0.77. The second row randomly swaps labels for wrong ones (RAF-DB with 10% noise) without relabeling, and the weights drop to 0.31 to 0.67. The third row turns relabeling on, the labels get changed, and the weights return to above 0.68.
Five of the eight were changed back to their original labels. Columns one, four and six were changed to a different class, which the paper admits, saying the new labels are "also reasonable in visualization." The first column was originally labeled sadness and became surprise; the fourth column's fear became surprise; the sixth, a child's surprise, became sadness. Wide-eyed, open-mouthed faces are hard to sort between surprise and fear to begin with, and in the first column it's hard to say whether sadness or surprise is right.
The official code is written as follows, excerpted from src/train.py, with variable names as in the original file, a few lines merged, and comments added by this note:
attention_weights, outputs = res18(imgs) # alpha in (0, 1); outputs = alpha * fc(x)
# Rank Regularization
tops = int(batch_sz * beta) # beta = 0.7
_, top_idx = torch.topk(attention_weights.squeeze(), tops)
_, down_idx = torch.topk(attention_weights.squeeze(), batch_sz - tops, largest=False)
high_mean = torch.mean(attention_weights[top_idx])
low_mean = torch.mean(attention_weights[down_idx])
diff = low_mean - high_mean + margin_1 # delta_1 - (alpha_H - alpha_L)
RR_loss = diff if diff > 0 else 0.0
loss = criterion(outputs, targets) + RR_loss # CE on the alpha-weighted logits
# Relabel samples (from epoch relabel_epoch = 10)
sm = torch.softmax(outputs, dim=1)
Pmax, predicted_labels = torch.max(sm, 1)
Pgt = torch.gather(sm, 1, targets.view(-1, 1)).squeeze()
update_idx = (Pmax - Pgt > margin_2).nonzero().squeeze() # every sample in the batch
label_idx = indexes[update_idx]
train_loader.dataset.label[label_idx.cpu().numpy()] = predicted_labels[update_idx].cpu().numpy()
criterion is ordinary cross-entropy, fed logits already multiplied by , and the sum of the two terms is twice the paper's loss at , so the ratio is the same. The relabeling part checks every image in the whole batch, not only those in down_idx. In December 2020 someone pointed this out in issue #33, and the author replied in a comment with a one-line fix that takes the intersection with np.intersect1d(down_idx, update_idx), but never committed it to the repo. In March 2024 it was asked again in issue #83, and the author replied "Indeed... it's been a while," asking whether the asker had tried both versions. The asker's experience was that relabeling only the low group was actually worse, and relabeling everything was better but unstable.
Training setup
- MTCNN detection and alignment, resized to .
- ResNet-18, pretrained on the MS-Celeb-1M face recognition data, with features from the last pooling layer.
- Eight 2080 Ti GPUs, batch 1,024, learning rate 0.1, divided by 10 at epochs 15 and 30, 40 epochs in total. The paper doesn't name the optimizer.
- , , , , with relabeling starting at epoch 10.
There's also WebEmotion, collected by the authors themselves. They searched YouTube with 40 emotion-related keywords paired with 45 country names and 6 age words (baby, lady, elderly and so on), took the first 20 videos under 4 minutes for each combination, 41,339 videos in all, then cut them into 200,149 clips, each with at least 5 seconds of a face MTCNN can detect. The classes are the same eight as FERPlus, and the labels are simply the classes the search keywords map to; "happy," "funny" and "kawaii," for example, all count as happiness. Labels like these are extremely noisy, and the authors use the data only for pretraining.
Discussion
Artificial noise
Of the four kinds of uncertainty, only "mislabeled" can be quantified, so the authors manufactured wrong labels on the three datasets. They randomly picked 10%, 20% and 30% of each class's training images, swapped their labels for another class, and compared two settings: training from scratch, and fine-tuning from weights pretrained on MS-Celeb-1M.
Trained from scratch, the baseline is quickly dragged down by the noise. On RAF-DB with 30% noise the baseline falls to 46.81% while SCN gets 60.61%, a gap of 13.80 percentage points; under the same conditions, the curriculum-learning CurriculumNet gets 57.52% and MetaCleaner 58.89%. The gaps on AffectNet and FERPlus are much smaller, only 1.07 and 1.91 points respectively.
With pretraining, every number goes up a notch and the gaps shrink:
| Dataset | Noise | Baseline | SCN |
|---|---|---|---|
| RAF-DB | 10% | 80.81 | 82.18 |
| RAF-DB | 20% | 78.18 | 80.10 |
| RAF-DB | 30% | 75.26 | 77.46 |
| AffectNet | 10% | 57.18 | 58.58 |
| AffectNet | 20% | 56.15 | 57.25 |
| AffectNet | 30% | 52.58 | 55.05 |
| FERPlus | 10% | 83.39 | 84.28 |
| FERPlus | 20% | 82.24 | 83.17 |
| FERPlus | 30% | 79.34 | 82.47 |
Compiled from Table 2 of the paper, ResNet-18 pretrained on MS-Celeb-1M, accuracy % (mean per-class for AffectNet).
The gains run from 0.9 to 3.1 percentage points, and broadly, the more noise, the more SCN helps.
The authors explain the especially large gain on RAF-DB from scratch by RAF-DB having compound expressions and crowdsourced annotation from 40 people, which makes it less consistent to begin with. As listed earlier, FERPlus is crowdsourced too, with 10 people per image, and AffectNet uses trained annotators, but only one per image. Explaining the gaps among the three by annotation method still lacks a control.
How the numbers in this table were picked, the paper doesn't say. In April 2022 someone asked in issue #69, and the author confirmed that what's reported is the epoch with the highest test accuracy during training. Two years later, EAC (ECCV 2022, Beijing University of Posts and Telecommunications) generated its own noise, reran SCN, and took the average of the last 5 epochs instead. On RAF-DB at the three noise levels, EAC's rerun of SCN gives 82.15, 79.79 and 77.45, almost identical to the SCN paper's 82.18, 80.10 and 77.46, and the baselines match too. On the same table, RUL (NeurIPS 2021) gets 86.17 at 10% noise and EAC itself 88.02, both 4 to 6 percentage points above SCN.
EAC also explains why SCN didn't help more. It files SCN under "sample selection" methods, which rely on the assumption that samples with large losses are the noisy ones and can't tell hard samples from mislabeled ones. In EAC's visualization, a surprised face mislabeled as sadness gets memorized by SCN through a small patch of furrowed-brow features; after 60 epochs of training, many mislabeled samples under SCN still have losses close to 0, meaning the model has memorized these wrong labels, and they haven't been relabeled either.
Original data
Artificial noise only simulates "mislabeled." The authors then ran on the original datasets to see whether SCN can handle real uncertainty:
| Dataset | Setting | Baseline | SCN |
|---|---|---|---|
| RAF-DB | Scratch | 72.00 | 78.31 |
| RAF-DB | Pretrained | 84.20 | 87.03 |
| AffectNet | Scratch | 46.58 | 47.28 |
| AffectNet | Pretrained | 58.5 | 60.23 |
| FERPlus | Scratch | 82.4 | 83.42 |
| FERPlus | Pretrained | 86.80 | 88.01 |
Compiled from Table 4 of the paper, accuracy %.
Trained from scratch, RAF-DB gains 6.31 percentage points, far more than the other two; with pretraining the gains are 2.83, 1.73 and 1.21. The authors picked out the ten RAF-DB images with the lowest weights; most are poor quality or occluded, and their original labels are mostly surprise and neutral.
The effect of WebEmotion pretraining was also tested on the original data. From scratch the results are 72.00, 46.58 and 82.4 (RAF-DB, AffectNet, FERPlus); pretrained on WebEmotion first and fine-tuned without SCN, they become 78.97, 56.43 and 84.20; fine-tuning with SCN gives 80.42, 57.23 and 85.13; and using SCN in pretraining as well reaches 82.45, 58.45 and 85.97. This keyword-labeled video data brings nearly 10 percentage points on AffectNet, and turning SCN on during pretraining adds another 0.8 to 2 points.
Ablations
What each of the three modules does, measured on the original RAF-DB data:
| Weight | Rank | Relabel | Scratch | Pretrained |
|---|---|---|---|---|
| – | – | – | 72.00 | 84.20 |
| – | – | ✓ | 71.25 | 83.78 |
| – | ✓ | – | 74.15 | 85.14 |
| ✓ | – | – | 76.26 | 86.09 |
| ✓ | ✓ | – | 76.57 | 86.63 |
| ✓ | ✓ | ✓ | 78.31 | 87.03 |
Compiled from Table 5 of the paper, accuracy %.
- Weighting does the heavy lifting. WCE alone takes training from scratch from 72.00 to 76.26, and pretrained from 84.20 to 86.09.
- Relabeling alone hurts. Turning relabeling on directly over the baseline drops both settings a little. The authors explain that many of the baseline model's relabelings are wrong, and weighting and ranking are needed first to gather the suspicious samples into the low group.
- Ranking on top of weighting adds only 0.3 to 0.5 percentage points. Ranking alone adds 2.15 from scratch and 0.94 pretrained, but without weighting, appears only in RR-Loss, and the paper doesn't explain how it affects classification in that case.
The ratio between the two losses was tried too. 0.5 is best (78.31); raising RR-Loss's share to 0.8 drops it to 71.75, below the baseline.

All three hyperparameters were swept in the from-scratch setting, and the numbers correspond to the earlier 78.31 (original data) and 70.26 (10% noise).
The left chart is the ranking margin . Between 0 and 0.3 the spread is under 2 percentage points without noise and about 2.7 with 10% noise, and both lines are best at 0.15; made a learnable parameter, it converges to about 0.142, with an accuracy of 77.76%, slightly below the hand-tuned value.
The middle chart is the relabeling threshold , which matters most. means relabeling whenever the network's top pick differs from the original label, and accuracy drops below 70%, worse than the 76.57 with no relabeling at all; 0.2 is best, and beyond that, relabeling happens less and less and the result approaches no relabeling.
The right chart is the high group's share . 0.7 is best, and lowering it to 0.5 (treating half the data as suspicious) falls to about 74.6%. The authors' explanation is that with too large almost no samples count as uncertain, and with it too small, too many normal samples are treated as suspicious.
Against the methods of the time
| Method | RAF-DB | AffectNet | FERPlus |
|---|---|---|---|
| RAN | 86.90 | 59.5 | 89.16 |
| SCN | 87.03 | 60.23 | 88.01 |
| SCN† | 88.14 | – | – |
| SCN‡ | – | – | 89.35 |
Excerpted from Table 7 of the paper, accuracy %. SCN† is trained on RAF-DB and AffectNet combined, and SCN‡ switches the backbone to IR50. Both rows in the AffectNet column use oversampling; RAN's FERPlus entry is the version with a VGG16 backbone trained on label distributions.
The three numbers in the abstract are 88.14%, 60.23% and 89.35%, and each comes with a condition. RAF-DB's 88.14 is from training on RAF-DB and AffectNet combined; RAF-DB alone gives 87.03. AffectNet's 60.23 uses oversampling to handle the class imbalance. FERPlus's 89.35 switches the backbone to IR50, the one ArcFace uses; ResNet-18 gives 88.01, below RAN's VGG16 version on the same table (89.16). RAN is the same authors' method from the year before, which needs several facial regions cropped at inference; SCN's argument is comparable accuracy with no extra computation at inference.
Official code and community reports
The official code is at kaiwang960112/Self-Cure-Network, with no license file; the author said in an issue that it may be used for academic purposes.
The training code in the official repo was rewritten after the fact. In March 2020 someone said in issue #7 that they couldn't reproduce the results, and the author replied that the lab had switched clusters at the end of the year, the original code sat on a hard drive in Shenzhen that couldn't be reached, and they had rewritten a version themselves. The train.py released in July was written by the author's friend nzhq, and the README says "open the SCN code and reproduce the experiments result." So the differences seen above go beyond the scope of relabeling; there are also these:
- Training recipe. Defaults of batch 64, Adam, the learning rate multiplied by 0.9 every epoch, and 70 epochs of training; the README suggests changing to 0.07 for batch 64. The paper uses batch 1,024, learning rate 0.1 and 40 epochs.
- Data augmentation. The code has random erasing, then with probability one half either a horizontal flip or added Gaussian noise. The paper doesn't mention any of it, and in issue #5 (March 2020) the author answered "We don't use data augmentation in the training stage."
- The pretrained weights never load. The code uses an ImageNet-pretrained ResNet-18 by default; when
--pretrainedpoints to the MS-Celeb-1M weights the author provides, the parameter names in the weight file aremodule.conv1…while the model's arefeatures.0…, soload_state_dict(strict=False)raises no error and loads nothing at all. The code prints "Loaded params num," but that counter is written after the assignment and always equals the total (marking its own homework). issue #49, #51 and #56 ran into it one after another, and the author's reply every time was that the names "differ by onemodule."; it took the asker in issue #81, at the end of 2022, printing the parameters before and after loading to confirm that nothing had changed at all.
How strong the baseline is has been questioned as well. In issue #58, someone trained a plain ResNet-18 with only the MS-Celeb-1M weights the author provides and reached 88% on RAF-DB; another added flips, color jitter, rotation and random erasing and reached 89.3%. The paper's pretrained baseline is 84.20% and SCN 87.03%; the author's reply was "Impressive~". issue #68 also found that switching to a different set of MS-Celeb-1M weights moves the baseline from 85% to over 88%; the asker in issue #81 later guessed that the 85% case was exactly because the weights hadn't loaded. The author's reply in July 2022 was candid. Using face pretraining or not, and which weights, really does change performance; not every group releases its weights, so SOTA comparisons "really do get messy," and the author suggested everyone compare with ImageNet-1K pretraining instead.
itself isn't easy to control either. In issue #37, training AffectNet with ResNet-50 left every near 0 and the gap between the two groups near 0 too; issue #77 went the other way, with every heading toward 1 after one epoch. As derived earlier, the direction of depends on whether the classifier agrees with the label; when the classifier's state shifts, can drift the same way en masse.
What's left are a few things that never came out. The paper said WebEmotion would be made public; in November 2020 the author said in issue #30 that, because of YouTube's policy, they'd release a download script instead, and in March 2021 replied "The code will be coming soon" (it's been coming ever since). Of the artificial-noise label files, only 10% and 20% were released; for the 30% one, the author said in November 2021 that they had moved to the National University of Singapore, no longer had the original file, and asked the requester to generate it themselves.
Conclusion
SCN takes on an old problem of expression data, annotations that can't be trusted in the first place. It learns a weight for each training image, splits them into high and low groups with rank regularization, and relabels the samples in the low group that the network is confident about; at inference it's still a ResNet-18. On RAF-DB the pretrained version goes from 84.20% to 87.03%; with 30% wrong labels added artificially, from 75.26% to 77.46%.
Reproducing it calls for extra care. The official code is a rewrite done after the fact, the MS-Celeb-1M weights never actually load, and relabeling applies to the whole batch; in December 2025 the author replied that those weights were "probably gone."
Two years later EAC reran it at 10% noise and SCN's numbers held up; RUL and EAC, which later took on noisy labels, both put it in their comparison tables.