Modification of timm.models.beit.py: Block.forward to support arbitrary window sizes.
(self, x, resolution, shared_rel_pos_bias: Optional[torch.Tensor] = None)
| 92 | |
| 93 | |
| 94 | def block_forward(self, x, resolution, shared_rel_pos_bias: Optional[torch.Tensor] = None): |
| 95 | """ |
| 96 | Modification of timm.models.beit.py: Block.forward to support arbitrary window sizes. |
| 97 | """ |
| 98 | if hasattr(self, 'drop_path1') and not hasattr(self, 'drop_path'): |
| 99 | self.drop_path = self.drop_path1 |
| 100 | if self.gamma_1 is None: |
| 101 | x = x + self.drop_path(self.attn(self.norm1(x), resolution, shared_rel_pos_bias=shared_rel_pos_bias)) |
| 102 | x = x + self.drop_path(self.mlp(self.norm2(x))) |
| 103 | else: |
| 104 | x = x + self.drop_path(self.gamma_1 * self.attn(self.norm1(x), resolution, |
| 105 | shared_rel_pos_bias=shared_rel_pos_bias)) |
| 106 | x = x + self.drop_path(self.gamma_2 * self.mlp(self.norm2(x))) |
| 107 | return x |
| 108 | |
| 109 | |
| 110 | def beit_forward_features(self, x): |
nothing calls this directly
no outgoing calls
no test coverage detected