| 9 | import torch |
| 10 | |
| 11 | class Generator(torch.nn.Module): |
| 12 | def __init__(self,in_features = 100,W = 28,H = 28): |
| 13 | super(Generator, self).__init__() |
| 14 | self.fc_layer_1 = torch.nn.Sequential( |
| 15 | torch.nn.Linear(in_features = in_features,out_features=256), |
| 16 | torch.nn.BatchNorm1d(num_features=256), |
| 17 | torch.nn.ReLU() |
| 18 | ) |
| 19 | self.fc_layer_2 = torch.nn.Sequential( |
| 20 | torch.nn.Linear(in_features=10,out_features=256), |
| 21 | torch.nn.BatchNorm1d(num_features=256), |
| 22 | torch.nn.ReLU() |
| 23 | ) |
| 24 | self.fc_layer_3 = torch.nn.Sequential( |
| 25 | torch.nn.Linear(in_features=512,out_features=512), |
| 26 | torch.nn.BatchNorm1d(num_features=512), |
| 27 | torch.nn.ReLU() |
| 28 | ) |
| 29 | self.fc_layer_4 = torch.nn.Sequential( |
| 30 | torch.nn.Linear(in_features=512,out_features=1024), |
| 31 | torch.nn.BatchNorm1d(num_features=1024), |
| 32 | torch.nn.ReLU() |
| 33 | ) |
| 34 | self.fc_layer_final = torch.nn.Linear(in_features=1024,out_features=H * W) |
| 35 | |
| 36 | def forward(self,input,label): |
| 37 | x = self.fc_layer_1(input) |
| 38 | y = self.fc_layer_2(label) |
| 39 | x = torch.cat([x,y],dim=1) |
| 40 | x = self.fc_layer_3(x) |
| 41 | x = self.fc_layer_4(x) |
| 42 | out = torch.tanh(self.fc_layer_final(x)) |
| 43 | return out |
| 44 | |
| 45 | class Discriminator(torch.nn.Module): |
| 46 | def __init__(self,W = 28,H = 28,out_features = 1): |
no outgoing calls
no test coverage detected