(self, x: torch.tensor, return_weights: bool = False)
| 216 | ) |
| 217 | |
| 218 | def forward(self, x: torch.tensor, return_weights: bool = False): |
| 219 | # Pass through the backbone |
| 220 | with torch.set_grad_enabled(not self.freeze_backbone): |
| 221 | x = self.backbone.patch_embed(x) |
| 222 | for blk in self.backbone.blocks: |
| 223 | x = blk(x) |
| 224 | embedding = self.backbone.norm(x) |
| 225 | |
| 226 | # Pass through cross-attention |
| 227 | x, attentions = self.cross_attention(embedding) |
| 228 | |
| 229 | # Pass through MLP and residual connection |
| 230 | x = self.mlp(x) |
| 231 | |
| 232 | if return_weights: |
| 233 | return x.squeeze(), attentions[1] |
| 234 | |
| 235 | return x.squeeze() |
| 236 | |
| 237 | |
| 238 | class SpectrumHead(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected