(self, dim, eps=1e-6)
| 43 | |
| 44 | class T5LayerNorm(nn.Module): |
| 45 | def __init__(self, dim, eps=1e-6): |
| 46 | super(T5LayerNorm, self).__init__() |
| 47 | self.dim = dim |
| 48 | self.eps = eps |
| 49 | self.weight = nn.Parameter(torch.ones(dim)) |
| 50 | |
| 51 | def forward(self, x): |
| 52 | x = x * torch.rsqrt(x.float().pow(2).mean(dim=-1, keepdim=True) + |