MCPcopy Create free account
hub / github.com/294coder/Dif-PAN / LayerNorm2d

Class LayerNorm2d

models/unet_model_google.py:21–34  ·  view source on GitHub ↗

LayerNorm for channels of '2D' spatial BCHW tensors

Source from the content-addressed store, hash-verified

19
20
21class LayerNorm2d(nn.LayerNorm):
22 """LayerNorm for channels of '2D' spatial BCHW tensors"""
23
24 def __init__(self, num_channels):
25 super().__init__(num_channels)
26
27 def forward(self, x: torch.Tensor) -> torch.Tensor:
28 return F.layer_norm(
29 x.permute(0, 2, 3, 1),
30 self.normalized_shape,
31 self.weight,
32 self.bias,
33 self.eps,
34 ).permute(0, 3, 1, 2)
35
36
37# model

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected