Yikai-Wang / ICI-FSL

This repository contains the code for Instance Credibility Inference (ICI).
82 stars 22 forks source link

miniimagenet experiment #9

Closed rp775 closed 3 years ago

rp775 commented 3 years ago

Hi Yikai-Wang: Thanks for paper and code. it looks interesting . I am trying to understand ICI implementation. I tried to run the code with miniimagenet pre trained model and it is working.

python main.py -g 0 --dataset miniimagenet --mode test --unlabel 5 --num-batches 16 --num_shots 1 --num_test_ways 2 --resume ckpt/res12_mini.pth.tar

But having few question. could you please clarify them when you get a chance.?

Question 1: But i couldn't understand why you are create target and generating test/train/unlabeled set from this line 1. based on my understanding from paper that we need to read test data from dataloader[from test csv file] and use it here right?

Line 1: targets = torch.arange(args.num_test_ways).repeat(args.num_shots+15+args.unlabel).long()[indicator[:args.num_test_ways*(args.num_shots+15+args.unlabel)] != 0]


indicator VALUE tensor([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]) targets VALUE tensor([0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1]) **Here we generated target value- what was the reason? any inside on this**

Line 2: data = data[indicator != 0].to(args.device) train_inputs = data[:k] train_targets = targets[:k].cpu().numpy() test_inputs = data[k:k+15args.num_test_ways] test_targets = targets[k:k+15args.num_test_ways].cpu().numpy()

Question 2: test.csv file has both data and label [same as val and train]. why we need to pass label for test data.

Question 3: Does this ICI approach only works for classification task. can we use this approach for segmentation task. whats your though on this?

Yikai-Wang commented 3 years ago

Q1: The reason is that our episode is constructed with samples from all classes one by one. As in your experiments, we have 2 classes, each of which contains 1 labeled data, 5 unlabeled data, 15 test data (the number is fixed by code). Hence we have 2*(1+5+15)=52 samples in total. Then our dataloader will first sample 1 data from the first class, and then 1 data from the second class, and again and again until all the data are sampled. Hence we simply generate the target following the sample strategy. See the following codes for more details. https://github.com/Yikai-Wang/ICI-FSL/blob/f2537b7742159adfa68cc8646b9a20c570320443/datasets.py#L64-L99 Q2: Passing labels for test data is for computing the accuracy. Q3: We haven't tried this. Maybe a point you need to consider is that the time complexity of ICI grows fast as the number of samples increases, which makes it not very scalable to problems with big data.