9This module implements the ConvNet generator model.
19 """ConvNet generator model."""
25 self.
fc = nn.Linear(96, 98304)
29 nn.Conv2d(512, 512, 5, 1, 2),
31 nn.ReLU(inplace=
True),
32 nn.Upsample(scale_factor=2, mode=
"nearest"),
34 nn.Conv2d(512, 256, 5, 1, 2),
36 nn.ReLU(inplace=
True),
37 nn.Upsample(scale_factor=2, mode=
"nearest"),
39 nn.Conv2d(256, 128, 5, 1, 2),
41 nn.ReLU(inplace=
True),
42 nn.Upsample(scale_factor=2, mode=
"nearest"),
44 nn.Conv2d(128, 64, 5, 1, 2),
46 nn.ReLU(inplace=
True),
47 nn.Upsample(scale_factor=2, mode=
"nearest"),
49 nn.Conv2d(64, 32, 5, 1, 2),
51 nn.ReLU(inplace=
True),
52 nn.Upsample(scale_factor=2, mode=
"nearest"),
54 nn.Conv2d(32, 1, 5, 1, 2),
61 """Compute the model output for a given input."""
62 return self.
features(self.
fc(z).view(-1, 512, 8, 24)).tanh_()
77 """Produce one pseudo-random image for each PXD module
78 using the ConvNet generator model.
81 device = next(model.parameters()).device
85 z = torch.randn(40, 96, device=device)
87 x = model(z)[:, 0, 3:-3, :]
93 x = x.mul_(0.5).add_(0.5).clamp_(0.0, 1.0)
94 x = torch.pow(256.0, x).sub_(1.0).clamp_(0.0, 255.0)
96 return x.to(torch.uint8)
Class for the ConvNet generator model.
features
Sequential composite layer.
def forward(self, z)
Function to perform a forward pass.
def __init__(self)
Constructor to create a new model instance.