meta-transfer-learning icon indicating copy to clipboard operation
meta-transfer-learning copied to clipboard

Question in meta phase: Why Generate the labels of support and query ?

Open im-wll opened this issue 4 years ago • 5 comments

thanks for your very enlightening work. However I found a spot that quiet confusing to me in your code, I describe it as follows: in the pytorch version, the MetaTrainer, line 115-120, 132-138, 182-187 , you generate the labels for support and query, so the class index is in order. But in sampling, the index of the class is scrambled. why not use the actual class index?

im-wll avatar Jul 31 '20 07:07 im-wll

Thanks for your interest in our work.

We will not shuffle the order of classes in one task during task sampling. During base learning, we update the model with all the samples in one batch, so we don't need to shuffle the samples.

yaoyao-liu avatar Jul 31 '20 10:07 yaoyao-liu

W`C3LE6E$K(Q8RHD(NKGTR3 thank you for your quick reply. but I still confused about it. in CategoriesSampler, the class is random select in each task ,such as [43,5,63,19,58], but when generate the labels, it will becom [0,1,2,3,4]. the class index is not equal to the real class index. here I print the generate label of train shot and query, and also print the real class of select . though the order is not shuffled, but the class index is not the same. if this will affect the accuracy?maybe I have some error in understanding the code.

im-wll avatar Aug 01 '20 05:08 im-wll

W`C3LE6E$K(Q8RHD(NKGTR3

im-wll avatar Aug 01 '20 06:08 im-wll

During meta-learning, we're doing a 5-class classification task. So the labels for the classes range from 0 to 4.

As we use F.cross_entropy to compute the loss, we cannot set the ground truth for a 5-dim vector as [43,5,63,19,58]. https://github.com/yaoyao-liu/meta-transfer-learning/blob/d4ab548fe4258bab8e1549c8e1c9be175d52afe1/pytorch/trainer/meta.py#L153

You may check the PyTorch source code here for the details of F.cross_entropy.

yaoyao-liu avatar Aug 01 '20 09:08 yaoyao-liu

thank you, I got it

im-wll avatar Aug 01 '20 11:08 im-wll