Home

Awesome

CoSSL: Co-Learning of Representation and Classifier for Imbalanced Semi-Supervised Learning

LICENSE Python PyTorch

This repository contains the PyTorch implementation for the CVPR 2022 Paper "CoSSL: Co-Learning of Representation and Classifier for Imbalanced Semi-Supervised Learning" by Yue Fan, Dengxin Dai, Anna Kukleva, and Bernt Schiele.

If you have any questions on this repository or the related paper, feel free to create an issue or send me an email.

Summary

Introduction

Standard semi-supervised learning (SSL) using class-balanced datasets has shown great progress to leverage unlabeled data effectively. However, the more realistic setting of class-imbalanced data - called imbalanced SSL - is largely underexplored and standard SSL tends to underperform. In this paper, we propose a novel co-learning framework (CoSSL), which decouples representation and classifier learning while coupling them closely. To handle the data imbalance, we devise Tail-class Feature Enhancement (TFE) for classifier learning. Furthermore, the current evaluation protocol for imbalanced SSL focuses only on balanced test sets, which has limited practicality in real-world scenarios. Therefore, we further conduct a comprehensive evaluation under various shifted test distributions. In experiments, we show that our approach outperforms other methods over a large range of shifted distributions, achieving state-of-the-art performance on benchmark datasets ranging from CIFAR-10, CIFAR-100, ImageNet, to Food-101.

<p align="center"> <img src="images/pipeline.png" width="800"/> </p>

Figure: Our co-learning framework CoSSL decouples the training of representation and classifier while coupling them in a non-gradient manner. CoSSL consists of three modules: a semi-supervised representation learning module, a balanced classifier learning module, and a carefully designed pseudo-label generation module. The representation module provides a momentum encoder for feature extraction in the other two modules, and the classifier module produces a balanced classifier using our novel Tail-class Feature Enhancement (TFE). Then, pseudo-label module generates pseudo-labels for the representation module using the momentum encoder and the balanced classifier. The interplay between these modules enhances each other, leading to both a more powerful representation and a more balanced classifier. Additionally, our framework is flexible as it can accommodate any standard SSL methods and classifier learning methods.

Installation

Running Experiments

We provide run*.sh for reproducing results in our paper.

Example

Here is an example of running CoSSL on CIFAR-10 at imbalance ratio 150 with FixMatch backbone:

Run pretrain phase:

python train_cifar_fix.py --ratio 2 --num_max 1500 --imb_ratio_l 150 --imb_ratio_u 150 --epoch 500 --val-iteration 500 --out ./results/cifar10/fixmatch/baseline/wrn28_N1500_r150_seed1 --manualSeed 1 --gpu 2

Applying CoSSL:

python train_cifar_fix_cossl.py --ratio 2 --num_max 1500 --imb_ratio_l 150 --imb_ratio_u 150 --epoch 100 --val-iteration 500 --resume ./results/cifar10/fixmatch/baseline/wrn28_N1500_r150_seed1/checkpoint_401.pth.tar --out ./results/cifar10/fixmatch/cossl/wrn28_N1500_r150_lam06_seed1 --max_lam 0.6 --manualSeed 1 --gpu 0

Performance

Test Acc. (%)CIFAR-10-LT γ=50CIFAR-10-LT γ=100CIFAR-10-LT γ=150
MixMatch+CoSSL80.3 ± 0.3176.4 ± 1.1473.5 ± 1.25
ReMixMatch+CoSSL87.7 ± 0.2184.1 ± 0.5681.3 ± 0.83
FixMatch+CoSSL86.8 ± 0.3083.2 ± 0.4980.3 ± 0.55
Test Acc. (%)CIFAR-100-LT γ=20CIFAR-100-LT γ=50CIFAR-100-LT γ=100
ReMixMatch+CoSSL55.8 ± 0.6248.9 ± 0.6144.1 ± 0.59
FixMatch+CoSSL53.9 ± 0.7847.6 ± 0.5743.0 ± 0.61
Test Acc. (%)Food-101-LT γ=50Food-101-LT γ=100
FixMatch+CoSSL49.040.4
Test Acc. (%)Small-ImageNet-127 32x32Small-ImageNet-127 64x64
FixMatch+CoSSL43.754.4

Citation

Please cite our paper if it is helpful to your work:

@inproceedings{fan2021cossl,
title={CoSSL: Co-Learning of Representation and Classifier for Imbalanced Semi-Supervised Learning},
author={Fan, Yue and Dai, Dengxin and Kukleva, Anna and Schiele, Bernt},
booktitle = {The IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},
year = {2022}
}

Acknowledgements

Our implementations use the source code from the following repositories and users: