Publish trained generator
Browse files
model.py
CHANGED
|
@@ -33,21 +33,3 @@ class Generator(nn.Module):
|
|
| 33 |
conditioned = torch.cat([noise, self.label_embedding(labels)], dim=1)
|
| 34 |
features = self.project(conditioned).view(-1, 128, 7, 7)
|
| 35 |
return self.decoder(features)
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
class Discriminator(nn.Module):
|
| 39 |
-
def __init__(self, num_classes=NUM_CLASSES):
|
| 40 |
-
super().__init__()
|
| 41 |
-
self.label_embedding = nn.Embedding(num_classes, 28 * 28)
|
| 42 |
-
self.features = nn.Sequential(
|
| 43 |
-
nn.utils.spectral_norm(nn.Conv2d(2, 64, 4, 2, 1)),
|
| 44 |
-
nn.LeakyReLU(0.2, inplace=True),
|
| 45 |
-
nn.utils.spectral_norm(nn.Conv2d(64, 128, 4, 2, 1)),
|
| 46 |
-
nn.LeakyReLU(0.2, inplace=True),
|
| 47 |
-
nn.Flatten(),
|
| 48 |
-
nn.utils.spectral_norm(nn.Linear(128 * 7 * 7, 1)),
|
| 49 |
-
)
|
| 50 |
-
|
| 51 |
-
def forward(self, images, labels):
|
| 52 |
-
label_map = self.label_embedding(labels).view(-1, 1, 28, 28)
|
| 53 |
-
return self.features(torch.cat([images, label_map], dim=1)).flatten()
|
|
|
|
| 33 |
conditioned = torch.cat([noise, self.label_embedding(labels)], dim=1)
|
| 34 |
features = self.project(conditioned).view(-1, 128, 7, 7)
|
| 35 |
return self.decoder(features)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|