Giter Site home page Giter Site logo

pt-map's Introduction

Leveraging the Feature Distribution in Transfer-based Few-Shot Learning

This repository is the official implementation of Leveraging the Feature Distribution in Transfer-based Few-Shot Learning.

Requirements

To install requirements:

pip install -r requirements.txt

Donwloading the dataset and create base/val/novel splits:

miniImageNet

  • Change directory to filelists/miniImagenet/
  • Run 'source ./download_miniImagenet.sh'

CUB

  • Change directory to filelists/CUB/
  • Run 'source ./download_CUB.sh'

CIFAR-FS

  • Download CIFAR-FS
  • Decompress and change the filename to 'cifar-FS'
  • Move the datafile to filelists/cifar/
  • Run 'python write_cifar_filelist.py'

Training

To train the feature extractors in the paper, run this command:

For miniImageNet/CUB

python train.py --dataset [miniImagenet/CUB] --method [S2M2_R/rotation] --model [WideResNet28_10/ResNet18] --train_aug

For CIFAR-FS

python train_cifar.py --dataset cifar --method [S2M2_R/rotation] --model [WideResNet28_10/ResNet18] --train_aug

Evaluation

To evaluate my model on miniImageNet/CUB/cifar/cross, run:

python test_standard.py

Pre-trained Models

You can download pretrained models and extracted features here:

  • trained models trained on miniImageNet, CUB and CIFAR-FS using WRN.

  • Create an empty 'checkpoints' directory.

  • Untar the downloaded file and move it into 'checkpoints' folder.

📋 To extract and save the novel class features of a newly trained backbone, run:

python save_plk.py --dataset [miniImagenet/CUB] --method S2M2_R --model [trainedmodel]

Results

Our model achieves the following performance (backbone: WRN) on :

Dataset 1-shot Accuracy 5-shot Accuracy
miniImageNet 82.92+-0.26% 88.82+-0.13%
tieredImageNet 85.41+-0.25% 90.44+-0.14%
CUB 91.55+-0.19% 93.99+-0.10%
CIFAR-FS 87.69+-0.23% 90.68+-0.15%
cross domain 62.49+-0.32% 76.51+-0.18%

References

A Closer Look at Few-shot Classification

Charting the Right Manifold: Manifold Mixup for Few-shot Learning

Manifold Mixup: Better Representations by Interpolating Hidden States

Sinkhorn Distances: Lightspeed Computation of Optimal Transport

SimpleShot: Revisiting Nearest-Neighbor Classification for Few-Shot Learning

Notes on optimal transport

pt-map's People

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  avatar  avatar

pt-map's Issues

trained model of tieredImagenet

Hi,
Thank you for this nice work.
I downloaded your Pre-trained Models from your Google Drive and I found that the model of tieredImagenet is missing.
Could you share us with this model?

models output: out, out1 why num_classes are 200?

Hey,

I had a question regarding the outputs from your backbone models, one you get the feature vector which is 512/640 dimension and the other output gives 200 dimension after being passed from an FC layer. What is this 200 num_classes represent and how is it used?

problem with code

Hi,thanks for your sharing.There is a problem in the res_mixup+model.py
in line 114, if isinstance(m, Bottleneck):
but there is no Bottleneck.
Looking forward to your reply

ImportError: cannot import name 'feature_loader' from 'data'

from . import datamgr
from . import dataset
from . import additional_transforms
from . import feature_loader
These above came from ./PT-MAP-master/data folder init.py file .
Actually there is no feature_loader file or module I can import. If there is something I forget to do, please tell me.
Thank you for your time.

dataset downlowding problems

There are some issues with downloading the datasets, CUB and mini-imagenet specifically from the links. Is it possible to upload them to a specific Dropobox link so that they can be downloaded?

Training epoches

Thank you for nice code!

May I know how many epoches you have trained model using rotation and S2M2_R, respectively?

Update of category centers

Thank you for your share. Would you like to know whether you only use Query in that category or all categories when updating a certain type of center?Looking forward to your reply!

The experimental results are not reasonable.

Thank you very much for sharing the code.

After running the experiment on the CUB data set by using the WideResNet28_10 model, the S2M2_R method has obtained the 100% accuracy rate, which is significantly inconsistent with your results. Could you check and address this issue? thanks.

train problrm with pre_model

When I train CUB with pre_model that you offer.
Runtime Error:Error(s) in loading state_dict for WideResNet:
Missing key(s) in state_dict: "conv1.weight", "block1.layer.0.bn1.weight", "block1.layer.0.bn1.bias", "block1.layer.0.bn1.running_mean", "block1.layer.0.bn1.running_var", "block1.layer.0.conv1.weight", "block1.layer.0.bn2.weight", "block1.layer.0.bn2.bias", "block1.layer.0.bn2.running_mean",

some issues in the test protocal

I am not an expert in FSL. But I found in the test code, you extract all runs features and stack these together. And then some functions like QR working on all of them. And initFromLabelledDatas, I am not sure this function may lead to label leakage. Because technically, if you calculate mean like that, you need to know the label information of the query data. I am looking forward to your reply.

Questions about the provided pre-trained model on cifar-FS

The provided pre-trained model on cifar-FS seems different from the other pre-trained models:

  1. The num_classes is 64, however, the total class number is 100 so that num_class should be larger than 100, is that right?
  2. The loss type seems to be 'softmax' rather than 'dist'?
  3. Can we save novel features of cifar-FS using save_plk.py? But it seems that save_plk.py only saves features of mini-Imagenet and CUB?
    Looking forward to the reply of the authors or anyone interested. Thank you.

Can't access mini-imagenet dataset

wget http://image-net.org/image/ILSVRC2015/ILSVRC2015_CLS-LOC.tar.gz

--2021-06-28 10:11:09-- http://image-net.org/image/ILSVRC2015/ILSVRC2015_CLS-LOC.tar.gz
Resolving image-net.org (image-net.org)... 171.64.68.16
Connecting to image-net.org (image-net.org)|171.64.68.16|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: https://image-net.org/image/ILSVRC2015/ILSVRC2015_CLS-LOC.tar.gz [following]
--2021-06-28 10:11:09-- https://image-net.org/image/ILSVRC2015/ILSVRC2015_CLS-LOC.tar.gz
Connecting to image-net.org (image-net.org)|171.64.68.16|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2021-06-28 10:11:10 ERROR 404: Not Found.

Can you upload a copy?

import feature_loader error

hello
I want to use the train code to perform with my data , but there is an error "ImportError: cannot import name 'feature_loader'"when I perform, but there is no "feature_loader.py" file, can you provide this file? thanks

关于测试问题

你好
阅读了论文和代码后,发现该方法最后测试的数据是“query samples”, 但这些query samples在计算类中心的过程中用过了,且每个类的测试样本数假定是一样的,那在实际问题中,测试数据样本数不一定是一样的,并且也都需要参与计算类中心吗? 期待回复 谢谢

Custom Dataset

Is there anyway to train on my dataset? Which parts of the code do I have to change?

Bugs relating to the published results?

Thank you for your source codes!

I found out that you have used the query label information in estimating the matrix c , which informs somehow the model that the number available of samples of the query data. During the experiences on my custom dataset, when I changed the matrix c by alternating the number of samples available for each class on query data to the one on support data, then the obtained results have changed significantly! Could you confirm to this isssue?

https://github.com/yhu01/PT-MAP/blob/master/test_standard.py#L99

Clarification on the backbone used on tiered imagenet

Hello, thanks for this interesting work. May I know if the result on tieredimagenet is obtained with which backbone?

The github readme states WRN but the paper states DenseNet for the same exact accuracy

Hope you can clarify. Thanks! 😀

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.