def __init__(self, in_channel, out_channel, kernel, stride, padding): super(Up2d, self).__init__() self.c1 = nn.ConvTranspose2d(in_channel, out_channel, kernel_size=kernel, stride=stride, padding=padding) self.n1 = nn.InstanceNorm2d(out_channel) self.c2 = nn.ConvTranspose2d(in_channel, out_channel, kernel_size=kernel, stride=stride, padding=padding) self.n2 = nn.InstanceNorm2d(out_channel)
def downsample(self, in_channels, out_channels, kernel_size, stride, padding): convLayer = nn.Sequential( nn.Conv2d( in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size, stride=stride, padding=padding, ), nn.InstanceNorm2d(num_features=out_channels, affine=True), GLU(), ) return convLayer
def __init__(self, in_channels, out_channels, kernel_size, stride, padding): super(DownSampleGenerator, self).__init__() self.convLayer = nn.Sequential( nn.Conv2d( in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size, stride=stride, padding=padding, ), nn.InstanceNorm2d(num_features=out_channels, affine=True), ) self.convLayer_gates = nn.Sequential( nn.Conv2d( in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size, stride=stride, padding=padding, ), nn.InstanceNorm2d(num_features=out_channels, affine=True), )
def upsample(self, in_channels, out_channels, kernel_size, stride, padding): self.convLayer = nn.Sequential( nn.Conv2d( in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size, stride=stride, padding=padding, ), nn.PixelShuffle(upscale_factor=2), nn.InstanceNorm2d(num_features=out_channels // 4, affine=True), GLU(), ) return self.convLayer