StableNet is a deep stable learning method for out-of-distribution generalization.
This is the official repo for CVPR21 paper "Deep Stable Learning for Out-Of-Distribution Generalization" and the arXiv version can be found at https://arxiv.org/abs/2104.07876.
Please note that some hyper-parameters(such as lrbl, epochb, lambdap) may affect the performance , which can vary among different tasks/environments/software/hardware/random seeds, and thus careful tunning is required. Similar to other DG repositories, direct migration may lead to different results as ours. We are sorry for this and trying to address this problem in the following work.
Approaches based on deep neural networks have achieved striking performance when testing data and training data share similar distribution, but can significantly fail otherwise. Therefore, eliminating the impact of distribution shifts between training and testing data is crucial for building performance-promising deep models. Conventional methods assume either the known heterogeneity of training data (e.g. domain labels) or the approximately equal capacities of different domains. In this paper, we consider a more challenging case where neither of the above assumptions holds. We propose to address this problem by removing the dependencies between features via learning weights for training samples, which helps deep models get rid of spurious correlations and, in turn, concentrate more on the true connection between discriminative features and labels. Extensive experiments clearly demonstrate the effectiveness of our method on multiple distribution generalization benchmarks compared with state-of-the-art counterparts. Through extensive experiments on distribution generalization benchmarks including PACS, VLCS, MNIST-M, and NICO, we show the effectiveness of our method compared with state-of-the-art counterparts.
- Linux with Python >= 3.6
- PyTorch >= 1.1.0
- torchvision >= 0.3.0
- tensorboard >= 1.14.0
python main_stablenet.py --gpu 0
You can see more options from
python main_stablenet.py -h
Result files will be saved in results/
.
setting | dataset | source domain | target domain | network | dataset split | accuracy | trained model |
---|---|---|---|---|---|---|---|
unbalanced(5:1:1) | PACS | A,C,S | photo | ResNet18 | split file | 94.864 | model file |
unbalanced(5:1:1) | PACS | C,S,P | art_painting | ResNet18 | split file | 80.344 | model file |
unbalanced(5:1:1) | PACS | A,S,P | cartoon | ResNet18 | split file | 74.249 | model file |
unbalanced(5:1:1) | PACS | A,C,P | sketch | ResNet18 | split file | 71.046 | model file |
unbalanced(5:1:1) | VLCS | L,P,S | caltech | ResNet18 | split file | 88.776 | model file |
unbalanced(5:1:1) | VLCS | C,P,S | labelme | ResNet18 | split file | 63.243 | model file |
unbalanced(5:1:1) | VLCS | C,L,S | pascal | ResNet18 | split file | 66.383 | model file |
unbalanced(5:1:1) | VLCS | C,L,P | sun | ResNet18 | split file | 55.459 | model file |
flexible(5:1:1) | PACS | - | - | ResNet18 | split file | 45.964 | model file |
flexible(5:1:1) | VLCS | - | - | ResNet18 | split file | 81.157 | model file |
If you find this repo useful for your research, please consider citing the paper.
@inproceedings{zhang2021deep,
title={Deep Stable Learning for Out-Of-Distribution Generalization},
author={Zhang, Xingxuan and Cui, Peng and Xu, Renzhe and Zhou, Linjun and He, Yue and Shen, Zheyan},
booktitle={Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition},
pages={5372--5382},
year={2021}
}