MCPcopy Create free account
hub / github.com/OUCMachineLearning/OUCML / _netD

Class _netD

GAN/ACGAN-PyTorch-master/network.py:67–144  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65
66
67class _netD(nn.Module):
68 def __init__(self, ngpu, num_classes=10):
69 super(_netD, self).__init__()
70 self.ngpu = ngpu
71
72 # Convolution 1
73 self.conv1 = nn.Sequential(
74 nn.Conv2d(3, 16, 3, 2, 1, bias=False),
75 nn.LeakyReLU(0.2, inplace=True),
76 nn.Dropout(0.5, inplace=False),
77 )
78 # Convolution 2
79 self.conv2 = nn.Sequential(
80 nn.Conv2d(16, 32, 3, 1, 0, bias=False),
81 nn.BatchNorm2d(32),
82 nn.LeakyReLU(0.2, inplace=True),
83 nn.Dropout(0.5, inplace=False),
84 )
85 # Convolution 3
86 self.conv3 = nn.Sequential(
87 nn.Conv2d(32, 64, 3, 2, 1, bias=False),
88 nn.BatchNorm2d(64),
89 nn.LeakyReLU(0.2, inplace=True),
90 nn.Dropout(0.5, inplace=False),
91 )
92 # Convolution 4
93 self.conv4 = nn.Sequential(
94 nn.Conv2d(64, 128, 3, 1, 0, bias=False),
95 nn.BatchNorm2d(128),
96 nn.LeakyReLU(0.2, inplace=True),
97 nn.Dropout(0.5, inplace=False),
98 )
99 # Convolution 5
100 self.conv5 = nn.Sequential(
101 nn.Conv2d(128, 256, 3, 2, 1, bias=False),
102 nn.BatchNorm2d(256),
103 nn.LeakyReLU(0.2, inplace=True),
104 nn.Dropout(0.5, inplace=False),
105 )
106 # Convolution 6
107 self.conv6 = nn.Sequential(
108 nn.Conv2d(256, 512, 3, 1, 0, bias=False),
109 nn.BatchNorm2d(512),
110 nn.LeakyReLU(0.2, inplace=True),
111 nn.Dropout(0.5, inplace=False),
112 )
113 # discriminator fc
114 self.fc_dis = nn.Linear(13*13*512, 1)
115 # aux-classifier fc
116 self.fc_aux = nn.Linear(13*13*512, num_classes)
117 # softmax and sigmoid
118 self.softmax = nn.Softmax()
119 self.sigmoid = nn.Sigmoid()
120
121 def forward(self, input):
122 if isinstance(input.data, torch.cuda.FloatTensor) and self.ngpu > 1:
123 conv1 = nn.parallel.data_parallel(self.conv1, input, range(self.ngpu))
124 conv2 = nn.parallel.data_parallel(self.conv2, conv1, range(self.ngpu))

Callers 1

main.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected