(self, x)
| 125 | kernel_size=patch_size, stride=patch_size) |
| 126 | |
| 127 | def forward(self, x): |
| 128 | batch_size, channels, height, width = x.shape |
| 129 | assert height == self.img_size[0] and width == self.img_size[1], \ |
| 130 | f"Input image size ({height}*{width}) doesn't match model ({self.img_size[0]}*{self.img_size[1]})." |
| 131 | x = self.proj(x).flatten(2).transpose(1, 2) |
| 132 | return x |
| 133 | |
| 134 | |
| 135 | class VisionTransformer(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected