本文整理汇总了Python中utils.pp.pprint方法的典型用法代码示例。如果您正苦于以下问题:Python pp.pprint方法的具体用法?Python pp.pprint怎么用?Python pp.pprint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.pp
的用法示例。
在下文中一共展示了pp.pprint方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from utils import pp [as 别名]
# 或者: from utils.pp import pprint [as 别名]
def main(_):
pp.pprint(flags.FLAGS.__flags)
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)
gpu_options = tf.GPUOptions(
per_process_gpu_memory_fraction=FLAGS.gpu_frac)
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
with tf.Session(config = tf.ConfigProto(gpu_options=gpu_options)) as sess:
dcgan = ECGAN(sess)
dcgan.train()
示例2: main
# 需要导入模块: from utils import pp [as 别名]
# 或者: from utils.pp import pprint [as 别名]
def main(_):
pp.pprint(flags.FLAGS.__flags)
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)
gpu_options = tf.GPUOptions(
per_process_gpu_memory_fraction=FLAGS.gpu_frac)
with tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) as sess:
# with tf.Session() as sess:
dcgan = ECGAN(sess)
dcgan.temporal_consistency()
示例3: main
# 需要导入模块: from utils import pp [as 别名]
# 或者: from utils.pp import pprint [as 别名]
def main(_):
pp.pprint(flags.FLAGS.__flags)
if not os.path.exists(FLAGS.checkpoint_dir):
os.makedirs(FLAGS.checkpoint_dir)
Analogy = model_dict[FLAGS.dataset]
with tf.Session() as sess:
analogy = Analogy(sess, image_size=FLAGS.image_size, model_type=FLAGS.model_type,
batch_size=FLAGS.batch_size, dataset=FLAGS.dataset)
if FLAGS.is_train:
analogy.train(max_iter=FLAGS.max_iter, alpha=FLAGS.alpha,
learning_rate=FLAGS.learning_rate, checkpoint_dir=FLAGS.checkpoint_dir)
else:
analogy.load(FLAGS.checkpoint_dir)
analogy.test()
示例4: main
# 需要导入模块: from utils import pp [as 别名]
# 或者: from utils.pp import pprint [as 别名]
def main(_):
pp.pprint(flags.FLAGS.__flags)
config = Config(FLAGS)
config.print_config()
config.make_dirs()
config_proto = tf.ConfigProto(allow_soft_placement=FLAGS.is_train, log_device_placement=False)
config_proto.gpu_options.allow_growth = True
with tf.Session(config=config_proto) as sess:
model = globals()[FLAGS.model](config)
if not FLAGS.is_train:
test_generation(model, sess)
else:
train(model, sess)
示例5: main
# 需要导入模块: from utils import pp [as 别名]
# 或者: from utils.pp import pprint [as 别名]
def main(_):
pp.pprint(flags.FLAGS.__flags)
data_path = "./data/%s" % FLAGS.dataset
reader = TextReader(data_path)
with tf.Session() as sess:
m = MODELS[FLAGS.model]
model = m(sess, reader, dataset=FLAGS.dataset,
embed_dim=FLAGS.embed_dim, h_dim=FLAGS.h_dim,
learning_rate=FLAGS.learning_rate, max_iter=FLAGS.max_iter,
checkpoint_dir=FLAGS.checkpoint_dir)
if FLAGS.forward_only:
model.load(FLAGS.checkpoint_dir)
else:
model.train(FLAGS)
while True:
text = raw_input(" [*] Enter text to test: ")
model.sample(5, text)
示例6: main
# 需要导入模块: from utils import pp [as 别名]
# 或者: from utils.pp import pprint [as 别名]
def main(_):
pp.pprint(flags.FLAGS.__flags)
sample_dir_ = os.path.join(FLAGS.sample_dir, FLAGS.name)
checkpoint_dir_ = os.path.join(FLAGS.checkpoint_dir, FLAGS.name)
log_dir_ = os.path.join(FLAGS.log_dir, FLAGS.name)
if not os.path.exists(checkpoint_dir_):
os.makedirs(checkpoint_dir_)
if not os.path.exists(sample_dir_):
os.makedirs(sample_dir_)
if not os.path.exists(log_dir_):
os.makedirs(log_dir_)
with tf.Session() as sess:
if FLAGS.dataset == 'mnist':
dcgan = DCGAN(sess, config=FLAGS, batch_size=FLAGS.batch_size, output_size=28, c_dim=1,
dataset_name=FLAGS.dataset, is_crop=FLAGS.is_crop, checkpoint_dir=checkpoint_dir_, sample_dir=sample_dir_, log_dir=log_dir_)
else:
dcgan = DCGAN(sess, image_size=FLAGS.image_size, batch_size=FLAGS.batch_size, output_size=FLAGS.output_size, c_dim=FLAGS.c_dim,
dataset_name=FLAGS.dataset, is_crop=FLAGS.is_crop, checkpoint_dir=FLAGS.checkpoint_dir, sample_dir=FLAGS.sample_dir)
if FLAGS.is_train:
dcgan.train(FLAGS)
else:
dcgan.sampling(FLAGS)
if FLAGS.visualize:
to_json("./web/js/layers.js", [dcgan.h0_w, dcgan.h0_b, dcgan.g_bn0],
[dcgan.h1_w, dcgan.h1_b, dcgan.g_bn1],
[dcgan.h2_w, dcgan.h2_b, dcgan.g_bn2],
[dcgan.h3_w, dcgan.h3_b, dcgan.g_bn3],
[dcgan.h4_w, dcgan.h4_b, None])
# Below is codes for visualization
OPTION = 2
visualize(sess, dcgan, FLAGS, OPTION)
示例7: main
# 需要导入模块: from utils import pp [as 别名]
# 或者: from utils.pp import pprint [as 别名]
def main(_):
pp.pprint(flags.FLAGS.__flags)
sample_dir_ = os.path.join(FLAGS.sample_dir, FLAGS.name)
checkpoint_dir_ = os.path.join(FLAGS.checkpoint_dir, FLAGS.name)
log_dir_ = os.path.join(FLAGS.log_dir, FLAGS.name)
if not os.path.exists(checkpoint_dir_):
os.makedirs(checkpoint_dir_)
if not os.path.exists(sample_dir_):
os.makedirs(sample_dir_)
if not os.path.exists(log_dir_):
os.makedirs(log_dir_)
with tf.Session() as sess:
if FLAGS.dataset == 'mnist':
dcgan = DCGAN(sess, config=FLAGS, batch_size=FLAGS.batch_size, output_size=28, c_dim=1,
dataset_name=FLAGS.dataset, is_crop=FLAGS.is_crop, checkpoint_dir=checkpoint_dir_, sample_dir=sample_dir_, log_dir=log_dir_)
else:
dcgan = DCGAN(sess, image_size=FLAGS.image_size, batch_size=FLAGS.batch_size, output_size=FLAGS.output_size, c_dim=FLAGS.c_dim,
dataset_name=FLAGS.dataset, is_crop=FLAGS.is_crop, checkpoint_dir=FLAGS.checkpoint_dir, sample_dir=FLAGS.sample_dir)
if FLAGS.is_train:
dcgan.train(FLAGS)
else:
dcgan.sampling(FLAGS)
#dcgan.load(FLAGS.checkpoint_dir)
if FLAGS.visualize:
to_json("./web/js/layers.js", [dcgan.h0_w, dcgan.h0_b, dcgan.g_bn0],
[dcgan.h1_w, dcgan.h1_b, dcgan.g_bn1],
[dcgan.h2_w, dcgan.h2_b, dcgan.g_bn2],
[dcgan.h3_w, dcgan.h3_b, dcgan.g_bn3],
[dcgan.h4_w, dcgan.h4_b, None])
# Below is codes for visualization
OPTION = 2
visualize(sess, dcgan, FLAGS, OPTION)
示例8: main
# 需要导入模块: from utils import pp [as 别名]
# 或者: from utils.pp import pprint [as 别名]
def main(_):
#pp.pprint(FLAGS.__flags)
pp.pprint(tf.app.flags.FLAGS.flag_values_dict())
if not os.path.exists(FLAGS.checkpoint_dir):
os.makedirs(FLAGS.checkpoint_dir)
if not os.path.exists(FLAGS.samples_dir):
os.makedirs(FLAGS.samples_dir)
gpu_options = tf.GPUOptions(visible_device_list =FLAGS.gpu, per_process_gpu_memory_fraction = 0.8, allow_growth = True)
with tf.Session(config=tf.ConfigProto(allow_soft_placement=True, log_device_placement=False, gpu_options=gpu_options)) as sess:
dcgan = DCGAN(sess, FLAGS)
if FLAGS.is_train:
dcgan.train(FLAGS)
else:
dcgan.load(FLAGS.checkpoint_dir)
dcgan.test(FLAGS, True)
'''
if FLAGS.visualize:
to_json("./web/js/layers.js", [dcgan.h0_w, dcgan.h0_b, dcgan.g_bn0],
[dcgan.h1_w, dcgan.h1_b, dcgan.g_bn1],
[dcgan.h2_w, dcgan.h2_b, dcgan.g_bn2],
[dcgan.h3_w, dcgan.h3_b, dcgan.g_bn3],
[dcgan.h4_w, dcgan.h4_b, None])
# Below is codes for visualization
OPTION = 2
visualize(sess, dcgan, FLAGS, OPTION)'''
示例9: main
# 需要导入模块: from utils import pp [as 别名]
# 或者: from utils.pp import pprint [as 别名]
def main(_):
pp.pprint(flags.FLAGS.__flags)
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)
gpu_options = tf.GPUOptions(
per_process_gpu_memory_fraction=FLAGS.gpu_frac)
with tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) as sess:
dcgan = ECGAN(sess)
dcgan.complete()
示例10: main
# 需要导入模块: from utils import pp [as 别名]
# 或者: from utils.pp import pprint [as 别名]
def main(_):
pp.pprint(flags.FLAGS.__flags)
if not os.path.exists(FLAGS.checkpoint_dir):
print(" [*] Creating checkpoint directory...")
os.makedirs(FLAGS.checkpoint_dir)
with tf.Session() as sess:
model = model_dict[FLAGS.model](sess, checkpoint_dir=FLAGS.checkpoint_dir,
seq_length=FLAGS.seq_length,
word_embed_dim=FLAGS.word_embed_dim,
char_embed_dim=FLAGS.char_embed_dim,
feature_maps=eval(FLAGS.feature_maps),
kernels=eval(FLAGS.kernels),
batch_size=FLAGS.batch_size,
dropout_prob=FLAGS.dropout_prob,
max_word_length=FLAGS.max_word_length,
forward_only=FLAGS.forward_only,
dataset_name=FLAGS.dataset,
use_char=FLAGS.use_char,
use_word=FLAGS.use_word,
data_dir=FLAGS.data_dir)
if not FLAGS.forward_only:
model.run(FLAGS.epoch, FLAGS.learning_rate, FLAGS.decay)
else:
test_loss = model.test(2)
print(" [*] Test loss: %2.6f, perplexity: %2.6f" % (test_loss, np.exp(test_loss)))
示例11: main
# 需要导入模块: from utils import pp [as 别名]
# 或者: from utils.pp import pprint [as 别名]
def main(_):
pp.pprint(flags.FLAGS.__flags)
if FLAGS.input_width is None:
FLAGS.input_width = FLAGS.input_height
if FLAGS.output_width is None:
FLAGS.output_width = FLAGS.output_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
with tf.Session(config=run_config) as sess:
wgan = WGAN(
sess,
input_width=FLAGS.input_width,
input_height=FLAGS.input_height,
input_water_width=FLAGS.input_water_width,
input_water_height=FLAGS.input_water_height,
output_width=FLAGS.output_width,
output_height=FLAGS.output_height,
batch_size=FLAGS.batch_size,
c_dim=FLAGS.c_dim,
max_depth = FLAGS.max_depth,
save_epoch=FLAGS.save_epoch,
water_dataset_name=FLAGS.water_dataset,
air_dataset_name = FLAGS.air_dataset,
depth_dataset_name = FLAGS.depth_dataset,
input_fname_pattern=FLAGS.input_fname_pattern,
is_crop=FLAGS.is_crop,
checkpoint_dir=FLAGS.checkpoint_dir,
results_dir = FLAGS.results_dir,
sample_dir=FLAGS.sample_dir,
num_samples = FLAGS.num_samples)
if FLAGS.is_train:
wgan.train(FLAGS)
else:
if not wgan.load(FLAGS.checkpoint_dir):
raise Exception("[!] Train a model first, then run test mode")
wgan.test(FLAGS)
# to_json("./web/js/layers.js", [wgan.h0_w, wgan.h0_b, wgan.g_bn0],
# [wgan.h1_w, wgan.h1_b, wgan.g_bn1],
# [wgan.h2_w, wgan.h2_b, wgan.g_bn2],
# [wgan.h3_w, wgan.h3_b, wgan.g_bn3],
# [wgan.h4_w, wgan.h4_b, None])
# Below is codes for visualization
#OPTION = 1
#visualize(sess, wgan, FLAGS, OPTION)
示例12: main
# 需要导入模块: from utils import pp [as 别名]
# 或者: from utils.pp import pprint [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)
示例13: main
# 需要导入模块: from utils import pp [as 别名]
# 或者: from utils.pp import pprint [as 别名]
def main(_):
pp.pprint(flags.FLAGS.__flags)
# run_config = tf.ConfigProto()
# run_config.gpu_options.allow_growth=True
# with tf.Session(config=run_config) as sess:
with tf.Session() as sess:
wgan = WGAN(sess,
input_height=FLAGS.input_height,
input_width=FLAGS.input_width,
crop=FLAGS.crop,
batch_size=FLAGS.batch_size,
output_height=FLAGS.output_height,
output_width=FLAGS.output_width,
z_dim=FLAGS.z_dim,
g_dim=FLAGS.g_dim,
d_dim=FLAGS.d_dim,
dataset_name=FLAGS.dataset,
input_fname_pattern=FLAGS.data_pattern,
log_dir=FLAGS.log_dir,
sample_dir=FLAGS.sample_dir,
max_epoch=FLAGS.max_epoch,
n_critic=FLAGS.n_critic,
lr=FLAGS.learning_rate,
beta1=FLAGS.beta1,
beta2=FLAGS.beta2)
show_all_variables()
if FLAGS.train:
wgan.train()
else:
if not wgan.load(FLAGS.log_dir):
raise Exception("[!] Train a model first, then run test mode")
if FLAGS.forward_test:
forward_test(sess,wgan,FLAGS, FLAGS.test_num)
OPTION = 1
visualize(sess,wgan, FLAGS, OPTION)