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

Class Discriminator

SRGAN/models.py:90–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88 return torch.tanh(self.final(x))
89
90class Discriminator(torch.nn.Module):
91 def __init__(self,in_channels = 3,features = [64,64,128,128,256,256,512,512]):
92 super(Discriminator, self).__init__()
93 blocks = []
94 for idx,feature in enumerate(features):
95 blocks.append(
96 ConvBlock(
97 in_channels,
98 feature,
99 kernel_size = (3,3),
100 stride = (1 + idx % 2,1 + idx % 2),
101 padding = (1,1),
102 discriminator=True,
103 use_act=True,
104 use_bn=False if idx == 0 else True
105 )
106 )
107 in_channels = feature
108 self.blocks = torch.nn.Sequential(*blocks)
109 self.classifier = torch.nn.Sequential(
110 torch.nn.AdaptiveAvgPool2d(output_size=(6,6)),
111 torch.nn.Flatten(),
112 torch.nn.Linear(in_features=512 * 6 * 6,out_features=1024),
113 torch.nn.LeakyReLU(negative_slope=0.2,inplace=True),
114 torch.nn.Linear(in_features=1024,out_features=1)
115 )
116 def forward(self,x):
117 out = self.blocks(x)
118 return self.classifier(out)
119
120if __name__ == '__main__':
121 #96 x 96 => 24 x 24

Callers 2

mainFunction · 0.90
models.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected