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

Method __init__

Code/net/Discriminator.py:29–52  ·  view source on GitHub ↗
(self, in_channels=3,features=(64,128,256,512))

Source from the content-addressed store, hash-verified

27
28class Discriminator(torch.nn.Module):
29 def __init__(self, in_channels=3,features=(64,128,256,512)):
30 super(Discriminator, self).__init__()
31 self.features = features
32 self.initial = torch.nn.Sequential(
33 torch.nn.Conv2d(in_channels=in_channels, out_channels=features[0], kernel_size=(4, 4),
34 stride=(2,2), padding=1, bias=True, padding_mode='reflect'),
35 torch.nn.BatchNorm2d(num_features=features[0]),
36 torch.nn.LeakyReLU(negative_slope=0.2, inplace=True)
37 )
38 layers = []
39 in_channels=features[0]
40 for feature in features[1:]:
41 layers.append(
42 Block(in_channels,feature,stride=1 if feature == features[-1] else 2)
43 )
44 in_channels=feature
45 layers.append(torch.nn.Conv2d(in_channels=in_channels,out_channels=1,kernel_size=(4,4),
46 stride=(1,1),padding=1,padding_mode='reflect'))
47 #将值归一化到[0-1]
48 layers.append(torch.nn.Sigmoid())
49 #对layers进行解序列
50 self.model = torch.nn.Sequential(
51 *layers
52 )
53 def forward(self,x):
54 x = self.initial(x)
55 out= self.model(x)

Callers

nothing calls this directly

Calls 2

BlockClass · 0.70
__init__Method · 0.45

Tested by

no test coverage detected