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

Method training_step

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

Source from the content-addressed store, hash-verified

80 return {"reconstructions": reconstructions, "embedding": x}
81
82 def training_step(self, batch):
83 # slice the input and copy
84 input = self.preprocess(batch["spectrum"])
85 target = torch.clone(input)
86
87 # mask parts of the input
88 input = self.mask_sequence(input)
89 # forward pass
90 output = self.forward_without_preprocessing(input)["reconstructions"]
91
92 # find the mask locations
93 locs = (input != target).type_as(output)
94 loss = F.mse_loss(output * locs, target * locs, reduction="mean") / locs.mean()
95 self.log("training_loss", loss, prog_bar=True)
96 return loss
97
98 def validation_step(self, batch):
99 # slice the input and copy

Callers

nothing calls this directly

Calls 3

preprocessMethod · 0.95
mask_sequenceMethod · 0.95

Tested by

no test coverage detected