(self, batch, batch_idx)
| 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 | |
| 117 | class CLIPLoss(nn.Module): |
nothing calls this directly
no outgoing calls
no test coverage detected