Example #1
0
    def __init__(self, in_ch, out_ch):
        super(GeneratorBlock, self).__init__()
        self.out_ch = out_ch
        irelu = chainer.initializers.HeNormal(scale=1.0)

        with self.init_scope():
            self.c0 = EqualizedConvolution2d(in_ch,
                                             out_ch,
                                             3,
                                             1,
                                             1,
                                             initialW=irelu)
            self.c1 = EqualizedConvolution2d(out_ch,
                                             out_ch,
                                             3,
                                             1,
                                             1,
                                             initialW=irelu)
Example #2
0
    def __init__(self, in_ch, out_ch):
        super(DiscriminatorBlock, self).__init__()
        #self.pooling_comp = pooling_comp
        self.out_ch = out_ch
        irelu = chainer.initializers.HeNormal(scale=1.0)

        with self.init_scope():
            self.c0 = EqualizedConvolution2d(in_ch,
                                             in_ch,
                                             3,
                                             1,
                                             1,
                                             initialW=irelu)
            self.c1 = EqualizedConvolution2d(in_ch,
                                             out_ch,
                                             3,
                                             1,
                                             1,
                                             initialW=irelu)
Example #3
0
    def __init__(self, max_stage=12):
        super(Discriminator, self).__init__()
        self.max_stage = max_stage
        #self.pooling_comp = pooling_comp # compensation of ave_pool is 0.5-Lipshitz

        self.R = (16, 32, 64, 128, 128, 128, 128, 128)
        irelu = chainer.initializers.HeNormal(scale=1.0)
        ilinear = chainer.initializers.HeNormal(scale=1.0 / np.sqrt(2))
        with self.init_scope():
            self.in7 = EqualizedConvolution2d(3,
                                              self.R[0],
                                              1,
                                              1,
                                              0,
                                              initialW=irelu)
            self.b7 = DiscriminatorBlock(self.R[0], self.R[1])
            self.in6 = EqualizedConvolution2d(3,
                                              self.R[1],
                                              1,
                                              1,
                                              0,
                                              initialW=irelu)
            self.b6 = DiscriminatorBlock(self.R[1], self.R[2])
            self.in5 = EqualizedConvolution2d(3,
                                              self.R[2],
                                              1,
                                              1,
                                              0,
                                              initialW=irelu)
            self.b5 = DiscriminatorBlock(self.R[2], self.R[3])
            self.in4 = EqualizedConvolution2d(3,
                                              self.R[3],
                                              1,
                                              1,
                                              0,
                                              initialW=irelu)
            self.b4 = DiscriminatorBlock(self.R[3], self.R[4])
            self.in3 = EqualizedConvolution2d(3,
                                              self.R[4],
                                              1,
                                              1,
                                              0,
                                              initialW=irelu)
            self.b3 = DiscriminatorBlock(self.R[4], self.R[5])
            self.in2 = EqualizedConvolution2d(3,
                                              self.R[5],
                                              1,
                                              1,
                                              0,
                                              initialW=irelu)
            self.b2 = DiscriminatorBlock(self.R[5], self.R[6])
            self.in1 = EqualizedConvolution2d(3,
                                              self.R[6],
                                              1,
                                              1,
                                              0,
                                              initialW=irelu)
            self.b1 = DiscriminatorBlock(self.R[6], self.R[7])
            self.in0 = EqualizedConvolution2d(3,
                                              self.R[7],
                                              1,
                                              1,
                                              0,
                                              initialW=irelu)

            self.out0 = EqualizedConvolution2d(self.R[7] + 1,
                                               self.R[7],
                                               3,
                                               1,
                                               1,
                                               initialW=irelu)
            self.out1 = EqualizedConvolution2d(self.R[7],
                                               self.R[7],
                                               4,
                                               1,
                                               0,
                                               initialW=irelu)
            self.out2 = EqualizedLinear(self.R[7], 1, initialW=ilinear)
Example #4
0
    def __init__(self, n_hidden=512, max_stage=12):
        super(Generator, self).__init__()
        self.n_hidden = n_hidden
        self.R = (128, 128, 128, 128, 128, 64, 32, 16)
        self.max_stage = max_stage
        irelu = chainer.initializers.HeNormal(scale=1.0)
        ilinear = chainer.initializers.HeNormal(scale=1.0 / np.sqrt(2))
        with self.init_scope():

            self.c0 = EqualizedConvolution2d(n_hidden,
                                             self.R[0],
                                             4,
                                             1,
                                             3,
                                             initialW=irelu)
            self.c1 = EqualizedConvolution2d(self.R[0],
                                             self.R[0],
                                             3,
                                             1,
                                             1,
                                             initialW=irelu)
            self.out0 = EqualizedConvolution2d(self.R[0],
                                               3,
                                               1,
                                               1,
                                               0,
                                               initialW=ilinear)
            self.b1 = GeneratorBlock(self.R[0], self.R[1])
            self.out1 = EqualizedConvolution2d(self.R[1],
                                               3,
                                               1,
                                               1,
                                               0,
                                               initialW=ilinear)
            self.b2 = GeneratorBlock(self.R[1], self.R[2])
            self.out2 = EqualizedConvolution2d(self.R[2],
                                               3,
                                               1,
                                               1,
                                               0,
                                               initialW=ilinear)
            self.b3 = GeneratorBlock(self.R[2], self.R[3])
            self.out3 = EqualizedConvolution2d(self.R[3],
                                               3,
                                               1,
                                               1,
                                               0,
                                               initialW=ilinear)
            self.b4 = GeneratorBlock(self.R[3], self.R[4])
            self.out4 = EqualizedConvolution2d(self.R[4],
                                               3,
                                               1,
                                               1,
                                               0,
                                               initialW=ilinear)
            self.b5 = GeneratorBlock(self.R[4], self.R[5])
            self.out5 = EqualizedConvolution2d(self.R[5],
                                               3,
                                               1,
                                               1,
                                               0,
                                               initialW=ilinear)
            self.b6 = GeneratorBlock(self.R[5], self.R[6])
            self.out6 = EqualizedConvolution2d(self.R[6],
                                               3,
                                               1,
                                               1,
                                               0,
                                               initialW=ilinear)
            self.b7 = GeneratorBlock(self.R[6], self.R[7])
            self.out7 = EqualizedConvolution2d(self.R[7],
                                               3,
                                               1,
                                               1,
                                               0,
                                               initialW=ilinear)