microsoft / Cream

This is a collection of our NAS and Vision Transformer work.
MIT License
1.66k stars 225 forks source link

Question about the Conv_BN in TinyViT #123

Closed tonysy closed 2 years ago

tonysy commented 2 years ago

Hi, I find the tinyvit uses Conv_BN, but the fuse function seems never been used durting the training or inference. So, can I use the standard conv and bn to replace Conv_BN?

wkcn commented 2 years ago

Thanks for your attention to our work!

The function fuse is used to fuse the conv and the batch norm into a conv for inference. I did not call it in the code.

You can replace Conv2d_BN by a standard conv and bn. Please notice the weight initialization of batch norm (https://github.com/microsoft/Cream/blob/main/TinyViT/models/tiny_vit.py#L28).