(
self, x: torch.tensor, y: torch.tensor = None, return_weights: bool = False
)
| 287 | ) |
| 288 | |
| 289 | def forward( |
| 290 | self, x: torch.tensor, y: torch.tensor = None, return_weights: bool = False |
| 291 | ): |
| 292 | # Embed the spectrum using the pretrained model |
| 293 | with torch.set_grad_enabled(not self.freeze_backbone): |
| 294 | embedding = self.backbone(x)["embedding"] |
| 295 | |
| 296 | # Pass through cross-attention |
| 297 | x, attentions = self.cross_attention(embedding) |
| 298 | |
| 299 | # Pass through MLP and residual connection |
| 300 | x = x + self.mlp(x) |
| 301 | |
| 302 | if return_weights: |
| 303 | return x.squeeze(), attentions[1] |
| 304 | |
| 305 | return x.squeeze() |
nothing calls this directly
no outgoing calls
no test coverage detected