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

Class Discriminator

cnn-CGANCode/models.py:81–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79 return out
80
81class Discriminator(torch.nn.Module):
82 def __init__(self,img_channels = 1,out_channels = 1,d = 128):
83 super(Discriminator, self).__init__()
84 self.conv_layer_1 = torch.nn.Sequential(
85 torch.nn.Conv2d(
86 in_channels=img_channels,
87 out_channels=d // 2,
88 kernel_size=(4,4),
89 stride=(2,2),
90 padding=(1,1)
91 ),
92 torch.nn.LeakyReLU(negative_slope=0.2,inplace=True)
93 )
94 self.conv_layer_2 = torch.nn.Sequential(
95 torch.nn.Conv2d(
96 in_channels=10,
97 out_channels=d // 2,
98 kernel_size=(4, 4),
99 stride=(2, 2),
100 padding=(1, 1)
101 ),
102 torch.nn.LeakyReLU(negative_slope=0.2, inplace=True)
103 )
104 self.conv_layer_3 = torch.nn.Sequential(
105 torch.nn.Conv2d(
106 in_channels=d,
107 out_channels=d * 2,
108 kernel_size=(4, 4),
109 stride=(2, 2),
110 padding=(1, 1)
111 ),
112 torch.nn.BatchNorm2d(num_features=d * 2),
113 torch.nn.LeakyReLU(negative_slope=0.2, inplace=True)
114 )
115 self.conv_layer_4 = torch.nn.Sequential(
116 torch.nn.Conv2d(
117 in_channels=d * 2,
118 out_channels=d * 4,
119 kernel_size=(4, 4),
120 stride=(2, 2),
121 padding=(1, 1)
122 ),
123 torch.nn.BatchNorm2d(num_features=d * 4),
124 torch.nn.LeakyReLU(negative_slope=0.2, inplace=True)
125 )
126 self.final_layer = torch.nn.Sequential(
127 torch.nn.Conv2d(
128 in_channels=d * 4,
129 out_channels=out_channels,
130 kernel_size=(4, 4),
131 stride=(1,1),
132 padding=(0,0)
133 ),
134 torch.nn.Sigmoid()
135 )
136 def forward(self,input,label):
137 x = self.conv_layer_1(input)
138 y = self.conv_layer_2(label)

Callers 2

mainFunction · 0.90
models.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected