Ejemplo n.º 1
0
def dcgan_gen(z, hparams):

    assert hparams.batch_size in [1, 64], 'batch size should be either 64 or 1'
    z_full = tf.zeros([64, 100]) + z

    model_hparams = celebA_dcgan_model_def.Hparams()

    x_hat_full = celebA_dcgan_model_def.generator(model_hparams, z_full, train=False, reuse=False)
    x_hat_batch = tf.reshape(x_hat_full[:hparams.batch_size], [hparams.batch_size, 64*64*3])

    restore_vars = celebA_dcgan_model_def.gen_restore_vars()
    restore_dict = {var.op.name: var for var in tf.global_variables() if var.op.name in restore_vars}
    restore_path = tf.train.latest_checkpoint(hparams.pretrained_model_dir)

    return x_hat_batch, restore_dict, restore_path
Ejemplo n.º 2
0
def dcgan_gen(z, pilot, hparams):

    assert hparams.batch_size in [1, 64], 'batch size should be either 64 or 1'
    z_full = tf.zeros([64, hparams.z_dim]) + z

    pilot_full = tf.tile(pilot, [64, 1])
    z_full = tf.concat([z_full, pilot_full], 1)  # conditional

    model_hparams = celebA_dcgan_model_def.Hparams()

    x_hat_full = celebA_dcgan_model_def.generator(model_hparams,
                                                  z_full,
                                                  train=False,
                                                  reuse=False)
    x_hat_batch = x_hat_full[:hparams.batch_size]

    restore_vars = celebA_dcgan_model_def.gen_restore_vars()
    restore_dict = {
        var.op.name: var
        for var in tf.global_variables() if var.op.name in restore_vars
    }
    restore_path = tf.train.latest_checkpoint(hparams.pretrained_model_dir)

    return x_hat_batch, restore_dict, restore_path