MCPcopy Create free account
hub / github.com/PolymathicAI/AstroCLIP / forward

Method forward

astroclip/models/astroclip.py:289–305  ·  view source on GitHub ↗
(
        self, x: torch.tensor, y: torch.tensor = None, return_weights: bool = False
    )

Source from the content-addressed store, hash-verified

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()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected