From 3a21c29e2eff4378c63717f8920ca3ccbfef013c Mon Sep 17 00:00:00 2001 From: Gustaf Rydholm Date: Sun, 3 Oct 2021 00:31:00 +0200 Subject: Lint files --- text_recognizer/criterions/label_smoothing.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'text_recognizer/criterions') diff --git a/text_recognizer/criterions/label_smoothing.py b/text_recognizer/criterions/label_smoothing.py index 74ff145..5b3a47e 100644 --- a/text_recognizer/criterions/label_smoothing.py +++ b/text_recognizer/criterions/label_smoothing.py @@ -21,7 +21,8 @@ class LabelSmoothingLoss(nn.Module): self, ignore_index: int = -100, smoothing: float = 0.0, dim: int = -1 ) -> None: super().__init__() - assert 0.0 < smoothing <= 1.0 + if not 0.0 < smoothing < 1.0: + raise ValueError("Smoothing must be between 0.0 and 1.0") self.ignore_index = ignore_index self.confidence = 1.0 - smoothing self.smoothing = smoothing -- cgit v1.2.3-70-g09d2