summaryrefslogtreecommitdiff
path: root/text_recognizer/models
diff options
context:
space:
mode:
Diffstat (limited to 'text_recognizer/models')
-rw-r--r--text_recognizer/models/base.py1
-rw-r--r--text_recognizer/models/transformer.py4
2 files changed, 3 insertions, 2 deletions
diff --git a/text_recognizer/models/base.py b/text_recognizer/models/base.py
index cc54de4..821cb69 100644
--- a/text_recognizer/models/base.py
+++ b/text_recognizer/models/base.py
@@ -46,6 +46,7 @@ class BaseLitModel(LightningModule):
optimizer: Type[torch.optim.Optimizer],
optimizer_idx: int,
) -> None:
+ """Optimal way to set grads to zero."""
optimizer.zero_grad(set_to_none=True)
def _configure_optimizer(self) -> List[Type[torch.optim.Optimizer]]:
diff --git a/text_recognizer/models/transformer.py b/text_recognizer/models/transformer.py
index d8cb665..369361b 100644
--- a/text_recognizer/models/transformer.py
+++ b/text_recognizer/models/transformer.py
@@ -60,8 +60,8 @@ class TransformerLitModel(BaseLitModel):
# pred = self(data)
# self.val_cer(pred, targets)
# self.log("val/cer", self.val_cer, on_step=False, on_epoch=True, prog_bar=True)
- # self.test_acc(pred, targets)
- # self.log("val/acc", self.test_acc, on_step=False, on_epoch=True)
+ # self.val_acc(pred, targets)
+ # self.log("val/acc", self.val_acc, on_step=False, on_epoch=True)
def test_step(self, batch: Tuple[Tensor, Tensor], batch_idx: int) -> None:
"""Test step."""