summaryrefslogtreecommitdiff
path: root/text_recognizer/networks/convnext/norm.py
diff options
context:
space:
mode:
Diffstat (limited to 'text_recognizer/networks/convnext/norm.py')
-rw-r--r--text_recognizer/networks/convnext/norm.py3
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)