コード例 #1
0
 def __init__(self, ch):
     super(SNResFCBlock, self).__init__()
     initializer = chainer.initializers.GlorotUniform()
     with self.init_scope():
         self.l0 = SNLinear(ch, ch, initialW=initializer)
         self.l1 = SNLinear(ch, ch, initialW=initializer)
         self.bn0 = L.BatchNormalization(ch)
         self.bn1 = L.BatchNormalization(ch)
コード例 #2
0
 def __init__(self, ch=64, activation=F.relu):
     super(SNResNetDiscriminator, self).__init__()
     self.activation = activation
     initializer = chainer.initializers.GlorotUniform()
     #w = chainer.initializers.Normal(0.02)
     with self.init_scope():
         self.block1 = OptimizedBlock(3, ch)
         #self.block1 = L.Convolution2D(3, ch // 8, 1, 1, 0, initialW=w)
         self.block2 = BlockDisc(ch,
                                 ch * 2,
                                 activation=activation,
                                 downsample=True)
         self.block3 = BlockDisc(ch * 2,
                                 ch * 4,
                                 activation=activation,
                                 downsample=True)
         self.block4 = BlockDisc(ch * 4,
                                 ch * 8,
                                 activation=activation,
                                 downsample=True)
         self.block5 = BlockDisc(ch * 8,
                                 ch * 8,
                                 activation=activation,
                                 downsample=False)
         self.l6 = SNLinear(ch * 8, 1, initialW=initializer)
コード例 #3
0
ファイル: net.py プロジェクト: min9813/GAN
    def __init__(self, output_dim=1, wscale=0.02, ch=512, bottom_width=4):
        w = chainer.initializers.Normal(wscale)
        super(SNMnistDiscriminator, self).__init__()
        with self.init_scope():
            self.c0 = SNConvolution2D(1,
                                      ch // 4,
                                      ksize=4,
                                      stride=2,
                                      pad=1,
                                      initialW=w)
            self.c1 = SNConvolution2D(ch // 4,
                                      ch // 2,
                                      ksize=4,
                                      stride=2,
                                      pad=2,
                                      initialW=w)
            self.c2 = SNConvolution2D(ch // 2,
                                      ch,
                                      ksize=4,
                                      stride=2,
                                      pad=1,
                                      initialW=w)

            self.lout = SNLinear(bottom_width * bottom_width * ch,
                                 output_dim,
                                 initialW=w)
コード例 #4
0
 def __init__(self, ch=512, wscale=0.02):
     w = chainer.initializers.Normal(wscale)
     super(SNPGGANDiscriminator, self).__init__()
     with self.init_scope():
         self.in1 = SNConvolution2D(3, ch // 8, 1, 1, 0, initialW=w)
         self.b1 = SNDiscriminatorBlock(ch // 8, ch // 4, initialW=w)
         self.b2 = SNDiscriminatorBlock(ch // 4, ch // 2, initialW=w)
         self.b3 = SNDiscriminatorBlock(ch // 2, ch, initialW=w)
         self.out0 = SNConvolution2D(ch, ch, 3, 1, 1, initialW=w)
         self.out1 = SNConvolution2D(ch, ch, 4, 1, 0, initialW=w)
         self.out2 = SNLinear(ch, 1, initialW=w)
コード例 #5
0
ファイル: resnet.py プロジェクト: yasinyazici/EMA_GAN
 def __init__(self, ch=64, activation=F.relu):
     super(Discriminator48, self).__init__()
     self.activation = activation
     initializer = chainer.initializers.GlorotUniform()
     with self.init_scope():
         self.block1 = OptimizedBlock(3, ch * 1)
         self.block2 = DiscriminatorBlock(ch * 1, ch * 2, activation=activation, downsample=True)
         self.block3 = DiscriminatorBlock(ch * 2, ch * 4, activation=activation, downsample=True)
         self.block4 = DiscriminatorBlock(ch * 4, ch * 8, activation=activation, downsample=True)
         self.block5 = DiscriminatorBlock(ch * 8, ch * 16, activation=activation, downsample=False)
         self.l5 = SNLinear(ch * 16, 1, initialW=initializer)
コード例 #6
0
 def __init__(self, bottom_width=8, ch=128, ouput_dim=1):
     w = chainer.initializers.HeNormal()
     super(SNResnetDiscriminator, self).__init__()
     self.bottom_width = bottom_width
     self.ch = ch
     with self.init_scope():
         self.r0 = SNOptimizedResBlock1(128)
         self.r1 = SNDownResBlock2(128)
         self.r2 = SNResBlock3(128)
         self.r3 = SNResBlock3(128)
         self.l4 = SNLinear(bottom_width * bottom_width * ch, ouput_dim, initialW=w)
コード例 #7
0
ファイル: resnet.py プロジェクト: yasinyazici/EMA_GAN
 def __init__(self, ch=64, activation=F.relu,sn=True):
     super(Discriminator32, self).__init__()
     self.activation = activation
     initializer = chainer.initializers.GlorotUniform()
     with self.init_scope():
         self.block1 = OptimizedBlock(3, ch*2,sn=sn)
         self.block2 = DiscriminatorBlock(ch * 2, ch * 2, activation=activation, downsample=True,sn=sn)
         self.block3 = DiscriminatorBlock(ch * 2, ch * 2, activation=activation, downsample=False,sn=sn)
         self.block4 = DiscriminatorBlock(ch * 2, ch * 2, activation=activation, downsample=False,sn=sn)
         if sn:
             self.l5 = SNLinear(ch * 2, 1, initialW=initializer)
         else:
             self.l5 = L.Linear(ch * 2, 1, initialW=initializer)
コード例 #8
0
 def __init__(self, bottom_width=4, ch=512, wscale=0.02, output_dim=1):
     w = chainer.initializers.Normal(wscale)
     super(SNDCGANDiscriminator, self).__init__()
     with self.init_scope():
         self.c0_0 = SNConvolution2D(3, ch // 8, 3, 1, 1, initialW=w)
         self.c0_1 = SNConvolution2D(ch // 8, ch // 4, 4, 2, 1, initialW=w)
         self.c1_0 = SNConvolution2D(ch // 4, ch // 4, 3, 1, 1, initialW=w)
         self.c1_1 = SNConvolution2D(ch // 4, ch // 2, 4, 2, 1, initialW=w)
         self.c2_0 = SNConvolution2D(ch // 2, ch // 2, 3, 1, 1, initialW=w)
         self.c2_1 = SNConvolution2D(ch // 2, ch // 1, 4, 2, 1, initialW=w)
         self.c3_0 = SNConvolution2D(ch // 1, ch // 1, 3, 1, 1, initialW=w)
         self.l4 = SNLinear(bottom_width * bottom_width * ch,
                            output_dim,
                            initialW=w)
コード例 #9
0
    def __init__(self, ch=512, wscale=0.02, sn=True):
        super(Discriminator32, self).__init__()
        w = chainer.initializers.Normal(wscale)
        with self.init_scope():
            if sn:
                print('sn')
                self.in_ = SNConvolution2D(3, ch // 8, 1, 1, 0, initialW=w)
            else:
                print('sn_free')
                self.in_ = L.Convolution2D(3, ch // 8, 1, 1, 0, initialW=w)

            self.b3 = DiscriminatorBlock(ch // 8, ch // 4, initialW=w, sn=sn)
            self.b2 = DiscriminatorBlock(ch // 4, ch // 2, initialW=w, sn=sn)
            self.b1 = DiscriminatorBlock(ch // 2, ch, initialW=w, sn=sn)

            if sn:
                self.out0 = SNConvolution2D(ch, ch, 3, 1, 1, initialW=w)
                self.out1 = SNConvolution2D(ch, ch, 4, 1, 0, initialW=w)
                self.out2 = SNLinear(ch, 1, initialW=w)
            else:
                self.out0 = L.Convolution2D(ch, ch, 3, 1, 1, initialW=w)
                self.out1 = L.Convolution2D(ch, ch, 4, 1, 0, initialW=w)
                self.out2 = L.Linear(ch, 1, initialW=w)