pmf_cvpr22 icon indicating copy to clipboard operation
pmf_cvpr22 copied to clipboard

the mode in single_step function

Open cosoldier opened this issue 1 year ago • 2 comments

Thank you for your share!

Can I use ProtoNet_Finetune during meta-train step? If so, how to modify the forward function of ProtoNet_Finetune?

I try to run the meta-train step with --deploy finetune, when using the following command:

python main.py --output outputs/your_experiment_name --dataset cifar_fs --epoch 100 --lr 5e-5 --arch dino_small_patch16 --device cuda:0 --nSupport 5 --fp16 --deploy finetune

I get an error as follow: RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn. This is because the value of mode in the last single_step function is set to false.

cosoldier avatar Dec 31 '22 18:12 cosoldier

Thank you for your interests!

Can I use ProtoNet_Finetune during meta-train step? If so, how to modify the forward function of ProtoNet_Finetune?

In theory, yes, but not for our implementation. You'll need to do gradient of gradient: something like loss.backward(retain_graph=True). This is commonly used by MAML. However, finetuning hundreds of steps will generate a huge computation graph, which is never feasible. An idea from my previous paper is to meta-train the finetuning of the final classifier only (you may include more layers if synthetic gradients is cleverly used).

hushell avatar Jan 03 '23 11:01 hushell

Thank you very much for your prompt reply! Indeed, the hundreds of inner adaptation step is impossible. Before your reply, I do not realize that the ProtoNet_Finetune will also need the calculation of second derivative just like MAML.

Your idea on finetuning the final classifier with several steps using synthetic gradients calculated with query samples inspired me a lot. This idea reminds me of the paper BOOTSTRAPPED META-LEARNING, which also uses query samples during meta-training to address the long horizon issue and do not use query samples on meta test.

cosoldier avatar Jan 04 '23 15:01 cosoldier