LA-Transformer icon indicating copy to clipboard operation
LA-Transformer copied to clipboard

Something wrong about the model's code

Open viet2411 opened this issue 2 years ago • 2 comments

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 avatar May 23 '22 13:05 viet2411

@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 avatar May 25 '22 14:05 Thunfischpirat

@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.

viet2411 avatar May 27 '22 07:05 viet2411