def __init__(self, in_channels=3, out_channels=3, specnorm=True): super(SRGenerator, self).__init__() self.in_channels = in_channels self.C_i = nn.Conv2d(in_channels, 64, kernel_size=3, stride=1, padding=1) self.C_m = nn.Conv2d(64, 64, kernel_size=3, stride=1, padding=1) self.C_f = nn.Conv2d(64, 3, kernel_size=3, stride=1, padding=1) self.PRelu = nn.PReLU() self.R = [] for i in range(5): self.R.append(ResBlock(64, specnorm=specnorm)) self.R = nn.ModuleList(self.R) self.U = [] for i in range(2): self.U.append(UpBlock(64, specnorm=specnorm)) self.U = nn.ModuleList(self.U) if specnorm: self.C_i = SpectralNorm(self.C_i) self.C_m = SpectralNorm(self.C_m) self.C_f = SpectralNorm(self.C_f)
def __init__(self, image_size, noise_dim = 128, emb_size = 50, specnorm = True): super(Text_Generator, self).__init__() self.h, self.w = image_size[0]//16, image_size[1]//16 self.noise_dim = noise_dim self.G_i = SpectralNorm(nn.Linear(emb_size, emb_size)) self.B_i = SpectralNorm(nn.Linear(emb_size, emb_size)) self.Const_Start = nn.Parameter(torch.ones(1, 256, self.h, self.w)) #self.Proj = nn.Linear(noise_dim + emb_size, 256*self.h*self.w) self.RGB_init = nn.Conv2d(256, 3, kernel_size = 1) self.C_init = nn.Conv2d(256, 256, kernel_size = 3, padding = 1) self.MN_init = ModulatingNet(256, noise_dim = noise_dim + emb_size, specnorm = specnorm) self.Attn = Self_Attn(64, specnorm = specnorm) self.layers, self.rgbs, self.mns = [], [], [] f = 256 for i in range(4): self.layers.append(ConvBlock(f, f//2, specnorm = specnorm)) self.mns.append(ModulatingNet(f//2, noise_dim = noise_dim + emb_size, specnorm = specnorm)) RGB = nn.Conv2d(f//2, 3, kernel_size = 1) if specnorm: RGB = SpectralNorm(RGB) self.rgbs.append(RGB) f = f//2 self.layers, self.rgbs, self.mns = nn.ModuleList(self.layers), nn.ModuleList(self.rgbs), nn.ModuleList(self.mns)
def __init__(self, image_size, in_channels = 3, noise_dim = 128, seg_channels = 3, specnorm = False): super(SPADE_Generator, self).__init__() self.h, self.w = image_size[0]//16, image_size[1]//16 self.in_channels = in_channels self.Proj = nn.Linear(noise_dim, self.h*self.w*512) self.U1 = UpBlock(512, 256, specnorm = specnorm, batchnorm = True) self.R1 = SPADE_Block(256, seg_channels = seg_channels, specnorm = specnorm) self.U2 = UpBlock(256, 128, specnorm = specnorm, batchnorm = True) self.MN = ModulatingNet(128, noise_dim = noise_dim, specnorm = specnorm) self.MN2 = ModulatingNet(64, noise_dim = noise_dim, specnorm = specnorm) self.R2 = SPADE_Block(128, seg_channels = seg_channels, specnorm = specnorm) self.U3 = UpBlock(128, 128, specnorm = specnorm, batchnorm = True) self.R3 = SPADE_Block(128, seg_channels = seg_channels, specnorm = specnorm) self.U4 = UpBlock(128, 64, specnorm = specnorm, batchnorm = True) self.TC4 = nn.ConvTranspose2d(64, self.in_channels, kernel_size = 3, stride = 1, padding = 1) if specnorm: self.Proj = SpectralNorm(self.Proj) self.TC4 = SpectralNorm(self.TC4)
def __init__(self, image_size, in_channels = 3, noise_dim = 128, specnorm = False): super(Basic_Generator, self).__init__() self.h, self.w = image_size[0]//8, image_size[1]//8 self.in_channels = in_channels self.Proj = nn.Linear(noise_dim, self.h*self.w*512) self.B0 = nn.BatchNorm2d(512) self.MN0 = ModulatingNet(512, specnorm = specnorm) self.TC1 = nn.ConvTranspose2d(512, 256, kernel_size = 4, stride = 2, padding = 1) self.B1 = nn.BatchNorm2d(256) self.MN1 = ModulatingNet(256, specnorm = specnorm) self.TC2 = nn.ConvTranspose2d(256, 128, kernel_size = 4, stride = 2, padding = 1) self.B2 = nn.BatchNorm2d(128) self.MN2 = ModulatingNet(128, specnorm = specnorm) self.TC3 = nn.ConvTranspose2d(128, 64, kernel_size = 4, stride = 2, padding = 1) self.B3 = nn.BatchNorm2d(64) self.MN3 = ModulatingNet(64, specnorm = specnorm) self.TC4 = nn.ConvTranspose2d(64, self.in_channels, kernel_size = 3, stride = 1, padding = 1) if specnorm: self.Proj = SpectralNorm(self.Proj) self.TC1 = SpectralNorm(self.TC1) self.TC2 = SpectralNorm(self.TC2) self.TC3 = SpectralNorm(self.TC3) self.TC4 = SpectralNorm(self.TC4)
def __init__(self, out_channels, in_channels = 3, specnorm = False): super(SPADE, self).__init__() self.C_P = nn.Conv2d(in_channels, out_channels, kernel_size = 1, padding = 0) self.G = nn.Conv2d(out_channels, out_channels, kernel_size = 3, padding = 1) self.B = nn.Conv2d(out_channels, out_channels, kernel_size = 3, padding = 1) if specnorm: self.C_P = SpectralNorm(self.C_P, power_iterations = 1) self.G = SpectralNorm(self.G, power_iterations = 1) self.B = SpectralNorm(self.B, power_iterations = 1)
def __init__(self, in_channels, out_channels, specnorm = True): super(ConvBlock, self).__init__() self.C1 = nn.Conv2d(in_channels, in_channels, kernel_size = 3, padding = 1) #self.C1 = ResBlock(in_channels, specnorm = specnorm) self.C2 = nn.Conv2d(in_channels, out_channels, kernel_size = 3, padding = 1) if specnorm: nn.init.kaiming_normal_(self.C1.weight) nn.init.kaiming_normal_(self.C2.weight) self.C1 = SpectralNorm(self.C1) self.C2 = SpectralNorm(self.C2)
def __init__(self, channels, seg_channels, specnorm = False): super(SPADE_Block, self).__init__() #Conv->BN->Relu->Conv->BN->Shortcut->Relu self.specnorm = specnorm self.C1 = (nn.Conv2d(channels, channels, kernel_size = 3, stride = 1, padding = 1)) self.C2 = (nn.Conv2d(channels, channels, kernel_size = 3, stride = 1, padding = 1)) if specnorm: self.C1 = SpectralNorm(self.C1, power_iterations = 1) self.C2 = SpectralNorm(self.C2, power_iterations = 1) self.S1 = SPADE(out_channels = channels, in_channels = seg_channels, specnorm = specnorm) self.S2 = SPADE(out_channels = channels, in_channels = seg_channels, specnorm = specnorm)
def __init__(self, img_size, in_channels = 3, cond_length = 10): super(Star_Patch_Discriminator, self).__init__() self.cond_length = cond_length self.h, self.w = img_size[0]//64, img_size[1]//64 self.Drop = nn.Dropout() self.C1 = SpectralNorm(nn.Conv2d(in_channels, 32, kernel_size = 4, stride = 2, padding = 1)) self.B1 = nn.InstanceNorm2d(32) self.C2 = SpectralNorm(nn.Conv2d(32, 64, kernel_size = 4, stride = 2, padding = 1)) self.B2 = nn.InstanceNorm2d(64) self.C3 = SpectralNorm(nn.Conv2d(64, 128, kernel_size = 4, stride = 2, padding = 1)) self.B3 = nn.InstanceNorm2d(128) self.C4 = SpectralNorm(nn.Conv2d(128, 256, kernel_size = 4, stride = 2, padding = 1)) self.B4 = nn.InstanceNorm2d(256) self.C5 = SpectralNorm(nn.Conv2d(256, 512, kernel_size = 4, stride = 2, padding = 1)) self.B5 = nn.InstanceNorm2d(512) self.C6 = SpectralNorm(nn.Conv2d(512, 512, kernel_size = 4, stride = 2, padding = 1)) self.B6 = nn.InstanceNorm2d(512) self.C7 = SpectralNorm(nn.Conv2d(512, 30, kernel_size = 1, stride = 1, padding = 0)) self.D1 = SpectralNorm(nn.Linear(512*self.h*self.w, cond_length))
def __init__(self, image_size, level=0, specnorm=True, mbd_features=None, in_channels=3): super(FractalNet_Discriminator, self).__init__() self.h, self.w = image_size[0] // 4, image_size[1] // 4 self.in_channels = in_channels self.mbd_features = mbd_features self.DB1 = DownBlock(self.in_channels, 64, specnorm=specnorm, batchnorm=False) self.DB2 = DownBlock(64, 128, specnorm=specnorm, batchnorm=False) self.F1 = FractalBlock(128, level=level, specnorm=specnorm, batchnorm=False) self.F2 = FractalBlock(128, level=level, specnorm=specnorm, batchnorm=False) if mbd_features is not None: self.D1 = nn.Linear(128 * self.h * self.w + mbd_features, 1) self.MBD = MinibatchDiscrimination1d(128 * self.h * self.w, mbd_features) else: self.D1 = nn.Linear(128 * self.h * self.w, 1) if specnorm: self.D1 = SpectralNorm(self.D1)
def __init__(self, image_size, in_channels=3, noise_dim=128, specnorm=False): super(DenseNet_Generator, self).__init__() self.h, self.w = image_size[0] // 8, image_size[1] // 8 self.in_channels = in_channels self.Proj = nn.Linear(noise_dim, self.h * self.w * 512) self.B0 = nn.BatchNorm2d(512) self.MN0 = ModulatingNet(512, specnorm=specnorm) self.U1 = UpBlock(512, 256, specnorm=specnorm, batchnorm=True) self.Den1 = DenseBlock(256, specnorm=specnorm, batchnorm=True) self.B1 = nn.BatchNorm2d(160) self.U2 = UpBlock(160, 128, specnorm=specnorm, batchnorm=True) self.MN1 = ModulatingNet(128, specnorm=specnorm) self.Den2 = DenseBlock(128, specnorm=specnorm, batchnorm=True) self.B2 = nn.BatchNorm2d(160) self.U3 = UpBlock(160, 64, specnorm=specnorm, batchnorm=True) self.MN2 = ModulatingNet(64, specnorm=specnorm) self.TC4 = nn.ConvTranspose2d(64, self.in_channels, kernel_size=3, stride=1, padding=1) if specnorm: self.Proj = SpectralNorm(self.Proj)
def __init__(self, image_size, in_channels = 3, noise_dim = 128, emb_dim = 50, specnorm = False): super(cResNet_Generator, self).__init__() self.h, self.w = image_size[0]//8, image_size[1]//8 self.in_channels = in_channels self.emb_dim = emb_dim self.Proj = nn.Linear(noise_dim, self.h*self.w*512) self.condProj = nn.Linear(emb_dim, self.h*self.w*emb_dim) self.B0 = nn.BatchNorm2d(512) self.MN0 = ModulatingNet(512, specnorm = specnorm) self.U1 = UpBlock(512 + emb_dim, 256, specnorm = specnorm, batchnorm = True) self.R1 = ResBlock(256, specnorm = specnorm, batchnorm = True) self.U2 = UpBlock(256, 128, specnorm = specnorm, batchnorm = True) self.MN1 = ModulatingNet(128, specnorm = specnorm) self.R2 = ResBlock(128, specnorm = specnorm, batchnorm = True) self.U3 = UpBlock(128, 64, specnorm = specnorm, batchnorm = True) self.MN2 = ModulatingNet(64, specnorm = specnorm) self.TC4 = nn.ConvTranspose2d(64, self.in_channels, kernel_size = 3, stride = 1, padding = 1) if specnorm: self.Proj = SpectralNorm(self.Proj)
def __init__(self, in_channels, out_channels, specnorm=False): super(ConvBlock, self).__init__() self.C1 = nn.Conv2d(in_channels, out_channels, kernel_size=3, stride=1, padding=1) self.P = PixelNorm() self.C2 = nn.Conv2d(out_channels, out_channels, kernel_size=3, stride=1, padding=1) if specnorm: self.C1 = SpectralNorm(self.C1, power_iterations=3) self.C2 = SpectralNorm(self.C2, power_iterations=3) else: self.C1 = equal_lr(self.C1) self.C2 = equal_lr(self.C2)
def __init__(self, channels, specnorm=False, batchnorm=False): super(ResBlock, self).__init__() self.specnorm = specnorm self.batchnorm = batchnorm self.PRelu = nn.PReLU() self.C1 = (nn.Conv2d(channels, channels, kernel_size=3, stride=1, padding=1)) self.C2 = (nn.Conv2d(channels, channels, kernel_size=3, stride=1, padding=1)) if specnorm: self.C1 = SpectralNorm(self.C1, power_iterations=1) self.C2 = SpectralNorm(self.C2, power_iterations=1) self.B1 = nn.InstanceNorm2d(channels) self.B2 = nn.InstanceNorm2d(channels)
def __init__(self, channels, specnorm=True): super(UpBlock, self).__init__() self.C = nn.Conv2d(channels, channels * 4, kernel_size=3, padding=1, stride=1) self.PixSh = nn.PixelShuffle(2) self.PRelu = nn.PReLU() if specnorm: self.C = SpectralNorm(self.C)
def __init__(self, specnorm = True, in_channels = 3): super(Patch_Discriminator, self).__init__() self.in_channels = in_channels self.DB1 = DownBlock(self.in_channels, 64, specnorm = specnorm, batchnorm = False) self.DB2 = DownBlock(64, 128, specnorm = specnorm, batchnorm = False) self.DB3 = DownBlock(128, 128, specnorm = specnorm, batchnorm = False) self.DB4 = DownBlock(128, 128, specnorm = specnorm, batchnorm = False) self.R1 = ResBlock(128, specnorm = specnorm, batchnorm = False) self.F = nn.Conv2d(128, 1, kernel_size = 3, padding = 1) if specnorm: self.F = SpectralNorm(self.F)
def __init__(self, in_channels=3, specnorm=True): super(SRDiscriminator, self).__init__() f = [3, 64, 64, 128, 128, 256, 256, 512, 512, 1024] self.D = [] for i in range(len(f) - 1): self.D.append(DownBlock(f[i], f[i + 1], specnorm=specnorm)) self.D = nn.ModuleList(self.D) self.C_f = nn.Conv2d(1024, 1, 1, 1, 1) if specnorm: self.C_f = SpectralNorm(self.C_f)
def __init__(self, img_size, in_channels = 3, out_channels = 3, cond_length = 10): super(Star_Generator, self).__init__() self.cond_length = cond_length self.ext_cond_length = cond_length*3 print(self.cond_length) self.h, self.w = img_size[0], img_size[1] self.E = nn.Embedding(cond_length, self.ext_cond_length) self.Drop = nn.Dropout() #self.C1 = SpectralNorm(nn.Conv2d(in_channels + self.cond_length, 64, kernel_size = 3, stride = 1, padding = 1)) self.C1 = SpectralNorm(nn.Conv2d(in_channels, 64, kernel_size = 3, stride = 1, padding = 1)) self.MN1 = ModulatingNet(64, noise_dim = cond_length, specnorm = True) self.I1 = nn.InstanceNorm2d(64) self.C2 = SpectralNorm(nn.Conv2d(64, 128, kernel_size = 4, stride = 2, padding = 1)) self.MN2 = ModulatingNet(128, noise_dim = cond_length, specnorm = True) self.I2 = nn.InstanceNorm2d(128) self.C3 = SpectralNorm(nn.Conv2d(128, 256, kernel_size = 4, stride = 2, padding = 1)) self.MN3 = ModulatingNet(256, noise_dim = cond_length, specnorm = True) self.I3 = nn.InstanceNorm2d(256) self.C4 = SpectralNorm(nn.Conv2d(256, 512, kernel_size = 4, stride = 2, padding = 1)) self.MN4 = ModulatingNet(512, noise_dim = cond_length, specnorm = True) self.I4 = nn.InstanceNorm2d(512) self.R1 = ResBlock(512, specnorm = True) self.R2 = ResBlock(512, specnorm = True) self.R3 = ResBlock(512, specnorm = True) self.ResList = nn.ModuleList([self.R1, self.R2, self.R3]) self.TC1 = SpectralNorm(nn.ConvTranspose2d(512, 256, kernel_size = 4, stride = 2, padding = 1)) self.MNT1 = ModulatingNet(256, noise_dim = cond_length, specnorm = True) self.IT1 = nn.InstanceNorm2d(256) self.TC2 = SpectralNorm(nn.ConvTranspose2d(256, 128, kernel_size = 4, stride = 2, padding = 1)) self.MNT2 = ModulatingNet(128, noise_dim = cond_length, specnorm = True) self.IT2 = nn.InstanceNorm2d(128) self.TC3 = SpectralNorm(nn.ConvTranspose2d(128, 64, kernel_size = 4, stride = 2, padding = 1)) self.MNT3 = ModulatingNet(64, noise_dim = cond_length, specnorm = True) self.IT3 = nn.InstanceNorm2d(64) #self.TC4 = SpectralNorm(nn.ConvTranspose2d(64 + self.cond_length, out_channels, kernel_size = 3, stride = 1, padding = 1)) self.TC4 = SpectralNorm(nn.ConvTranspose2d(64, out_channels, kernel_size = 3, stride = 1, padding = 1))
def __init__(self, in_channels = 3, specnorm = True): super(Discriminator, self).__init__() self.layers, self.rgbs, self.mns = [], [], [] f = 64 self.C_init = nn.Conv2d(3 + 50, f, kernel_size = 3, padding = 1) self.Pool = nn.AvgPool2d(3, stride = 2, padding = 1) for i in range(4): RGB = nn.Conv2d(3, f, kernel_size = 1) if specnorm: RGB = SpectralNorm(RGB) self.rgbs.append(RGB) self.layers.append(ConvBlock(2*f, 2*f, specnorm)) self.mns.append(ModulatingNet(2*f, noise_dim = 50, specnorm = specnorm)) f = f*2 self.F = nn.Conv2d(f, 1, kernel_size = 1) self.layers, self.rgbs, self.mns = nn.ModuleList(self.layers), nn.ModuleList(self.rgbs), nn.ModuleList(self.mns) if specnorm: self.C_init = SpectralNorm(self.C_init) self.F = SpectralNorm(self.F)
def __init__(self, image_size, specnorm = True, mbd_features = None, in_channels = 3): super(Basic_Discriminator, self).__init__() self.h, self.w = image_size[0]//16, image_size[1]//16 self.in_channels = in_channels self.mbd_features = mbd_features self.DB1 = DownBlock(self.in_channels, 64, specnorm = specnorm, batchnorm = False) self.DB2 = DownBlock(64, 128, specnorm = specnorm, batchnorm = False) self.DB3 = DownBlock(128, 256, specnorm = specnorm, batchnorm = False) self.DB4 = DownBlock(256, 512, specnorm = specnorm, batchnorm = False) if mbd_features is not None: self.D1 = nn.Linear(512*self.h*self.w + mbd_features, 1) self.MBD = MinibatchDiscrimination1d(512*self.h*self.w, mbd_features) else: self.D1 = nn.Linear(512*self.h*self.w, 1) if specnorm: self.D1 = SpectralNorm(self.D1)
def __init__(self, image_size, emb_dim = 50, specnorm = True, mbd_features = None, in_channels = 3): super(cResNet_Discriminator, self).__init__() self.h, self.w = image_size[0]//4, image_size[1]//4 self.in_channels = in_channels self.mbd_features = mbd_features self.emb_dim = emb_dim self.DB1 = DownBlock(self.in_channels, 64, specnorm = specnorm, batchnorm = False) self.DB2 = DownBlock(64, 128, specnorm = specnorm, batchnorm = False) self.R1 = ResBlock(128, specnorm = specnorm, batchnorm = False) self.R2 = ResBlock(128, specnorm = specnorm, batchnorm = False) if mbd_features is not None: self.D1 = nn.Linear(128*self.h*self.w + mbd_features + emb_dim, 1) self.MBD = MinibatchDiscrimination1d(128*self.h*self.w, mbd_features) else: self.D1 = nn.Linear(128*self.h*self.w + emb_dim, 1) if specnorm: self.D1 = SpectralNorm(self.D1)
def __init__(self, in_channels = 3, noise_dim = 128, seg_channels = 3, specnorm = False): super(SPADE_Generator_FConv, self).__init__() self.in_channels = in_channels self.U1 = UpBlock(1, 512, specnorm = specnorm, batchnorm = True) self.R1 = SPADE_Block(512, seg_channels = seg_channels, specnorm = specnorm) self.U2 = UpBlock(512, 256, specnorm = specnorm, batchnorm = True) self.MN = ModulatingNet(256, noise_dim = noise_dim, specnorm = specnorm) self.MN2 = ModulatingNet(256, noise_dim = noise_dim, specnorm = specnorm) self.R2 = SPADE_Block(256, seg_channels = seg_channels, specnorm = specnorm) self.U3 = UpBlock(256, 256, specnorm = specnorm, batchnorm = True) self.R3 = SPADE_Block(256, seg_channels = seg_channels, specnorm = specnorm) self.U4 = UpBlock(256, 256, specnorm = specnorm, batchnorm = True) self.TC4 = nn.ConvTranspose2d(256, self.in_channels, kernel_size = 3, stride = 1, padding = 1) if specnorm: self.TC4 = SpectralNorm(self.TC4)
def __init__(self, specnorm=False): super(Prog_Discriminator, self).__init__() self.C_1 = ConvBlock(128, 128, specnorm=specnorm) self.C_2 = ConvBlock(128, 128, specnorm=specnorm) self.C_3 = ConvBlock(128, 128, specnorm=specnorm) self.C_4 = ConvBlock(128, 128, specnorm=specnorm) self.C_5 = ConvBlock(128, 128, specnorm=specnorm) self.C_6 = ConvBlock(128, 128, specnorm=specnorm) self.C_7 = ConvBlock(128 + 1, 128, specnorm=specnorm) self.From_RGB_1 = nn.Conv2d(3, 128, kernel_size=3, stride=1, padding=1) self.From_RGB_2 = nn.Conv2d(3, 128, kernel_size=3, stride=1, padding=1) self.From_RGB_3 = nn.Conv2d(3, 128, kernel_size=3, stride=1, padding=1) self.From_RGB_4 = nn.Conv2d(3, 128, kernel_size=3, stride=1, padding=1) self.From_RGB_5 = nn.Conv2d(3, 128, kernel_size=3, stride=1, padding=1) self.From_RGB_6 = nn.Conv2d(3, 128, kernel_size=3, stride=1, padding=1) self.From_RGB_7 = nn.Conv2d(3, 128, kernel_size=3, stride=1, padding=1) self.D1 = nn.Linear(128 * 4 * 4, 1) self.total_no_of_layers = 7 self.ConvList = nn.ModuleList([ self.C_1, self.C_2, self.C_3, self.C_4, self.C_5, self.C_6, self.C_7 ]) self.From_RGBList = nn.ModuleList([ self.From_RGB_1, self.From_RGB_2, self.From_RGB_3, self.From_RGB_4, self.From_RGB_5, self.From_RGB_6, self.From_RGB_7 ]) if specnorm: for i in range(len(self.From_RGBList)): self.From_RGBList[i] = SpectralNorm(self.From_RGBList[i], power_iterations=3) else: for i in range(len(self.From_RGBList)): self.From_RGBList[i] = equal_lr(self.From_RGBList[i])
def __init__(self, noise_dim=128, specnorm=False): super(Prog_Generator, self).__init__() self.noise_dim = noise_dim #This guy turns 1x1 into 4x4 self.Proj = nn.ConvTranspose2d(noise_dim, 128, kernel_size=4, stride=1, padding=0) self.Pi = PixelNorm() self.C_4x4 = ConvBlock(128, 128, specnorm=specnorm) self.C_8x8 = ConvBlock(128, 128, specnorm=specnorm) self.C_16x16 = ConvBlock(128, 128, specnorm=specnorm) self.C_32x32 = ConvBlock(128, 128, specnorm=specnorm) self.C_64x64 = ConvBlock(128, 128, specnorm=specnorm) self.C_128x128 = ConvBlock(128, 128, specnorm=specnorm) self.C_256x256 = ConvBlock(128, 128, specnorm=specnorm) self.To_RGB_8x8 = nn.Conv2d(128, 3, kernel_size=3, stride=1, padding=1) self.To_RGB_16x16 = nn.Conv2d(128, 3, kernel_size=3, stride=1, padding=1) self.To_RGB_32x32 = nn.Conv2d(128, 3, kernel_size=3, stride=1, padding=1) self.To_RGB_64x64 = nn.Conv2d(128, 3, kernel_size=3, stride=1, padding=1) self.To_RGB_128x128 = nn.Conv2d(128, 3, kernel_size=3, stride=1, padding=1) self.To_RGB_256x256 = nn.Conv2d(128, 3, kernel_size=3, stride=1, padding=1) self.ConvList = nn.ModuleList([ self.C_16x16, self.C_32x32, self.C_64x64, self.C_128x128, self.C_256x256 ]) self.To_RGBList = nn.ModuleList([ self.To_RGB_8x8, self.To_RGB_16x16, self.To_RGB_32x32, self.To_RGB_64x64, self.To_RGB_128x128, self.To_RGB_256x256 ]) if specnorm: for i in range(len(self.To_RGBList)): self.To_RGBList[i] = SpectralNorm(self.To_RGBList[i], power_iterations=3) else: for i in range(len(self.To_RGBList)): self.To_RGBList[i] = equal_lr(self.To_RGBList[i])