Python model.DCGAN Examples
The following are 4
code examples of model.DCGAN().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
model
, or try the search function
.
Example #1
Source File: main.py From flow-gan with MIT License | 4 votes |
def main(_): np.random.seed(0) tf.set_random_seed(0) pp.pprint(flags.FLAGS.__flags) if FLAGS.input_width is None: FLAGS.input_width = FLAGS.input_height if not os.path.exists(FLAGS.checkpoint_dir): os.makedirs(FLAGS.checkpoint_dir) if not os.path.exists(FLAGS.sample_dir): os.makedirs(FLAGS.sample_dir) run_config = tf.ConfigProto() run_config.gpu_options.allow_growth=True run_config.allow_soft_placement=True sess = None with tf.Session(config=run_config) as sess: dcgan = DCGAN( sess, input_width=FLAGS.input_width, input_height=FLAGS.input_height, batch_size=FLAGS.batch_size, sample_num=FLAGS.batch_size, c_dim=FLAGS.c_dim, z_dim=FLAGS.c_dim * FLAGS.input_height * FLAGS.input_width, dataset_name=FLAGS.dataset, checkpoint_dir=FLAGS.checkpoint_dir, f_div=FLAGS.f_div, prior=FLAGS.prior, lr_decay=FLAGS.lr_decay, min_lr=FLAGS.min_lr, model_type=FLAGS.model_type, log_dir=FLAGS.log_dir, alpha=FLAGS.alpha, batch_norm_adaptive=FLAGS.batch_norm_adaptive, init_type=FLAGS.init_type, reg=FLAGS.reg, n_critic=FLAGS.n_critic, hidden_layers=FLAGS.hidden_layers, no_of_layers=FLAGS.no_of_layers, like_reg=FLAGS.like_reg, df_dim=FLAGS.df_dim) dcgan.train(FLAGS)
Example #2
Source File: pacgan_task.py From PacGAN with MIT License | 4 votes |
def main(self): FLAGS = Struct(**self._config) if FLAGS.input_width is None: FLAGS.input_width = FLAGS.input_height if FLAGS.output_width is None: FLAGS.output_width = FLAGS.output_height FLAGS.checkpoint_dir = os.path.join(self._work_dir, "checkpoint") if not os.path.exists(FLAGS.checkpoint_dir): os.makedirs(FLAGS.checkpoint_dir) FLAGS.sample_dir = os.path.join(self._work_dir, "samples") if not os.path.exists(FLAGS.sample_dir): os.makedirs(FLAGS.sample_dir) FLAGS.work_dir = self._work_dir #gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333) run_config = tf.ConfigProto() run_config.gpu_options.allow_growth=True if FLAGS.random: seed = random.randint(1, 100000) np.random.seed(seed) with open(os.path.join(self._work_dir, "seed.txt"), "w") as f: f.write("{}".format(seed)) t_num_test_samples = int(ceil(float(FLAGS.num_test_sample) / float(FLAGS.batch_size))) * FLAGS.batch_size test_samples = np.random.uniform(-1, 1, size = (t_num_test_samples, FLAGS.z_dim)) with tf.Session(config=run_config) as sess: dcgan = DCGAN( sess, input_width=FLAGS.input_width, input_height=FLAGS.input_height, output_width=FLAGS.output_width, output_height=FLAGS.output_height, batch_size=FLAGS.batch_size, sample_num=FLAGS.batch_size, dataset_name=FLAGS.dataset, input_fname_pattern=FLAGS.input_fname_pattern, crop=FLAGS.crop, checkpoint_dir=FLAGS.checkpoint_dir, sample_dir=FLAGS.sample_dir, packing_num=FLAGS.packing_num, num_training_sample=FLAGS.num_training_sample, num_test_sample=FLAGS.num_test_sample, z_dim=FLAGS.z_dim, test_samples=test_samples) show_all_variables() dcgan.train(FLAGS) #OPTION = 0 #visualize(sess, dcgan, FLAGS, OPTION)
Example #3
Source File: pacgan_task.py From PacGAN with MIT License | 4 votes |
def main(self): FLAGS = Struct(**self._config) if FLAGS.input_width is None: FLAGS.input_width = FLAGS.input_height if FLAGS.output_width is None: FLAGS.output_width = FLAGS.output_height FLAGS.checkpoint_dir = os.path.join(self._work_dir, "checkpoint") if not os.path.exists(FLAGS.checkpoint_dir): os.makedirs(FLAGS.checkpoint_dir) FLAGS.sample_dir = os.path.join(self._work_dir, "samples") if not os.path.exists(FLAGS.sample_dir): os.makedirs(FLAGS.sample_dir) FLAGS.work_dir = self._work_dir #gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333) run_config = tf.ConfigProto() run_config.gpu_options.allow_growth = True if FLAGS.random: seed = random.randint(1, 100000) np.random.seed(seed) with open(os.path.join(self._work_dir, "seed.txt"), "w") as f: f.write("{}".format(seed)) t_num_test_samples = int(ceil(float(FLAGS.num_test_sample) / float(FLAGS.batch_size))) * FLAGS.batch_size test_samples = np.random.normal(size = (t_num_test_samples, FLAGS.z_dim)) with tf.Session(config=run_config) as sess: dcgan = DCGAN( sess, input_width = FLAGS.input_width, input_height = FLAGS.input_height, output_width = FLAGS.output_width, output_height = FLAGS.output_height, batch_size = FLAGS.batch_size, sample_num = FLAGS.batch_size, dataset_name = FLAGS.dataset, checkpoint_dir = FLAGS.checkpoint_dir, sample_dir = FLAGS.sample_dir, packing_num = FLAGS.packing_num, num_training_sample = FLAGS.num_training_sample, num_test_sample = FLAGS.num_test_sample, z_dim = FLAGS.z_dim, test_samples = test_samples) show_all_variables() print("Start training!") dcgan.train(FLAGS)
Example #4
Source File: pacgan_task.py From PacGAN with MIT License | 4 votes |
def main(self): FLAGS = Struct(**self._config) if FLAGS.input_width is None: FLAGS.input_width = FLAGS.input_height if FLAGS.output_width is None: FLAGS.output_width = FLAGS.output_height FLAGS.checkpoint_dir = os.path.join(self._work_dir, "checkpoint") if not os.path.exists(FLAGS.checkpoint_dir): os.makedirs(FLAGS.checkpoint_dir) FLAGS.sample_dir = os.path.join(self._work_dir, "samples") if not os.path.exists(FLAGS.sample_dir): os.makedirs(FLAGS.sample_dir) FLAGS.work_dir = self._work_dir #gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.333) run_config = tf.ConfigProto() run_config.gpu_options.allow_growth = True if FLAGS.random: seed = random.randint(1, 100000) np.random.seed(seed) with open(os.path.join(self._work_dir, "seed.txt"), "w") as f: f.write("{}".format(seed)) t_num_test_samples = int(ceil(float(FLAGS.num_test_sample) / float(FLAGS.batch_size))) * FLAGS.batch_size test_samples = np.random.normal(size = (t_num_test_samples, FLAGS.z_dim)) with tf.Session(config=run_config) as sess: dcgan = DCGAN( sess, input_width=FLAGS.input_width, input_height=FLAGS.input_height, output_width=FLAGS.output_width, output_height=FLAGS.output_height, batch_size=FLAGS.batch_size, sample_num=FLAGS.batch_size, dataset_name=FLAGS.dataset, checkpoint_dir=FLAGS.checkpoint_dir, sample_dir=FLAGS.sample_dir, packing_num=FLAGS.packing_num, num_training_sample=FLAGS.num_training_sample, num_test_sample=FLAGS.num_test_sample, z_dim=FLAGS.z_dim, test_samples=test_samples) show_all_variables() print("Start training!") dcgan.train(FLAGS)