| 10 | from torchvision import transforms |
| 11 | |
| 12 | class Block(torch.nn.Module): |
| 13 | def __init__(self,in_channels,out_channels,stride): |
| 14 | super(Block, self).__init__() |
| 15 | self.in_channels = in_channels |
| 16 | self.out_channels = out_channels |
| 17 | |
| 18 | self.conv = torch.nn.Sequential( |
| 19 | torch.nn.Conv2d(in_channels=in_channels,out_channels=out_channels,kernel_size=(4,4), |
| 20 | stride=stride,padding=1,bias=True,padding_mode='reflect'), |
| 21 | torch.nn.BatchNorm2d(num_features=out_channels), |
| 22 | torch.nn.LeakyReLU(negative_slope=0.2,inplace=True) |
| 23 | ) |
| 24 | def forward(self,x): |
| 25 | out = self.conv(x) |
| 26 | return out |
| 27 | |
| 28 | class Discriminator(torch.nn.Module): |
| 29 | def __init__(self, in_channels=3,features=(64,128,256,512)): |