Home

Awesome

ServiceNow completed its acquisition of Element AI on January 8, 2021. All references to Element AI in the materials that are part of this project should refer to ServiceNow.

License

<h1 align="center">Embedding Propagation</h1> <h5 align="center">Smoother Manifold for Few-Shot Classification <a href="https://arxiv.org/abs/2003.04151">[Paper]</a> (ECCV2020) </h5>

Embedding propagation can be used to regularize the intermediate features so that generalization performance is improved.

Usage

Add an embedding propagation layer to your network.

pip install git+https://github.com/ElementAI/embedding-propagation
import torch
from embedding_propagation import EmbeddingPropagation

ep = EmbeddingPropagation()
features = torch.randn(32, 32)
embeddings = ep(features)

Experiments

Generate the results from the <a href="https://arxiv.org/abs/2003.04151">[Paper]</a>.

Install requirements

pip install -r requirements.txt

This command installs the Haven library which helps in managing the experiments.

Download the Datasets

If you have the pkl version of miniimagenet, you can still use it by setting the dataset name to "episodic_miniimagenet_pkl", in each of the files in exp_configs.

<!-- You can either edit `data_root` in the `exp_configs/[pretraining|finetuning].py` or create a symbolic link to the each of the dataset folders at `./data/dataset-name/` (default). -->

Reproduce the results in the paper

1. Pre-training

python3 trainval.py -e pretrain -sb ./logs/pretraining -d <datadir>

where <datadir> is the directory where the data is saved.

2. Fine-tuning

In exp_configs/finetune_exps.py, set "pretrained_weights_root": ./logs/pretraining/

python3 trainval.py -e finetune -sb ./logs/finetuning -d <datadir>

3. SSL experirments with 100 unlabeled

In exp_configs/ssl_exps.py, set "pretrained_weights_root": ./logs/finetuning/

python3 trainval.py -e ssl_large -sb ./logs/ssl/ -d <datadir>

4. SSL experirments with 20-100% unlabeled

In exp_configs/ssl_exps.py, set "pretrained_weights_root": ./logs/finetuning/

python3 trainval.py -e ssl_small -sb ./logs/ssl/ -d <datadir>

Results

datasetmodel1-shot5-shot
episodic_cubconv465.94 ± 0.9378.80 ± 0.64
episodic_cubresnet1281.32 ± 0.8491.02 ± 0.44
episodic_cubwrn87.48 ± 0.6893.74 ± 0.35
episodic_miniimagenetconv457.41 ± 0.8572.35 ± 0.62
episodic_miniimagenetresnet1264.82 ± 0.8980.59 ± 0.64
episodic_miniimagenetwrn69.92 ± 0.8183.64 ± 0.54
episodic_tiered-imagenetconv458.63 ± 0.9272.80 ± 0.78
episodic_tiered-imagenetresnet1275.90 ± 0.9086.83 ± 0.58
episodic_tiered-imagenetwrn78.46 ± 0.9087.46 ± 0.62

Different from the paper, these results were obtained on a run with fixed hyperparameters during fine-tuning: lr=0.001, alpha=0.2 (now default), train_iters=600, classification_weight=0.1

Pre-trained weights

https://zenodo.org/record/5552602#.YV2b-UbMKvU

Citation

@article{rodriguez2020embedding,
  title={Embedding Propagation: Smoother Manifold for Few-Shot Classification},
  author={Pau Rodríguez and Issam Laradji and Alexandre Drouin and Alexandre Lacoste},
  year={2020},
  journal={arXiv preprint arXiv:2003.04151},
}