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:
1 parent
9468ef91c5
commit
fd5836be8a
3 files changed
+10
-5
No files matched your search
@@ -8,4 +8,6 @@ max_epochs: 10
|
||||
progress_bar_refresh_rate: 5
|
||||
resume_from_checkpoint: null
|
||||
weights_summary: "full"
|
||||
|
||||
# number of validation steps to execute at the beginning of the training
|
||||
num_sanity_val_steps: 0
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
# --------- pytorch --------- #
|
||||
torch>=1.10.0
|
||||
torchvision>=0.11.0
|
||||
pytorch-lightning>=1.4.0
|
||||
pytorch-lightning>=1.5.0
|
||||
torchmetrics>=0.6.0
|
||||
|
||||
# --------- hydra --------- #
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user