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

Method __init__

StyleGAN/net/model.py:29–42  ·  view source on GitHub ↗
(self,in_channels,out_channels,kernel_size = 3,stride = 1,
                 padding = 1,gain = 2)

Source from the content-addressed store, hash-verified

27#紧跟PixelNorm之后的3 x 3卷积
28class WSConv2d(torch.nn.Module):
29 def __init__(self,in_channels,out_channels,kernel_size = 3,stride = 1,
30 padding = 1,gain = 2):
31 super(WSConv2d, self).__init__()
32 self.conv = torch.nn.Conv2d(in_channels,out_channels,kernel_size,stride,padding)
33 self.scale = (gain / (in_channels * (kernel_size**2)))**0.5
34 self.bias = self.conv.bias
35 self.conv.bias = None
36
37 #initialize conv layer
38 #torch.init.normal_:给tensor初始化,一般是给网络中参数weight初始化,初始化参数值符合正态分布。
39 #torch.init.normal_(tensor,mean=,std=) ,mean:均值,std:正态分布的标准差
40 torch.nn.init.normal_(self.conv.weight)
41 #将其偏置设置为0
42 torch.nn.init.zeros_(self.bias)
43
44 def forward(self,x):
45 out = self.conv(x * self.scale) + self.bias.view(1,self.bias.shape[0],1,1)

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected