def setup_tensorflow():
# Create session
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=FLAGS.gpu_fraction)
config = tf.ConfigProto(log_device_placement=FLAGS.log_device_placement, gpu_options=gpu_options)
sess = tf.Session(config=config)
# Initialize rng with a deterministic seed
with sess.graph.as_default():
tf.set_random_seed(FLAGS.random_seed)
random.seed(FLAGS.random_seed)
np.random.seed(FLAGS.random_seed)
summary_writer = tf.summary.FileWriter(FLAGS.train_dir, sess.graph)
return sess, summary_writer
评论列表
文章目录