summaryrefslogtreecommitdiff
path: root/text_recognizer/models
diff options
context:
space:
mode:
authorGustaf Rydholm <gustaf.rydholm@gmail.com>2021-11-21 21:35:50 +0100
committerGustaf Rydholm <gustaf.rydholm@gmail.com>2021-11-21 21:35:50 +0100
commitfe43389ad26559cc09f2fd00441c02556ff674c3 (patch)
tree0ce6a70c0dc2ea54bac7e19b539af5aec4ebab19 /text_recognizer/models
parenta9363f3944f1ad31590c48d5d51c45df3bbf43b1 (diff)
Format files
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."""