WenbinLee / DN4

Pytorch code of "Revisiting Local Descriptor based Image-to-Class Measure for Few-shot Learning", CVPR 2019.
Other
191 stars 43 forks source link

Does this DN4 network contains a pre-triaing stage? #18

Closed YiX98 closed 1 year ago

YiX98 commented 3 years ago

Hello, this is a great work and thank you for open the resource. I realized that a lot of few-shot learning network has a pre-training stage and maybe fine-tuning during the classification. But I have not found any code regarding to the pre-training, so does the DN4 need a pre-training or it is just train from scratch based on the data with a few labeled samples?

WenbinLee commented 3 years ago

Thanks. No, DN4 does not need a pre-training stage and it is just trained from scratch in this code. By the way, since pre-training is a general trick, you can also combine our DN4 with a pre-training by yourself.

Hope this can help you!

YiX98 commented 3 years ago

Thank you for your reply! Can I ask the reason why the DN4 can achieve such a great result without the pre-training? Are some of the features of DN4 that make it possible to learn quickly in a small number of samples without fine-tuning? Or is it found in your experiments that satisfactory classification performance can be obtained without pre-training?

WenbinLee commented 3 years ago

You are welcome.

As mentioned in our paper, one key reason is that we employ the much richer non-summarized local representations to represent both the query image and support class. This can be seen as a natural data augmentation, which can especially benefit the few-shot setting. On the other hand, the image-to-class measure can make full use of these local representations owing to the exchangeability of visual patterns.

You can just run our codes or use our latest implementation in ADM from https://github.com/WenbinLee/ADM.git.

YiX98 commented 3 years ago

Thanks a lot for your answers! I've tried with the DN4 on my dataset and it can achieve a very promising result. Although DN4 can perform very well on my dataset, I am wondering how can I further improve the performance. So far I tried with adding a Transformer block to adjust the feature maps returned by the feature extractor but this Transformer block can't help with the overall accuracy. I think maybe this specific Transformer block is ineffective. Would you please give me some suggestions on using Transformer to enhance performance of DN4? Or can you please share some recommended Transformer literature with potential for DN4 enhancement?

WenbinLee commented 3 years ago

It's my pleasure. I am glad that DN4 works on your dataset! Yes, Transformer is a good choice. Unfortunately, I don't have much good suggestions or experiences on this part. I guess the key reason may be that Transformer is somewhat difficult to train. Some training tricks can be seen in "Training data-efficient image transformers & distillation through attention". Also, you may need to further make some special designs.

Hope this can help you.

YiX98 commented 3 years ago

Thank you so much for the previous support! I recently found that the output of the Similarity list shows very similar values within classes. For example, in a single episode, with the input of a single Query image and randomly selected 5-shot Support images (I have 4 classes in total). The Similarity list reported as follows: [3846.2258, 3845.3762, 3850.9907, 3846.0186], which should be the Similarity values of this Query and all the 4 Support classes. These similar values don’t seem to significantly discriminate each category. May I ask whether this is a common situation? Because I am expecting obvious differences in similarity although the testing result is good on my dataset.

WenbinLee commented 3 years ago

Yes, it's a normal situation. Because DN4 use a Sum operation to aggregate all the local similarities for a query image, this will make the similarity list flat. Fortunately, the following Softmax operation will make the the similarity list somewhat sharp.

Also, if you want to explicitly make the similarity list sharp, you may use temperature or mean/weighted average operation.

Hope this can help you.