All Projects → Haoqing-Wang → CDFSL-ATA

Haoqing-Wang / CDFSL-ATA

Licence: other
[IJCAI 2021] Cross-Domain Few-Shot Classification via Adversarial Task Augmentation

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to CDFSL-ATA

Awesome Domain Adaptation
A collection of AWESOME things about domian adaptation
Stars: ✭ 3,357 (+15885.71%)
Mutual labels:  adversarial-learning, few-shot-learning
Learning-To-Compare-For-Text
Learning To Compare For Text , Few shot learning in text classification
Stars: ✭ 38 (+80.95%)
Mutual labels:  meta-learning, few-shot-learning
LibFewShot
LibFewShot: A Comprehensive Library for Few-shot Learning.
Stars: ✭ 629 (+2895.24%)
Mutual labels:  meta-learning, few-shot-learning
Transferlearning
Transfer learning / domain adaptation / domain generalization / multi-task learning etc. Papers, codes, datasets, applications, tutorials.-迁移学习
Stars: ✭ 8,481 (+40285.71%)
Mutual labels:  meta-learning, few-shot-learning
LearningToCompare-Tensorflow
Tensorflow implementation for paper: Learning to Compare: Relation Network for Few-Shot Learning.
Stars: ✭ 17 (-19.05%)
Mutual labels:  meta-learning, few-shot-learning
adapt
Awesome Domain Adaptation Python Toolbox
Stars: ✭ 46 (+119.05%)
Mutual labels:  adversarial-learning, few-shot-learning
awesome-few-shot-meta-learning
awesome few shot / meta learning papers
Stars: ✭ 44 (+109.52%)
Mutual labels:  meta-learning, few-shot-learning
Meta Learning Papers
Meta Learning / Learning to Learn / One Shot Learning / Few Shot Learning
Stars: ✭ 2,420 (+11423.81%)
Mutual labels:  meta-learning, few-shot-learning
sib meta learn
Code of Empirical Bayes Transductive Meta-Learning with Synthetic Gradients
Stars: ✭ 56 (+166.67%)
Mutual labels:  meta-learning, few-shot-learning
FUSION
PyTorch code for NeurIPSW 2020 paper (4th Workshop on Meta-Learning) "Few-Shot Unsupervised Continual Learning through Meta-Examples"
Stars: ✭ 18 (-14.29%)
Mutual labels:  meta-learning, few-shot-learning
Awesome-Few-shot
Awesome Few-shot learning
Stars: ✭ 50 (+138.1%)
Mutual labels:  meta-learning, few-shot-learning
Meta-TTS
Official repository of https://arxiv.org/abs/2111.04040v1
Stars: ✭ 69 (+228.57%)
Mutual labels:  meta-learning, few-shot-learning
simple-cnaps
Source codes for "Improved Few-Shot Visual Classification" (CVPR 2020), "Enhancing Few-Shot Image Classification with Unlabelled Examples" (WACV 2022), and "Beyond Simple Meta-Learning: Multi-Purpose Models for Multi-Domain, Active and Continual Few-Shot Learning" (Neural Networks 2022 - in submission)
Stars: ✭ 88 (+319.05%)
Mutual labels:  meta-learning, few-shot-learning
FSL-Mate
FSL-Mate: A collection of resources for few-shot learning (FSL).
Stars: ✭ 1,346 (+6309.52%)
Mutual labels:  meta-learning, few-shot-learning
MeTAL
Official PyTorch implementation of "Meta-Learning with Task-Adaptive Loss Function for Few-Shot Learning" (ICCV2021 Oral)
Stars: ✭ 24 (+14.29%)
Mutual labels:  meta-learning, few-shot-learning
Learning2AdaptForStereo
Code for: "Learning To Adapt For Stereo" accepted at CVPR2019
Stars: ✭ 73 (+247.62%)
Mutual labels:  meta-learning
finetuner
Finetuning any DNN for better embedding on neural search tasks
Stars: ✭ 442 (+2004.76%)
Mutual labels:  few-shot-learning
CADA
Attending to Discriminative Certainty for Domain Adaptation
Stars: ✭ 17 (-19.05%)
Mutual labels:  adversarial-learning
AKE
Guiding Entity Alignment via Adversarial Knowledge Embedding
Stars: ✭ 15 (-28.57%)
Mutual labels:  adversarial-learning
Open-L2O
Open-L2O: A Comprehensive and Reproducible Benchmark for Learning to Optimize Algorithms
Stars: ✭ 108 (+414.29%)
Mutual labels:  meta-learning

Cross-Domain Few-Shot Classification via Adversarial Task Augmentation

PyTorch implementation of:
Cross-Domain Few-Shot Classification via Adversarial Task Augmentation

Haoqing Wang, Zhi-hong Deng

IJCAI 2021 Main Track

Abstract

Few-shot classification aims to recognize unseen classes with few labeled samples from each class. Many meta-learning models for few-shot classification elaborately design various task-shared inductive bias (meta-knowledge) to solve such tasks, and achieve impressive performance. However, when there exists the domain shift between the training tasks and the test tasks, the obtained inductive bias fails to generalize across domains, which degrades the performance of the meta-learning models. In this work, we aim to improve the robustness of the inductive bias through task augmentation. Concretely, we consider the worst-case problem around the source task distribution, and propose the adversarial task augmentation method which can generate the inductive bias-adaptive 'challenging' tasks. Our method can be used as a simple plug-and-play module for various meta-learning models, and improve their cross-domain generalization capability. We conduct extensive experiments under the cross-domain setting, using nine few-shot classification datasets: mini-ImageNet, CUB, Cars, Places, Plantae, CropDiseases, EuroSAT, ISIC and ChestX. Experimental results show that our method can effectively improve the few-shot classification performance of the meta-learning models under domain shift, and outperforms the existing works.

Citation

If you use this code for your research, please cite our paper:

@inproceedings{ijcai2021-149,
  title     = {Cross-Domain Few-Shot Classification via Adversarial Task Augmentation},
  author    = {Wang, Haoqing and Deng, Zhi-Hong},
  booktitle = {Proceedings of the Thirtieth International Joint Conference on
               Artificial Intelligence, {IJCAI-21}},
  publisher = {International Joint Conferences on Artificial Intelligence Organization},
  editor    = {Zhi-Hua Zhou},
  pages     = {1075--1081},
  year      = {2021},
  month     = {8},
  note      = {Main Track}
  doi       = {10.24963/ijcai.2021/149},
  url       = {https://doi.org/10.24963/ijcai.2021/149},
}

Dependencies

Datasets

We use miniImageNet as the single source domain, and use CUB, Cars, Places, Plantae, CropDiseases, EuroSAT, ISIC and ChestX as the target domains.

For miniImageNet, CUB, Cars, Places and Plantae, download and process them seperately with the following commands.

  • Set DATASET_NAME to: miniImagenet, cub, cars, places or plantae.
cd filelists
python process.py DATASET_NAME
cd ..

For CropDiseases, EuroSAT, ISIC and ChestX, download them from

and put them under their respective paths, e.g., 'filelists/CropDiseases', 'filelists/EuroSAT', 'filelists/ISIC', 'filelists/chestX', then process them with following commands.

  • Set DATASET_NAME to: CropDiseases, EuroSAT, ISIC or chestX.
cd filelists/DATASET_NAME
python write_DATASET_NAME_filelist.py
cd ..

Pre-training

We adopt baseline pre-training from CloserLookFewShot for all models.

  • Download the pre-trained feature encoders from CloserLookFewShot.
  • Or train your own pre-trained feature encoder.
python pretrain.py --dataset miniImagenet --name Pretrain --train_aug

Training

1.Train meta-learning models

Set method to MatchingNet, RelationNet, ProtoNet, GNN or TPN. For MatchingNet, RelationNet and TPN models, we set the training shot be 5 for both 1s and 5s evaluation.

python train.py --model ResNet10 --method GNN --n_shot 5 --name GNN_5s --train_aug
python train.py --model ResNet10 --method TPN --n_shot 5 --name TPN --train_aug

2.Train meta-learning models with feature-wise transformations.

Set method to MatchingNet, RelationNet, ProtoNet, GNN or TPN.

python train_FT.py --model ResNet10 --method GNN --n_shot 5 --name GNN_FWT_5s --train_aug
python train_FT.py --model ResNet10 --method TPN --n_shot 5 --name TPN_FWT --train_aug

3.Explanation-guided train meta-learning models.

Set method to RelationNetLRP or GNNLRP.

python train.py --model ResNet10 --method GNNLRP --n_shot 5 --name GNN_LRP_5s --train_aug
python train.py --model ResNet10 --method RelationNetLRP --n_shot 5 --name RelationNet_LRP --train_aug

4.Train meta-learning models with Adversarial Task Augmentation.

Set method to MatchingNet, RelationNet, ProtoNet, GNN or TPN.

python train_ATA.py --model ResNet10 --method GNN --max_lr 80. --T_max 5 --prob 0.5 --n_shot 5 --name GNN_ATA_5s --train_aug
python train_ATA.py --model ResNet10 --method TPN --max_lr 20. --T_max 5 --prob 0.6 --n_shot 5 --name TPN_ATA --train_aug

To get the results of the iteration goal without the regularization term, with the sample-wise Euclidean distance regularization term and with the maximum mean discrepancy (MMD) distance regularization term, run

python train_NR.py --model ResNet10 --method GNN --max_lr 80. --T_max 5 --n_shot 5 --name GNN_NR_5s --train_aug
python train_Euclid.py --model ResNet10 --method GNN --max_lr 40. --T_max 5 --lamb 1. --n_shot 5 --name GNN_Euclid_5s --train_aug
python train_MMD.py --model ResNet10 --method GNN --max_lr 80. --T_max 5 --lamb 1. --n_shot 5 --name GNN_MMD_5s --train_aug

Evaluation and Fine-tuning

1.Test the trained model on the unseen domains.

  • Specify the target dataset with --dataset: cub, cars, places, plantae, CropDiseases, EuroSAT, ISIC or chestX.
  • Specify the saved model you want to evaluate with --name.
python test.py --dataset cub --n_shot 5 --model ResNet10 --method GNN --name GNN_ATA_5s
python test.py --dataset cub --n_shot 5 --model ResNet10 --method GNN --name GNN_LRP_5s

2.Fine-tuning with linear classifier. To get the results of traditional pre-training and fine-tuning, run

python finetune.py --dataset cub --n_shot 5 --finetune_epoch 50 --model ResNet10 --name Pretrain

3.Fine-tuning the meta-learning models.

python finetune_ml.py --dataset cub --method GNN --n_shot 5 --finetune_epoch 50 --model ResNet10 --name GNN_ATA_5s

Note

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].