def __init__(self, x_channels=1, y_channels=3, ch=64, activation=F.relu): super().__init__() self.activation = activation initializer = chainer.initializers.GlorotUniform() with self.init_scope(): self.block0_0 = OptimizedBlock(x_channels, ch // 2) self.block0_1 = OptimizedBlock(y_channels, ch // 2) self.block1 = Block(ch, ch * 2, activation=activation, downsample=True) self.block2 = Block(ch * 2, ch * 4, activation=activation, downsample=True) self.block3 = Block(ch * 4, ch * 8, activation=activation, downsample=True) self.block4 = Block(ch * 8, ch * 16, activation=activation, downsample=True) self.block5 = Block(ch * 16, ch * 16, activation=activation, downsample=False) self.l6 = Linear(ch * 16, 1, initialW=initializer)
def __init__(self, ch=64, n_classes=0, activation=F.relu): super(SNResNetProjectionDiscriminator, self).__init__() self.activation = activation initializer = chainer.initializers.GlorotUniform() with self.init_scope(): self.block1 = OptimizedBlock(3, ch) self.block2 = Block(ch, ch * 2, activation=activation, downsample=True) self.block3 = Block(ch * 2, ch * 4, activation=activation, downsample=True) self.block4 = Block(ch * 4, ch * 8, activation=activation, downsample=True) self.block5 = Block(ch * 8, ch * 16, activation=activation, downsample=True) self.block6 = Block(ch * 16, ch * 16, activation=activation, downsample=False) self.l7 = SNLinear(ch * 16, 1, initialW=initializer) if n_classes > 0: self.l_y = SNEmbedID(n_classes, ch * 16, initialW=initializer)
def __init__(self, ch=64, ch_in=3, n_classes=0, activation=F.relu): super(SNResNetProjectionDiscriminator, self).__init__() self.activation = activation self.block1 = OptimizedBlock(ch_in, ch) self.block2 = Block(ch, ch * 2, activation=activation, downsample=True) self.block3 = Block(ch * 2, ch * 4, activation=activation, downsample=True) self.block4 = Block(ch * 4, ch * 8, activation=activation, downsample=True) self.block5 = Block(ch * 8, ch * 16, activation=activation, downsample=True) self.block6 = Block(ch * 16, ch * 16, activation=activation, downsample=False) self.l7 = SNLinear(ch * 16, 1) if n_classes > 0: self.l_y = SNEmbedding(n_classes, ch * 16)
def __init__(self, ch=128, n_classes=0, activation=F.relu): super(SNResNetProjectionDiscriminator, self).__init__() self.activation = activation with self.init_scope(): self.block1 = OptimizedBlock(3, ch) self.block2 = Block(ch, ch, activation=activation, downsample=True) self.block3 = Block(ch, ch, activation=activation, downsample=False) self.block4 = Block(ch, ch, activation=activation, downsample=False) self.l5 = SNLinear(ch, 1, initialW=chainer.initializers.GlorotUniform(), nobias=True) self.l5.u = np.ones((1, 1)).astype(np.float32) if n_classes > 0: self.l_y = SNEmbedID( n_classes, ch, initialW=chainer.initializers.GlorotUniform()) seed_weights(self)
def __init__(self, init_ch=1, ch=6, activation=F.relu, dim_z=4, bottom_size=32): super(Discriminator, self).__init__() self.activation = activation initializer = chainer.initializers.GlorotUniform() with self.init_scope(): # 1x32x32 self.phi_block1 = OptimizedBlock(init_ch, ch) self.phi_block2 = Block(ch, ch * 2, activation=activation, downsample=True) self.phi_block3 = Block(ch * 2, ch * 2, activation=activation, downsample=True) # ch*2x8x8 => basically 6*2x8*8 = 768 self.enc1 = Block1(init_ch, ch, activation=activation, is_shortcut=True, dim_z=dim_z) self.enc2 = Block1(ch, ch * 2, activation=activation, is_shortcut=True, dim_z=dim_z) self.enc3 = Block1(ch * 2, ch * 2, activation=activation, is_shortcut=True, dim_z=dim_z) self.linear = L.Linear( ch * 2 * (bottom_size * bottom_size), ch * 2 * (bottom_size // 8 * bottom_size // 8)) self.l8 = SNLinear(ch * 2 * (bottom_size // 8) * (bottom_size // 8), 1, initialW=initializer)
def __init__(self, ch=128, n_classes=0, activation=F.relu): super(SRDiscriminator, self).__init__() self.activation = activation with self.init_scope(): self.block1 = OptimizedBlock(3, ch) self.block2 = Block(ch, ch, activation=activation, downsample=True) self.block3 = Block(ch, ch, activation=activation, downsample=False) self.block4 = Block(ch, ch, activation=activation, downsample=False) self.l5 = SNLinear(ch, 1, initialW=chainer.initializers.GlorotUniform(), nobias=True) if n_classes > 0: self.l_y = SNEmbedID( n_classes, ch, initialW=chainer.initializers.GlorotUniform())