Swin-Transformer
Swin-Transformer copied to clipboard
Is the Flops calulated wrong?
https://github.com/microsoft/Swin-Transformer/blob/2622619f70760b60a42b996f5fcbe7c9d2e7ca57/models/swin_transformer.py#L583
where
self.avgpool=self.norm: self.num_features * self.patches_resolution[0] * self.patches_resolution[1] // ((2 ** (self.num_layers - 1)) ** 2)
so flops += self.num_features * self.patches_resolution[0] * self.patches_resolution[1] // (2 ** self.num_layers) // 2
eg. 768 * 7 * 7 * 2 = 768 * 56 * 56 // 16 // 2
Hi @choasup, you are right, but the flops of avgpool
is so negligible compared with the overall flops, so we just ignore it.
Hi @choasup, how did ((2 ** (self.num_layers - 1)) ** 2)
simplified into (2 ** self.num_layers)
?
I'm so confused about the calculation of FLOPs for norm here, as in #165
Does anyone can answer my question?
Thanks alot!