PeiyanFlying / SPViT

39 stars 3 forks source link

Preserve token strategy used at inference stage #3

Open King4819 opened 3 months ago

King4819 commented 3 months ago

Hi, I want to ask that what is the strategy at inference stage ? The method utilizes gumbel softmax to generate preserve token mask at training stage, but how to generate preserve token mask at inference stage ?

ZLKong commented 3 months ago

For the inference stage, we remove (hard prune) the tokens for speedup. https://github.com/PeiyanFlying/SPViT/blob/7ff446dcdbc72fc99097686f7ed6c819e146db3b/vit_l2_3keep_senet_inference.py#L563

We only use gumbel softmax during training. The same approach is used in DynamicViT

https://github.com/raoyongming/DynamicViT/blob/1322e626d1e9eca18cc150569908fb4af29e15f7/models/dyvit.py#L449

King4819 commented 3 months ago

@ZLKong Thanks for your reply. If during inference stage it utilizes the technique same as DynamicViT, how do it achieve adaptive pruning? Since the preserve number of tokens is already determined