Hierarchical Graph Neural Networks for Few-Shot Learning
- python 3.6.9
- pytorch 1.2.0
- torchvision 0.4.0
- tensorboardx
- numpy
- pandas
- tqdm
You can download miniImagenet dataset from EGNN's author here
Copy them inside following directory:
.
├── ...
└── dataset
└── compacted_datasets
├── mini_imagenet_train.pickle
├── mini_imagenet_val.pickle
└── mini_imagenet_test.pickle
You can download tieredimagenet dataset from few-shot-ssl-public's author here
Copy them inside following directory:
.
├── ...
└── dataset
└── tiered-imagenet
├── train_images_png.pkl
├── train_labels.pkl
├── val_images_png.pkl
├── val_labels.pkl
├── test_images_png.pkl
├── test_labels.pkl
├── class_names.txt
└── synsets.txt
# ************************** miniImagenet, 5way 5shot *****************************
$ python train.py --device cuda:0 --dataset mini --num_ways 5 --num_shots 5 --transductive True --pool_mode kn --unet_mode addold
$ python train.py --device cuda:0 --dataset mini --num_ways 5 --num_shots 5 --transductive False --pool_mode kn --unet_mode addold
# ************************** miniImagenet, 5way 1shot *****************************
$ python train.py --device cuda:0 --dataset mini --num_ways 5 --num_shots 1 --transductive True --pool_mode kn --unet_mode addold
$ python train.py --device cuda:0 --dataset mini --num_ways 5 --num_shots 1 --transductive False --pool_mode kn --unet_mode addold
# ************************** tieredImagenet, 5way 5shot *****************************
$ python train.py --device cuda:0 --dataset tiered --num_ways 5 --num_shots 5 --transductive True --pool_mode kn --unet_mode addold
$ python train.py --device cuda:0 --dataset tiered --num_ways 5 --num_shots 5 --transductive False --pool_mode kn --unet_mode addold
The trained models are saved in the path './asset/checkpoints/', with the name of 'D-{dataset}_ N-{ways} _K-{shots} _Q-{num_queries} _B-{batch size} _T-{transductive} _P-{pooling mode} _Un-{unet mode}'. So, for example, if you want to test the trained model of 'miniImagenet, 5way 5shot, transductive, kngpooling, addold' setting, you can give --test_model argument as follow:
$ python3 eval.py --test_model D-mini_N-5_K-5_Q-5_B-40_T-True_P-kn_Un-addold
You can download our experiment results and trained models from here
Model | 5-way 5-shot acc(%) |
---|---|
GNN | 66.41 |
EGNN | 66.85 |
(ours)HGNN | 69.05 |
Model | 5-way 5-shot acc(%) |
---|---|
GNN* | 75.41 |
EGNN | 76.37 |
(ours)HGNN | 79.64 |
Model | 5-way 5-shot acc(%) |
---|---|
GNN | 69.45 |
EGNN | 70.98 |
(ours)HGNN | 73.01 |
Model | 5-way 5-shot acc(%) |
---|---|
GNN* | 81.89 |
EGNN | 80.15 |
(ours)HGNN | 83.34 |
GNN transductive mode was implemented in here by gaieepo.