Skip to content

Commit

Permalink
Added validation step
Browse files Browse the repository at this point in the history
  • Loading branch information
JVGD committed Oct 23, 2021
1 parent 1af1395 commit eac8272
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions experiment1/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,17 @@ def training_step(self, batch, batch_idx, *args, **kwargs) -> T.Tensor:
self.log("loss/train", loss, prog_bar=True, on_step=False, on_epoch=True)
return loss

def validation_step(self, batch, batch_idx, *args, **kwargs) -> T.Tensor:
# Unpacking
samples = batch["samples"]
targets = batch["targets"]

# Forward
targets_pred = self(samples)

# Loss
loss = self.criteria(targets, targets_pred)

# Logging
self.log("loss/valid", loss, prog_bar=True, on_step=False, on_epoch=True)
return loss

0 comments on commit eac8272

Please sign in to comment.