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

Class _netG

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

Source from the content-addressed store, hash-verified

3
4
5class _netG(nn.Module):
6 def __init__(self, ngpu, nz):
7 super(_netG, self).__init__()
8 self.ngpu = ngpu
9 self.nz = nz
10
11 # first linear layer
12 self.fc1 = nn.Linear(110, 768)
13 # Transposed Convolution 2
14 self.tconv2 = nn.Sequential(
15 nn.ConvTranspose2d(768, 384, 5, 2, 0, bias=False),
16 nn.BatchNorm2d(384),
17 nn.ReLU(True),
18 )
19 # Transposed Convolution 3
20 self.tconv3 = nn.Sequential(
21 nn.ConvTranspose2d(384, 256, 5, 2, 0, bias=False),
22 nn.BatchNorm2d(256),
23 nn.ReLU(True),
24 )
25 # Transposed Convolution 4
26 self.tconv4 = nn.Sequential(
27 nn.ConvTranspose2d(256, 192, 5, 2, 0, bias=False),
28 nn.BatchNorm2d(192),
29 nn.ReLU(True),
30 )
31 # Transposed Convolution 5
32 self.tconv5 = nn.Sequential(
33 nn.ConvTranspose2d(192, 64, 5, 2, 0, bias=False),
34 nn.BatchNorm2d(64),
35 nn.ReLU(True),
36 )
37 # Transposed Convolution 5
38 self.tconv6 = nn.Sequential(
39 nn.ConvTranspose2d(64, 3, 8, 2, 0, bias=False),
40 nn.Tanh(),
41 )
42
43 def forward(self, input):
44 if isinstance(input.data, torch.cuda.FloatTensor) and self.ngpu > 1:
45 input = input.view(-1, self.nz)
46 fc1 = nn.parallel.data_parallel(self.fc1, input, range(self.ngpu))
47 fc1 = fc1.view(-1, 768, 1, 1)
48 tconv2 = nn.parallel.data_parallel(self.tconv2, fc1, range(self.ngpu))
49 tconv3 = nn.parallel.data_parallel(self.tconv3, tconv2, range(self.ngpu))
50 tconv4 = nn.parallel.data_parallel(self.tconv4, tconv3, range(self.ngpu))
51 tconv5 = nn.parallel.data_parallel(self.tconv5, tconv4, range(self.ngpu))
52 tconv5 = nn.parallel.data_parallel(self.tconv6, tconv5, range(self.ngpu))
53 output = tconv5
54 else:
55 input = input.view(-1, self.nz)
56 fc1 = self.fc1(input)
57 fc1 = fc1.view(-1, 768, 1, 1)
58 tconv2 = self.tconv2(fc1)
59 tconv3 = self.tconv3(tconv2)
60 tconv4 = self.tconv4(tconv3)
61 tconv5 = self.tconv5(tconv4)
62 tconv5 = self.tconv6(tconv5)

Callers 1

main.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected