diff options
| author | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-10-02 01:45:34 +0200 |
|---|---|---|
| committer | Gustaf Rydholm <gustaf.rydholm@gmail.com> | 2022-10-02 01:45:34 +0200 |
| commit | ffec11ce67d8fe75ea0d5dde5ddf17eb1017fa7d (patch) | |
| tree | db8c78232e588b12d7a8b408682783e0b5858615 /text_recognizer/networks/convnext/norm.py | |
| parent | cf2a827db5798a245dd5207685251675d311dbec (diff) | |
Add comments
Diffstat (limited to 'text_recognizer/networks/convnext/norm.py')
| -rw-r--r-- | text_recognizer/networks/convnext/norm.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/text_recognizer/networks/convnext/norm.py b/text_recognizer/networks/convnext/norm.py index 23cf07a..3355de9 100644 --- a/text_recognizer/networks/convnext/norm.py +++ b/text_recognizer/networks/convnext/norm.py @@ -4,11 +4,14 @@ from torch import Tensor, nn class LayerNorm(nn.Module): + """Layer norm for convolutions.""" + def __init__(self, dim: int) -> None: super().__init__() self.gamma = nn.Parameter(torch.ones(1, dim, 1, 1)) def forward(self, x: Tensor) -> Tensor: + """Applies layer norm.""" eps = 1e-5 if x.dtype == torch.float32 else 1e-3 var = torch.var(x, dim=1, unbiased=False, keepdim=True) mean = torch.mean(x, dim=1, keepdim=True) |