This commit is contained in:
Aseem Saxena 2026-01-21 00:13:50 +00:00 committed by GitHub
commit 9b1a7dd83a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,4 +9,5 @@ class PixelNorm(nn.Module):
self.eps = eps
def forward(self, x):
return x / torch.sqrt(torch.mean(x**2, dim=self.dim, keepdim=True) + self.eps)
mean_square = torch.mean(x * x, dim=self.dim, keepdim=True) + self.eps
return x * torch.rsqrt(mean_square)