(self, batch)
| 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""" |
nothing calls this directly
no test coverage detected