This commit is contained in:
fliptrigga13 2026-07-06 17:34:00 +08:00 committed by GitHub
commit 83eacda9a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -17,7 +17,7 @@ def normalize(x, dim=None, eps=1e-4):
if dim is None:
dim = list(range(1, x.ndim))
norm = torch.linalg.vector_norm(x, dim=dim, keepdim=True, dtype=torch.float32)
norm = torch.add(eps, norm, alpha=math.sqrt(norm.numel() / x.numel()))
norm = torch.add(norm, eps) / math.sqrt(norm.numel() / x.numel())
return x / norm.to(x.dtype)
class ResnetBlock1D(nn.Module):
@ -118,4 +118,4 @@ class Downsample1D(nn.Module):
if self.with_conv:
x = self.conv2(x)
return x
return x