Home

Awesome

MutexMatch4SSL

This repo is the official Pytorch implementation of our paper:

MutexMatch: Semi-Supervised Learning with Mutex-Based Consistency Regularization
Authors: Yue Duan, Lei Qi, Lei Wang, Luping Zhou and Yinghuan Shi

Introduction

The core issue in semi-supervised learning (SSL) lies in how to effectively leverage unlabeled data, whereas most existing methods tend to put a great emphasis on the utilization of high-confidence samples yet seldom fully explore the usage of low-confidence samples. In this article, we aim to utilize low-confidence samples in a novel way with our proposed mutex-based consistency regularization, namely MutexMatch. Specifically, the high-confidence samples are required to exactly predict "what it is" by the conventional true-positive classifier (TPC), while low-confidence samples are employed to achieve a simpler goal — to predict with ease "what it is not" by the true-negative classifier (TNC). In this sense, we not only mitigate the pseudo-labeling errors but also make full use of the low-confidence unlabeled data by the consistency of dissimilarity degree.

Requirements

Training

Important Args

Training with Single GPU

python train_mutex.py --rank 0 --gpu [0/1/...] @@@other args@@@

Training with Multi-GPUs

python train_mutex.py --world-size 1 --rank 0 @@@other args@@@
python train_mutex.py --world-size 1 --rank 0 --multiprocessing-distributed @@@other args@@@

Examples of Running

This code assumes 1 epoch of training, but the number of iterations is 2**20. For CIFAR-100, you need set --widen_factor 8 for WRN-28-8 whereas WRN-28-2 is used for CIFAR-10. Note that you need set --net resnet18 for STL-10 and mini-ImageNet.

WideResNet

python train_mutex.py --world-size 1 --rank 0 --lr_decay cos --seed 1 --num_eval_iter 1000 --overwrite --save_name cifar10 --dataset cifar10 --num_classes 10 --num_labels 40  --gpu 0
python train_mutex.py --world-size 1 --rank 0 --lr_decay cos --k 60 --widen_factor 8 --seed 1 --num_eval_iter 1000 --overwrite --save_name cifar100 --dataset cifar100 --num_classes 100 --num_labels 200  --gpu 0
python train_mutex.py --world-size 1 --rank 0 --lr_decay cos --seed 1 --num_eval_iter 1000 --overwrite --save_name svhn --dataset svhn --num_classes 10 --num_labels 40  --gpu 0

CNN-13

python train_mutex.py --world-size 1 --rank 0 --lr_decay cos --seed 1 --num_eval_iter 1000 --overwrite --save_name cifar10 --dataset cifar10 --num_classes 10 --num_labels 1000 --net cnn13 --gpu 0

ResNet-18

python train_mutex.py --world-size 1 --rank 0 --lr_decay cos --seed 1 --num_eval_iter 1000 --overwrite --save_name miniimage --dataset miniimage --num_classes 100 --num_labels 1000 --net resnet18 --gpu 0

Resume Training and Evaluation

Resume

If you restart the training, please use --resume --load_path @checkpoint path@.

Evaluation

python eval_mutex.py --data_dir @dataset path@ --load_path @checkpoint path@ --dataset [cifar10/cifar100/svhn/stl10/miniimage/tinyimage] 

Use --net [resnet18/cnn13] for different backbones.

Results (e.g., CIFAR-10)

seed10 labels20 labels40 labels80 labels
115.7393.4394.9193.69
271.4793.2494.7693.64
393.0793.4292.9692.05
486.3287.5688.4193.43
565.6691.1895.0593.32
avg66.4591.7793.2293.23
seed10 labels20 labels40 labels80 labels
165.0193.8594.5094.77
219.9992.9594.0194.67
370.4692.8694.7494.83
468.8986.6394.9595.43
563.2394.8492.8495.30
avg57.5292.2394.2195.00

Citation

Please cite our paper if you find MutexMatch useful:

@article{duan2022mutexmatch,
  title={MutexMatch: Semi-supervised Learning with Mutex-based Consistency Regularization},
  author={Duan, Yue and Zhao, Zhen and Qi, Lei and Wang, Lei and Zhou, Luping and Shi, Yinghuan and Gao, Yang},
  journal={arXiv preprint arXiv:2203.14316},
  year={2022}
}

or

@article{9992211,
  author={Duan, Yue and Zhao, Zhen and Qi, Lei and Wang, Lei and Zhou, Luping and Shi, Yinghuan and Gao, Yang},
  journal={IEEE Transactions on Neural Networks and Learning Systems}, 
  title={MutexMatch: Semi-Supervised Learning With Mutex-Based Consistency Regularization}, 
  year={2024},
  volume={35},
  number={6},
  pages={8441-8455},
  keywords={Training;Predictive models;Semisupervised learning;Data models;Task analysis;Entropy;Labeling;Mutex-based consistency regularization;semi-supervised classification},
  doi={10.1109/TNNLS.2022.3228380}}

Acknowledgement

Our code is based on open source code: LeeDoYup/FixMatch-pytorch