Implementation of Few-Shot Learning with Graph Neural Networks on Python3, Pytorch 0.3.1
Create images.zip file and copy it inside mini_imagenet
directory:
.
├── ...
└── datasets
└── compressed
└── mini_imagenet
└── images.zip
The images.zip file must contain the splits and images in the following format:
── images.zip
├── test.csv
├── train.csv
├── val.csv
└── images
├── n0153282900000006.jpg
├── ...
└── n1313361300001299.jpg
The splits {test.csv, train.csv, val.csv} can be downloaded from Ravi and Larochelle - splits. For more information on how to obtain the images check the original source Ravi and Larochelle - github
# 5-Way 1-shot | Few-shot
EXPNAME=minimagenet_N5_S1
python3 main.py --exp_name $EXPNAME --dataset mini_imagenet --test_N_way 5 --train_N_way 5 --train_N_shots 1 --test_N_shots 1 --batch_size 100 --dec_lr=15000 --iterations 80000
# 5-Way 5-shot | Few-shot
EXPNAME=minimagenet_N5_S5
python3 main.py --exp_name $EXPNAME --dataset mini_imagenet --test_N_way 5 --train_N_way 5 --train_N_shots 5 --test_N_shots 5 --batch_size 40 --dec_lr=15000 --iterations 90000
# 5-Way 5-shot 20%-labeled | Semi-supervised
EXPNAME=minimagenet_N5_S1_U4
python3 main.py --exp_name $EXPNAME --dataset mini_imagenet --test_N_way 5 --train_N_way 5 --train_N_shots 5 --test_N_shots 5 --unlabeled_extra 4 --batch_size 40 --dec_lr=15000 --iterations 100000
Download images_background.zip and images_evaluation.zip files from brendenlake/omniglot and copy it inside the omniglot
directory:
.
├── ...
└── datasets
└── compressed
└── omniglot
├── images_background.zip
└── images_evaluation.zip
# 5-Way 1-shot | Few-shot
EXPNAME=omniglot_N5_S1_v2
python3 main.py --exp_name $EXPNAME --dataset omniglot --test_N_way 5 --train_N_way 5 --train_N_shots 1 --test_N_shots 1 --batch_size 300 --dec_lr=10000 --iterations 100000
# 5-Way 5-shot | Few-shot
EXPNAME=omniglot_N5_S5
python3 main.py --exp_name $EXPNAME --dataset omniglot --test_N_way 5 --train_N_way 5 --train_N_shots 5 --test_N_shots 5 --batch_size 100 --dec_lr=10000 --iterations 80000
# 20-Way 1-shot | Few-shot
EXPNAME=omniglot_N20_S1
python3 main.py --exp_name $EXPNAME --dataset omniglot --test_N_way 20 --train_N_way 20 --train_N_shots 1 --test_N_shots 1 --batch_size 100 --dec_lr=10000 --iterations 80000
# 5-Way 5-shot 20%-labeled | Semi-supervised
EXPNAME=omniglot_N5_S1_U4
python3 main.py --exp_name $EXPNAME --dataset omniglot --test_N_way 5 --train_N_way 5 --train_N_shots 5 --test_N_shots 5 --unlabeled_extra 4 --batch_size 100 --dec_lr=10000 --iterations 80000