tensorflow命令行参数
源码github上已经给出:
https://github.com/abseil/abseil-py/blob/master/absl/flags/_defines.py#L319
以下是写的demo:
import tensorflow as tf
flags = tf.app.flags
FLAGS = flags.FLAGS
# Settings for some training parameters.
flags.DEFINE_enum('learning_policy', 'poly', ['poly', 'step'], 'Learning rate policy for training.')
flags.DEFINE_float('learning_rate', 0.005, 'The base learning rate for model training')
flags.DEFINE_integer('learning_rate_decay_step', 20000, 'Decay the base learning rate at a fixed step')
flags.DEFINE_multi_integer('train_crop_size',[32,32],'Image crop size [height,width] during traing')
flags.DEFINE_string('dataset', 'test_dataset', 'Name of the test name')
flags.DEFINE_boolean('dow_sample_logits', True, 'downsample logits during training')
def main(_):
print(FLAGS.learning_policy)
print(FLAGS.base_learning_rate)
print(FLAGS.learning_rate_decay_step)
print(FLAGS.train_crop_size)
print(FLAGS.dataset)
print(FLAGS.down_sample_logits)
if __name__ == '__main__':
tf.app.run()
结果:
poly
0.001
20000
[32, 32]
test_dataset
True