MCPcopy Create free account
hub / github.com/KeepTryingTo/Pytorch-GAN / PixelNorm

Class PixelNorm

StyleGAN/net/model.py:18–25  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#Pixel norm沿着channel维度做归一化(axis=1),这样归一化的一个好处在于,
17# feature map的每个位置都具有单位长度。
18class PixelNorm(torch.nn.Module):
19 def __init__(self):
20 super(PixelNorm, self).__init__()
21 self.epsilon = 1e-8
22 def forward(self,x):
23 #keepdim:输出张量是否保留了dim
24 out = x / torch.sqrt(torch.mean(x**2,dim = 1,keepdim=True) + self.epsilon)
25 return out
26
27#紧跟PixelNorm之后的3 x 3卷积
28class WSConv2d(torch.nn.Module):

Callers 1

__init__Method · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected