예제 #1
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
예제 #2
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
예제 #3
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
예제 #4
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