From 738a9cd63554104635351ced21d6f5808c1b6072 Mon Sep 17 00:00:00 2001 From: Ross Wightman Date: Mon, 17 Jan 2022 09:25:06 -0800 Subject: [PATCH] unbiased=False for torch.var_mean path of ConvNeXt LN. Fix #1090 --- timm/models/convnext.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/timm/models/convnext.py b/timm/models/convnext.py index 3b8a049e..5f75647b 100644 --- a/timm/models/convnext.py +++ b/timm/models/convnext.py @@ -94,7 +94,7 @@ class LayerNorm2d(nn.LayerNorm): return F.layer_norm( x.permute(0, 2, 3, 1), self.normalized_shape, self.weight, self.bias, self.eps).permute(0, 3, 1, 2) else: - s, u = torch.var_mean(x, dim=1, keepdim=True) + s, u = torch.var_mean(x, dim=1, unbiased=False, keepdim=True) x = (x - u) * torch.rsqrt(s + self.eps) x = x * self.weight[:, None, None] + self.bias[:, None, None] return x