def __init__(self, input_shape, latent_space_dim, have_2nd_density_est,
                 log_dir, sec_stg_beta):
        self.log_dir = log_dir
        self.latent_space_dim = latent_space_dim
        self.have_2nd_density_est = have_2nd_density_est
        self.sec_stg_beta = sec_stg_beta
        with tf.name_scope('Encoder'):
            e_in = Input(shape=input_shape)
            x = Dense(1024, activation='relu')(e_in)
            x = Dense(1024, activation='relu')(x)
            z = Dense(latent_space_dim, activation='linear')(x)
            encoder = Model(inputs=e_in, outputs=z)

            layer_for_z_sigma = Dense(latent_space_dim, activation='tanh')

        with tf.name_scope('Decoder'):
            d_in = Input(shape=(latent_space_dim, ))
            x = Dense(1024, activation='relu')(d_in)
            x = Dense(1024, activation='relu')(x)
            d_out = Dense(input_shape[0], activation='linear')(x)
            decoder = Model(inputs=d_in, outputs=d_out)

        self.encoder, self.decoder, self.auto_encoder = get_vae_given_enc_dec.get_vae(
            encoder,
            decoder,
            embeding_loss_weight=self.sec_stg_beta,
            layer_for_z_sigma=layer_for_z_sigma,
            recon_loss_func=mean_squared_error,
            constant_sigma=None)
Example #2
0
def get_vae_mnist(input_shape, bottleneck_size, embeding_loss_weight, generator_regs, generator_reg_types,
                  include_batch_norm, num_filter, spec_norm_dec_only, recon_loss_func, constant_sigma):
    encoder, decoder, _ = rae_mnist.get_vae_mnist(input_shape, bottleneck_size, embeding_loss_weight,
                                                  generator_regs, generator_reg_types,
                                                  include_batch_norm, num_filter, spec_norm_dec_only,
                                                  recon_loss_func=recon_loss_func, verbose=False)
    layer_for_z_sigma = Dense(bottleneck_size, activation='tanh', name='log_sigma')
    return get_vae_given_enc_dec.get_vae(encoder, decoder, embeding_loss_weight, layer_for_z_sigma, recon_loss_func,
                                         constant_sigma)
def build_vae_cifar(encoder, decoder, embeding_loss_weight, recon_loss_func,
                    constant_sigma):

    bottleneck_size = K.get_variable_shape(encoder.outputs[0])[-1]
    layer_for_z_sigma = Dense(bottleneck_size,
                              activation='tanh',
                              name='log_sigma')
    return get_vae_given_enc_dec.get_vae(encoder, decoder,
                                         embeding_loss_weight,
                                         layer_for_z_sigma, recon_loss_func,
                                         constant_sigma)
def get_vae_svhn(input_shape, embeding_loss_weight, generator_regs,
                 generator_reg_types, include_batch_norm, spec_norm_dec_only,
                 recon_loss_func):
    encoder, decoder, _ = rae_svhn.get_vae_svhn_wae_architecture(
        input_shape,
        embeding_loss_weight,
        generator_regs,
        generator_reg_types,
        include_batch_norm,
        spec_norm_dec_only,
        recon_loss_func=recon_loss_func,
        verbose=False)
    bottleneck_size = K.get_variable_shape(encoder.outputs[0])[-1]
    layer_for_z_sigma = Dense(bottleneck_size,
                              activation='tanh',
                              name='log_sigma')
    return get_vae_given_enc_dec.get_vae(encoder, decoder,
                                         embeding_loss_weight,
                                         layer_for_z_sigma, recon_loss_func)