Release/1.2 (#199)

*add manual resetting of metrics at the end of every epoch
*set `pytorch-lightning>=1.5` in `requirements.txt`
This commit is contained in:
Łukasz Zalewski authored and GitHub committed 2021-11-08 21:15:54 +01:00
1 parent 9468ef91c5
commit fd5836be8a
3 files changed
+10 -5

No files matched your search

+7 -4
View File
@@ -50,7 +50,7 @@ class MNISTLitModel(LightningModule):
self.val_acc = Accuracy()
self.test_acc = Accuracy()
# for logging best accuracy achieved so far
# for logging best so far validation accuracy
self.val_acc_best = MaxMetric()
def forward(self, x: torch.Tensor):
@@ -92,9 +92,6 @@ class MNISTLitModel(LightningModule):
def validation_epoch_end(self, outputs: List[Any]):
acc = self.val_acc.compute() # get val accuracy from current epoch
self.val_acc.reset() # reset is necessary if you're using `num_sanity_val_steps` in trainer
# compute and log best so far val accuracy
self.val_acc_best.update(acc)
self.log("val/acc_best", self.val_acc_best.compute(), on_epoch=True, prog_bar=True)
@@ -111,6 +108,12 @@ class MNISTLitModel(LightningModule):
def test_epoch_end(self, outputs: List[Any]):
pass
def on_epoch_end(self):
# reset metrics at the end of every epoch!
self.train_acc.reset()
self.test_acc.reset()
self.val_acc.reset()
def configure_optimizers(self):
"""Choose what optimizers and learning-rate schedulers to use in your optimization.
Normally you'd need one. But in the case of GANs or similar you might have multiple.