sicara / easy-few-shot-learning

Ready-to-use code and tutorial notebooks to boost your way into few-shot learning for image classification.
MIT License
1.07k stars 147 forks source link

Labels of support and query images: validation and test sets #126

Closed vsantjr closed 1 year ago

vsantjr commented 1 year ago

Problem To understand the values of the labels of support and query images of the validation and test sets.

Considered solutions Not applicable.

How can we help By running the classical training notebook considering my dataset (21 classes; 13 for training; 3 for validation; 5 for testing), I would like to see the labels of the support and query images of the validation and test sets. See part of the code below related to the validation set:

from easyfsl.methods import PrototypicalNetworks
from easyfsl.samplers import TaskSampler

n_way = 2 
n_shot = 5
n_query = 10
n_validation_tasks = 500

val_set ...

It is 2-way because I have only 3 classes in the validation set. The code for the test phase considered 1000 test tasks, I used the same 2-way 5-shot setting as above and recall that I have 5 classes in the test set. But, looking at some labels of the support and query images not only for the validation set but also for the test set, there are only 0 and 1 labels. Code below (test):

(
    example_support_images,
    example_support_labels,
    example_query_images,
    example_query_labels,
    example_class_ids,
) = next(iter(test_loader))

print('Some support labels:', example_support_labels)
print('Some query labels:', example_query_labels)

And the output:

Some support labels: tensor([1, 1, 1, 1, 1, 0, 0, 0, 0, 0]) Some query labels: tensor([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

Should we not expect labels from 0 to 4 here (test set), since we have 5 test classes?

vsantjr commented 1 year ago

I think I have figured out. Thank you.