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

Method forward

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

Source from the content-addressed store, hash-verified

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
238class SpectrumHead(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected