diff options
author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-08-06 14:19:37 +0200 |
---|---|---|
committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2021-08-06 14:19:37 +0200 |
commit | 263f2b7158d76bc0adad45309625910c0fa7b1fe (patch) | |
tree | 6af1782e39812c8d7ff8a853195adc32f67f56c2 /text_recognizer/models/base.py | |
parent | 3ab82ad36bce6fa698a13a029a0694b75a5947b7 (diff) |
Remove lr args from model, add Cosine lr, fix to vqvae stack
Diffstat (limited to 'text_recognizer/models/base.py')
-rw-r--r-- | text_recognizer/models/base.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/text_recognizer/models/base.py b/text_recognizer/models/base.py index 57c5964..ab3fa35 100644 --- a/text_recognizer/models/base.py +++ b/text_recognizer/models/base.py @@ -26,8 +26,6 @@ class BaseLitModel(LightningModule): loss_fn: Type[nn.Module] = attr.ib() optimizer_config: DictConfig = attr.ib() lr_scheduler_config: DictConfig = attr.ib() - interval: str = attr.ib() - monitor: str = attr.ib(default="val/loss") train_acc: torchmetrics.Accuracy = attr.ib( init=False, default=torchmetrics.Accuracy() ) @@ -58,12 +56,18 @@ class BaseLitModel(LightningModule): self, optimizer: Type[torch.optim.Optimizer] ) -> Dict[str, Any]: """Configures the lr scheduler.""" + # Extract non-class arguments. + monitor = self.lr_scheduler_config.monitor + interval = self.lr_scheduler_config.interval + del self.lr_scheduler_config.monitor + del self.lr_scheduler_config.interval + log.info( f"Instantiating learning rate scheduler <{self.lr_scheduler_config._target_}>" ) scheduler = { - "monitor": self.monitor, - "interval": self.interval, + "monitor": monitor, + "interval": interval, "scheduler": hydra.utils.instantiate( self.lr_scheduler_config, optimizer=optimizer ), |