本文整理汇总了Python中model.DCGAN属性的典型用法代码示例。如果您正苦于以下问题:Python model.DCGAN属性的具体用法?Python model.DCGAN怎么用?Python model.DCGAN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类model
的用法示例。
在下文中一共展示了model.DCGAN属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import model [as 别名]
# 或者: from model import DCGAN [as 别名]
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)
示例2: main
# 需要导入模块: import model [as 别名]
# 或者: from model import DCGAN [as 别名]
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)
示例3: main
# 需要导入模块: import model [as 别名]
# 或者: from model import DCGAN [as 别名]
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)
示例4: main
# 需要导入模块: import model [as 别名]
# 或者: from model import DCGAN [as 别名]
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)