Skip to content

Commit eaef0d0

Browse files
committed
Reorder weight and bias attributes in normalization classes for consistency
1 parent e7f31d6 commit eaef0d0

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

dnnlpy/src/dnnlpy/nn/normalization.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
class _BatchNorm(ABC, nn.Module):
2828
"""Base class for batch normalization modules."""
2929

30-
running_mean: Tensor | None
31-
running_var: Tensor | None
3230
weight: Tensor | None
3331
bias: Tensor | None
32+
running_mean: Tensor | None
33+
running_var: Tensor | None
3434
num_batches_tracked: Tensor | None
3535

3636
def __init__(
@@ -192,6 +192,9 @@ def _check_input_dim(self, x: Tensor) -> None:
192192

193193
class GroupNorm(nn.Module):
194194
"""Apply group normalization over channel groups."""
195+
196+
weight: Tensor | None
197+
bias: Tensor | None
195198

196199
def __init__(
197200
self,
@@ -272,10 +275,10 @@ def extra_repr(self) -> str:
272275
class _InstanceNorm(ABC, nn.Module):
273276
"""Base class for instance normalization modules."""
274277

275-
running_mean: Tensor | None
276-
running_var: Tensor | None
277278
weight: Tensor | None
278279
bias: Tensor | None
280+
running_mean: Tensor | None
281+
running_var: Tensor | None
279282

280283
def __init__(
281284
self,
@@ -416,6 +419,9 @@ def _check_input_dim(self, x: Tensor) -> None:
416419
class LayerNorm(nn.Module):
417420
"""Apply layer normalization over the trailing input dimensions."""
418421

422+
weight: Tensor | None
423+
bias: Tensor | None
424+
419425
def __init__(
420426
self,
421427
normalized_shape: int | tuple[int, ...],
@@ -545,6 +551,8 @@ def extra_repr(self) -> str:
545551
class RMSNorm(nn.Module):
546552
"""Apply root mean square normalization over the trailing input dimensions."""
547553

554+
weight: Tensor | None
555+
548556
def __init__(
549557
self,
550558
normalized_shape: int | tuple[int, ...],

0 commit comments

Comments
 (0)