Esempio n. 1
0
    def _construct_decoder(self):
        """
        CNN decoder.
        """
        z = Input(shape=(self.latent_dim,))
        z0 = Dense(self.hidden_dim)(z)
        z_reshp = Reshape((1, 1, self.hidden_dim))(z0)
        z1 = bn_deconv_layer(z_reshp, 256, 4, 4)
        z2 = bn_deconv_layer(z1, 128, 4, 2)
        z3 = bn_deconv_layer(z2, 64, 4, 2)
        z4 = bn_deconv_layer(z3, 32, 4, 2)
        gen_img = bn_deconv_layer(z4, self.img_dim[-1], 4, 2,
                                  activation='sigmoid',
                                  batchnorm=False)

        decoder = Model(z, gen_img)
        return decoder
Esempio n. 2
0
    def _construct_generator(self):
        z = Input(shape=(self.in_dim, ))
        # z0 = bn_dense(z, self.g_hidden * 64 * 4 * 4, 'selu')
        z0 = Reshape((1, 1, self.in_dim))(z)
        z1 = bn_deconv_layer(z0,
                             16 * self.g_hidden,
                             4,
                             4,
                             activation='selu',
                             batchnorm=False)
        # z2 = bn_deconv_layer(
        #     z1, 32 * self.g_hidden, 4, 2, activation='selu', batchnorm=False)
        # z3 = bn_deconv_layer(
        #     z1, 16 * self.g_hidden, 4, 2, activation='selu', batchnorm=False)
        z4 = bn_deconv_layer(z1,
                             8 * self.g_hidden,
                             4,
                             2,
                             activation='selu',
                             batchnorm=False)
        z5 = bn_deconv_layer(z4,
                             4 * self.g_hidden,
                             4,
                             2,
                             activation='selu',
                             batchnorm=False)
        z6 = bn_deconv_layer(z5,
                             2 * self.g_hidden,
                             4,
                             2,
                             activation='selu',
                             batchnorm=False)
        gen_img = bn_deconv_layer(z6,
                                  self.img_dim[-1],
                                  4,
                                  2,
                                  activation='sigmoid',
                                  batchnorm=False)

        generator = Model(z, gen_img)
        # generator.compile(optimizer=self.critic_opt(lr=self.critic_lr),
        #                   loss='binary_crossentropy')
        return generator
Esempio n. 3
0
    def _construct_decoder(self):
        """
        CNN decoder.
        """
        z = Input(shape=(self.latent_dim, ))
        z0 = Dense(self.hidden_dim)(z)
        deconv_block = deconvnet(z0, self.img_dim, self.dec_param, bias=False)
        gen_img = bn_deconv_layer(deconv_block,
                                  self.img_dim[-1],
                                  4,
                                  2,
                                  activation='sigmoid',
                                  batchnorm=False)

        decoder = Model(z, gen_img)
        return decoder
Esempio n. 4
0
    def _construct_generator(self):
        z = Input(shape=(self.in_dim, ))
        z0 = Reshape((1, 1, self.in_dim))(z)
        deconv_block = deconvnet(z0, self.img_dim, self.g_hidden, bias=False)
        gen_img = bn_deconv_layer(deconv_block,
                                  self.img_dim[-1],
                                  4,
                                  2,
                                  activation='sigmoid',
                                  batchnorm=False,
                                  use_bias=False)

        generator = Model(z, gen_img)
        generator.compile(
            optimizer=self.critic_opt(lr=self.critic_lr),
            # loss='binary_crossentropy')
            loss='mse')
        return generator
Esempio n. 5
0
    def _construct_imggen(self):
        """
        CNN decoder/generator.

        The decoder and generator share structure but do NOT share weights.
        """
        z = Input(shape=(self.latent_dim, ))
        z0 = Dense(512)(z)
        deconv_block = deconvnet(z0,
                                 self.img_dim,
                                 self.dec_param,
                                 activation='elu')
        gen_img = bn_deconv_layer(deconv_block,
                                  self.img_dim[-1],
                                  4,
                                  2,
                                  activation='sigmoid',
                                  batchnorm=False)

        generator = Model(z, gen_img)
        return generator
Esempio n. 6
0
    def _construct_generator(self):
        z = Input(shape=(self.in_dim, ))
        z1 = bn_dense(z, 512)
        z_reshp = Reshape((1, 1, 512))(z1)
        deconv_block = deconvnet(z_reshp,
                                 self.img_dim,
                                 self.g_hidden,
                                 activation='selu',
                                 batchnorm=True,
                                 bias=False)
        gen_img = bn_deconv_layer(deconv_block,
                                  self.img_dim[-1],
                                  4,
                                  2,
                                  activation='tanh',
                                  batchnorm=False,
                                  use_bias=False)

        generator = Model(z, gen_img)
        # generator.compile(optimizer=self.critic_opt(lr=self.critic_lr),
        #                   loss='mse')
        return generator