Code Monkey home page Code Monkey logo

tpn-pytorch's Introduction

Transductive Propagation Network

Pytorch Code for ICLR19 paper Learning to Propagate Labels: Transductive Propagation Network for Few-shot Learning. pdf

Requirements

  • Python 3.5
  • Pytorch 0.4+
  • tqdm

Data Download (miniImagenet and tieredImagenet)

Please download the compressed tar files from: https://github.com/renmengye/few-shot-ssl-public

mkdir -p data/miniImagenet/data
tar -zxvf mini-imagenet.tar.gz
mv *.pkl data/miniImagenet/data

mkdir -p data/tieredImagenet/data
tar -xvf tiered-imagenet.tar
mv *.pkl data/tieredImagenet/data

TPN mini-5way1shot

python train.py --gpu=0 --n_way=5 --n_shot=1 --n_test_way=5 --n_test_shot=1 --lr=0.001 --step_size=10000 --dataset=mini --exp_name=mini_TPN_5w1s_5tw1ts_rn300_k20 --rn=300 --alpha=0.99 --k=20
python test.py --gpu=0 --n_way=5 --n_shot=1 --n_test_way=5 --n_test_shot=1 --lr=0.001 --step_size=10000 --dataset=mini --exp_name=mini_TPN_5w1s_5tw1ts_rn300_k20 --rn=300 --alpha=0.99 --k=20 --iters=81500

TPN mini-5way5shot

python train.py --gpu=0 --n_way=5 --n_shot=5 --n_test_way=5 --n_test_shot=5 --lr=0.001 --step_size=10000 --dataset=mini --exp_name=mini_TPN_5w5s_5tw5ts_rn300_k20 --rn=300 --alpha=0.99 --k=20
python test.py --gpu=0 --n_way=5 --n_shot=5 --n_test_way=5 --n_test_shot=5 --lr=0.001 --step_size=10000 --dataset=mini --exp_name=mini_TPN_5w5s_5tw5ts_rn300_k20 --rn=300 --alpha=0.99 --k=20 --iters=50100

TPN tiered-5way1shot

python train.py --gpu=0 --n_way=5 --n_shot=1 --n_test_way=5 --n_test_shot=1 --lr=0.001 --step_size=25000 --dataset=tiered --exp_name=tiered_TPN_5w1s_5tw1ts_rn300_k20 --rn=300 --alpha=0.99 --k=20

TPN tiered-5way5shot

python train.py --gpu=0 --n_way=5 --n_shot=5 --n_test_way=5 --n_test_shot=5 --lr=0.001 --step_size=25000 --dataset=tiered --exp_name=tiered_TPN_5w5s_5tw5ts_rn300_k20 --rn=300 --alpha=0.99 --k=20

Citation

If you use our code, please consider cite the following:

  • Yanbin Liu, Juho Lee, Minseop Park, Saehoon Kim, Eunho Yang, Sungju Hwang, Yi Yang. Learning to Propagate Labels: Transductive Propagation Network for Few-shot Learning. In Proceedings of 7th International Conference on Learning Representations (ICLR), 2019.

@inproceedings{liu2019fewTPN,
	title={Learning to Propagate Labels: Transductive Propagation Network for Few-shot Learning},
  	author={Liu, Yanbin and Lee, Juho and Park, Minseop and Kim, Saehoon and Yang, Eunho and Hwang, Sung Ju and Yang, Yi},
	booktitle={International Conference on Learning Representations},
	year={2019},
}

tpn-pytorch's People

Contributors

csyanbin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

tpn-pytorch's Issues

about epochs

Hello,Congratulations on your work and thank you for sharing.I want to reproduce your work.
I want to know How many epochs does it take to train this model before it converges?Because my configuration is not very high, it may take a long time.thank you.

How to modify the code to TPN-semi

Hello! Thanks for your great work!
I am wondering how to modify the public code to TPN-semi. Only one sentence in the paper is for this. I would appreciate it if you could give more hints.
Thanks!

A question about the adjacency matrix

Hello, it is really a good work!
I am confused of the value of diagonal when constructing the adjacency matrix, in your code, you didn't mask the diagonal, which will make the value of diagonal near to 1. does that limit the result of transductive (S is near to Identity matrix under this condition)?

Testing - Model checkpoint to load for tieredImageNet

Hi, first of all congrats on your great work and thank you for sharing.

I'm trying to reproduce your results on tiered-ImageNet. I already trained the model. When running the testing code, which "iters" value should I load the trained model from to obtain your results displayed in your paper? That parameter is indicated for the testing phase on mini-Imagenet, but it is not for tiered-ImageNet.

Thank you for your answer.

Accruracy of TPN-semi on miniImagenet

Hi, congrats on the work!
I got some problem when running TPN in semi-supervision setting on miniImagenet. I split each class into 40% : 60% for labeled and unlabeled data, and train with extra 5 unlabeled data for each support class (same as the setting in https://arxiv.org/abs/1803.00676). However, I only got accuracy of ~51.3, which is 1.5 lower than your paper. Do you know why this may happen?

Can it use ResNet12 as backbone?

I try to change the backbone from Conv64-4 to ResNet12, but it is harmful for the accuracy. Is this model not suitable for large networks like ResNet or there is a bug in my code? And I found that the 5-shot situation usually fails, even with Conv64-4.

view size is not compatible with input tensor's size

when I run the code I get the following error:

Traceback (most recent call last): File "train.py", line 280, in <module> main() File "train.py", line 210, in main loss, acc = model(inputs) File "/home/michalislazarou/anaconda3/envs/metal/lib/python3.7/site-packages/torch/nn/modules/module.py", line 550, in __call__ result = self.forward(*input, **kwargs) File "/home/michalislazarou/PhD/TPN-torch/models.py", line 170, in forward emb_all = self.encoder(inp).view(-1,1600) RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.