Skip to content

Commit 6f53e2d

Browse files
Pull Request
1 parent 5bbb1cc commit 6f53e2d

10 files changed

+1545
-1
lines changed

README.md

+49-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,49 @@
1-
# MetaOptNet
1+
# Meta-learning with differentiable convex optimization
2+
The following are the miniImageNet few-shot accuracies of ProtoNet (Snell et al., NIPS 2017), Meta-learning with differentiable closed-form solvers — R2D2 (Bertinetto et al., arXiv 2018), and MetaOptNet (ours) ran on our codebase.
3+
4+
miniImageNet 5-way accuracies
5+
6+
| Method | 1-shot | 5-shot |
7+
|--------------------------------------------| ----------------- | --------------- |
8+
| ProtoNet (reported in paper) | 49.4 ± 0.8 % | 68.2 ± 0.7 % |
9+
| ProtoNet (our implementation) | 52.0 ± 0.6 % | 68.5 ± 0.5 % |
10+
| R2D2 (reported in paper) | 51.2 ± 0.6 % | 68.2 ± 0.6 % |
11+
| R2D2 (our implementation) | 54.0 ± 0.6 % | 70.0 ± 0.5 % |
12+
| MetaOptNet (ours) | 57.7 ± 0.6 % | 73.6 ± 0.5 % |
13+
14+
For ProtoNet and R2D2, we used the network architectures used in the original publication. For MetaOptNet, we used ResNet12.
15+
As a note, we use a different training episode composition from the ProtoNet and R2D2 papers: we always trained with 5-way and each class contains 6 query points per episode.
16+
In order to replicate the results, execute the following commands:
17+
18+
19+
Prototypical Networks 1-shot
20+
```
21+
python train.py --gpu 0 --save-path "./experiments/exp_proto_1_shot" --train-way 5 --shot 1 --query 6 --head ProtoNet --network ProtoNet --episodes-per-batch 8
22+
python test.py --gpu 0 --load ./experiments/exp_proto_1_shot/best_model.pth --episode 1000 --way 5 --shot 1 --query 15 --head ProtoNet --network ProtoNet
23+
```
24+
Prototypical Networks 5-shot
25+
```
26+
python train.py --gpu 0 --save-path "./experiments/exp_proto_5_shot" --train-way 5 --shot 5 --query 6 --head ProtoNet --network ProtoNet --episodes-per-batch 8
27+
python test.py --gpu 0 --load ./experiments/exp_proto_5_shot/best_model.pth --episode 1000 --way 5 --shot 5 --query 15 --head ProtoNet --network ProtoNet
28+
```
29+
R2D2 1-shot
30+
```
31+
python train.py --gpu 0 --save-path "./experiments/exp_R2D2_1_shot" --train-way 5 --shot 1 --query 6 --head R2D2 --network R2D2 --episodes-per-batch 8
32+
python test.py --gpu 0 --load ./experiments/exp_R2D2_1_shot/best_model.pth --episode 1000 --way 5 --shot 1 --query 15 --head R2D2 --network R2D2
33+
```
34+
35+
R2D2 5-shot
36+
```
37+
python train.py --gpu 0 --save-path "./experiments/exp_R2D2_5_shot" --train-way 5 --shot 5 --query 6 --head R2D2 --network R2D2 --episodes-per-batch 8
38+
python test.py --gpu 0 --load ./experiments/exp_R2D2_5_shot/best_model.pth --episode 1000 --way 5 --shot 5 --query 15 --head R2D2 --network R2D2
39+
```
40+
MetaOptNet 1-shot
41+
```
42+
python train.py --gpu 0 --save-path "./experiments/exp_MetaOptNet_1_shot" --train-way 20 --shot 1 --query 6 --head SVM --network ResNet --episodes-per-batch 2
43+
python test.py --gpu 0 --load ./experiments/exp_MetaOptNet_1_shot/best_model.pth --episode 1000 --way 5 --shot 1 --query 15 --head SVM --network ResNet
44+
```
45+
MetaOptNet 5-shot
46+
```
47+
python train.py --gpu 0 --save-path "./experiments/exp_MetaOptNet_5_shot" --train-way 15 --shot 5 --query 6 --head SVM --network ResNet --episodes-per-batch 1
48+
python test.py --gpu 0 --load ./experiments/exp_MetaOptNet_5_shot/best_model.pth --episode 1000 --way 5 --shot 5 --query 15 --head SVM --network ResNet
49+
```

__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Implement your code here.

0 commit comments

Comments
 (0)