summaryrefslogtreecommitdiff
path: root/text_recognizer/networks/transformer/norm.py
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/networks/transformer/norm.py
parenta9363f3944f1ad31590c48d5d51c45df3bbf43b1 (diff)
Format files
Diffstat (limited to 'text_recognizer/networks/transformer/norm.py')
-rw-r--r--text_recognizer/networks/transformer/norm.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/text_recognizer/networks/transformer/norm.py b/text_recognizer/networks/transformer/norm.py
index c59744a..98f4d7f 100644
--- a/text_recognizer/networks/transformer/norm.py
+++ b/text_recognizer/networks/transformer/norm.py
@@ -12,6 +12,8 @@ from torch import Tensor
class ScaleNorm(nn.Module):
+ """Scaled normalization."""
+
def __init__(self, normalized_shape: int, eps: float = 1.0e-5) -> None:
super().__init__()
self.scale = normalized_shape ** -0.5
@@ -25,6 +27,8 @@ class ScaleNorm(nn.Module):
class PreNorm(nn.Module):
+ """Applies layer normalization then function."""
+
def __init__(self, normalized_shape: int, fn: Type[nn.Module]) -> None:
super().__init__()
self.norm = nn.LayerNorm(normalized_shape)