| 14 | |
| 15 | |
| 16 | class Generator(torch.nn.Module): |
| 17 | def __init__(self,img_channels = 1,d = 128): |
| 18 | super(Generator, self).__init__() |
| 19 | self.conv_layer_1 = torch.nn.Sequential( |
| 20 | torch.nn.ConvTranspose2d( |
| 21 | in_channels=100, |
| 22 | out_channels=d * 2, |
| 23 | kernel_size=(4,4), |
| 24 | stride=(1,1), |
| 25 | padding=(0,0) |
| 26 | ), |
| 27 | torch.nn.BatchNorm2d(num_features=2 * d), |
| 28 | torch.nn.ReLU(inplace=True) |
| 29 | ) |
| 30 | self.conv_layer_2 = torch.nn.Sequential( |
| 31 | torch.nn.ConvTranspose2d( |
| 32 | in_channels=10, |
| 33 | out_channels=d * 2, |
| 34 | kernel_size=(4, 4), |
| 35 | stride=(1,1), |
| 36 | padding=(0,0) |
| 37 | ), |
| 38 | torch.nn.BatchNorm2d(num_features=2 * d), |
| 39 | torch.nn.ReLU(inplace=True) |
| 40 | ) |
| 41 | self.conv_layer_3 = torch.nn.Sequential( |
| 42 | torch.nn.ConvTranspose2d( |
| 43 | in_channels=4 * d, |
| 44 | out_channels=d * 2, |
| 45 | kernel_size=(4, 4), |
| 46 | stride=(2,2), |
| 47 | padding=(1,1) |
| 48 | ), |
| 49 | torch.nn.BatchNorm2d(num_features=2 * d), |
| 50 | torch.nn.ReLU(inplace=True) |
| 51 | ) |
| 52 | self.conv_layer_4 = torch.nn.Sequential( |
| 53 | torch.nn.ConvTranspose2d( |
| 54 | in_channels=d * 2, |
| 55 | out_channels=d, |
| 56 | kernel_size=(4, 4), |
| 57 | stride=(2,2), |
| 58 | padding=(1,1) |
| 59 | ), |
| 60 | torch.nn.BatchNorm2d(num_features=d), |
| 61 | torch.nn.ReLU(inplace=True) |
| 62 | ) |
| 63 | self.final_conv_layer = torch.nn.Sequential( |
| 64 | torch.nn.ConvTranspose2d( |
| 65 | in_channels=d, |
| 66 | out_channels=img_channels, |
| 67 | kernel_size=(4, 4), |
| 68 | stride=(2, 2), |
| 69 | padding=(1, 1) |
| 70 | ) |
| 71 | ) |
| 72 | def forward(self,input,label): |
| 73 | x = self.conv_layer_1(input) |
no outgoing calls
no test coverage detected