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.03k stars 140 forks source link

[Question] Can we have 2 datasets in the TaskSampler (different for Query and Support dataset)? #148

Open talhaashraf7213 opened 4 months ago

talhaashraf7213 commented 4 months ago

Problem I am trying to implement something like this

test_sampler2 = CustomTaskSampler(
    support_dataset=support_dataset,
    query_dataset=query_dataset,
    n_way=N_WAY,
    n_shot=N_SHOT,
    n_query=N_QUERY,
    n_tasks=N_EVALUATION_TASKS,
)

where I can use my custom images dataset as the query dataset and CFAR100 as my support dataset.

I wanted to know from your experience if it's possible and secondly is it a good approach to improve accuracy of the model?

Considered solutions I have tried to create a custom Class CustomTaskSampler and implement the __iter__ and episodic_collate_fn but maybe I am struggling with the implementation so I wanted to validate the approach.

would highly appreciate your input.

Thank you

ebennequin commented 4 months ago

Hi! I've given your issue some thought and I don't see how it can be solved with just a custom sampler, because you are going to feed it to a DataLoader which only handles a single dataset.

I believe that you need to design:

  1. A custom dataset with defined items that can be sampled in support sets and others that can be sampled in query sets.
  2. A sampler modified from TaskSampler that samples support and query items from relevant subsets of the dataset.

I wanted to know from your experience if it's possible and secondly is it a good approach to improve accuracy of the model?

It's difficult to answer this as I don't know what you are trying to achieve with these experiments.