Few-Shot Learning as Domain Adaptation: Algorithm and Analysis(accepted by ICML2020)
Jiechao Guan, Zhiwu Lu, Tao Xiang, Ji-Rong Wen
To recognize the unseen classes with only few samples, few-shot learning (FSL) uses prior knowledge learned from the seen classes. A major challenge for FSL is that the distribution of the unseen classes is different from that of those seen, resulting in poor generalization even when a model is meta-trained on the seen classes. This class-difference-caused distribution shift can be considered as a special case of domain shift. In this paper, for the first time, we propose a domain adaptation prototypical network with attention (DAPNA) to explicitly tackle such a domain shift problem in a meta-learning framework. Specifically, armed with a set transformer based attention module, we construct each episode with two sub-episodes without class overlap on the seen classes to simulate the domain shift between the seen and unseen classes. To align the feature distributions of the two sub-episodes with limited training samples, a feature transfer network is employed together with a margin disparity discrepancy (MDD) loss. Importantly, theoretical analysis is provided to give the learning bound of our DAPNA. Extensive experiments show that our DAPNA outperforms the state-of-the-art FSL alternatives, often by significant margins.
If you find it useful, please consider citing our work using the bibtex:
@inproceedings{guan2020icml,
title = {Few-Shot Learning as Domain Adaptation: Algorithm and Analysis},
author = {Jiechao Guan and Zhiwu Lu and Tao Xiang and Ji-Rong Wen},
booktitle = {International Conference on Machine Learning},
year = {2020},
}
- Python 3.7
- Pytorch 1.3.1
-
Folder '\data' should contain the raw images of 3 FSL datasets (e.g. miniImageNet, tieredImageNet, CUB). We download the original images of ImageNet to construct mini- and tieredImageNet datasets based on the splitting strategies. We download the CUB dataset and use the bounding-box images. You can download the miniImageNet (Enter Code: 4u9g, 2.86 Gb) and CUB (Enter Code: kscu, 2.23 Gb) processed by us. The tieredImageNet zip exceeds 88 Gb so we are unable to upload it to Baidu Disk. Email to me (
guanjiechao0660@ruc.edu.cn
) if you want it. -
Folder '\saves' should include the WRN-28-10 models pretrained on Place365 (24Gb), which has no overlap classes with that of the MiniImageNet/TieredImageNet/CUB dataset. You can pretrain a new one, or use our pretrained models: miniImageNet (Enter Code: 2p7s), tieredImageNet (Enter Code: zigs), CUB (Enter Code: 1h2y) (Actually these three pretrained models are the same).
--Standard FSL Setting
1. Train a DAPNA model.
-- sh train_proto_mdd.sh
2. Evaluate DAPNA's performance.
-- python eval.py
--Cross domain FSL setting
1. Train a DAPNA model.
-- sh cross_domain_train_proto_mdd.sh
2. Evaluate DAPNA's performance.
-- python cross_domain_eval.py
We thank following repos providing helpful components/functions in our work.
- A Closer Look at Few-shot Classification https://github.com/wyharveychen/CloserLookFewShot
- Learning Embedding Adaptation for Few-Shot Learning https://github.com/Sha-Lab/FEAT
- Bridging Theory and Algorithm for Domain Adaptation https://github.com/thuml/MDD