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

Method validation_step

astroclip/models/specformer.py:98–113  ·  view source on GitHub ↗
(self, batch)

Source from the content-addressed store, hash-verified

96 return loss
97
98 def validation_step(self, batch):
99 # slice the input and copy
100 input = self.preprocess(batch["spectrum"])
101 target = torch.clone(input)
102
103 # mask parts of the input
104 input = self.mask_sequence(input)
105
106 # forward pass
107 output = self.forward_without_preprocessing(input)["reconstructions"]
108
109 # find the mask locations
110 locs = (input != target).type_as(output)
111 loss = F.mse_loss(output * locs, target * locs, reduction="mean") / locs.mean()
112 self.log("val_training_loss", loss, prog_bar=True)
113 return loss
114
115 def mask_sequence(self, x: Tensor):
116 """Mask batched sequence"""

Callers

nothing calls this directly

Calls 3

preprocessMethod · 0.95
mask_sequenceMethod · 0.95

Tested by

no test coverage detected