LA-Transformer
LA-Transformer copied to clipboard
Something wrong about the model's code
Hello! Thanks for your great work.
I read your code and found out that it has one point which is different from your paper. In your paper, the GELT are created before the Pooling method. However, in the LA_Transformer code, it was implemented after the Pooling:
` cls_token_out = x[:, 0].unsqueeze(1)
# Average pool
x = self.avgpool(x[:, 1:])
# Add global cls token to each local token
for i in range(self.part):
out = torch.mul(x[:, i, :], self.lmbd)
x[:, i, :] = torch.div(torch.add(cls_token_out.squeeze(), out), 1 + self.lmbd)
`
Please check the source code again and correct me if I'm wrong.
Thank you and best regards.
@viet2411 I also made a similar observation. Note that the model during testing doesn't even create GELT'S apparently, since this part of the code is commented out in the forward
method of the LATransformerTest
class. However in the LA Transformer Testing.ipynb
notebook there is a headline saying "Concat Averaged GELTs". @SiddhantKapil would be glad if you could shed some light on this issue. Kudos to your hard work in any case.
@Thunfischpirat I noticed that the function of LA was defined in this paragraph:
"The global tokens G = f0 and local tokens Q = [f1, f2, f3, ..., fN ] are obtained for which N is number of patches. NR is defined as the total number of patches per row and NC as the total number of patches per column. In our case, NR = NC =√N. Then we define L as the averaged GELT obtained after average pooling of Q and G as follow"
So the GELT was implemented after the Average Pooling, and maybe Figure 1 in the paper had some mistake.