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

Method validation_step

astroclip/models/astroclip.py:97–114  ·  view source on GitHub ↗
(self, batch, batch_idx)

Source from the content-addressed store, hash-verified

95 return loss_withlogit
96
97 def validation_step(self, batch, batch_idx):
98 im, sp = batch["image"], batch["spectrum"]
99
100 # Get the image and spectrum features
101 image_features = self.image_encoder(im)
102 spectrum_features = self.spectrum_encoder(sp)
103
104 # Calculate the CLIP loss
105 val_loss_nologit = self.criterion(
106 image_features, spectrum_features, self.hparams.logit_scale
107 )
108 val_loss_withlogit = self.criterion(
109 image_features, spectrum_features, self.hparams.temperature
110 )
111
112 # Log the losses
113 self.log("val_loss_nologit", val_loss_nologit)
114 self.log("val_loss_withlogit", val_loss_withlogit)
115
116
117class CLIPLoss(nn.Module):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected