-
Notifications
You must be signed in to change notification settings - Fork 230
Open
Description
While translating this chapter, I noticed that the code here seems a bit strange. Is the indentation of the forward method incorrect?
computer-vision-course/chapters/en/unit3/vision-transformers/cvt.mdx
Lines 241 to 261 in d5b297e
| def forward(self, x): | |
| x = self.patch_embed(x) | |
| B, C, H, W = x.size() | |
| x = rearrange(x, "b c h w -> b (h w) c") | |
| cls_tokens = None | |
| if self.cls_token is not None: | |
| cls_tokens = self.cls_token.expand(B, -1, -1) | |
| x = torch.cat((cls_tokens, x), dim=1) | |
| x = self.pos_drop(x) | |
| for i, blk in enumerate(self.blocks): | |
| x = blk(x, H, W) | |
| if self.cls_token is not None: | |
| cls_tokens, x = torch.split(x, [1, H * W], 1) | |
| x = rearrange(x, "b (h w) c -> b c h w", h=H, w=W) | |
| return x, cls_tokens |
Metadata
Metadata
Assignees
Labels
No labels