tensorflow-命令行參數

from tensorflow import app
from tensorflow.python.platform import flags


FLAGS = flags.FLAGS

# yapf: disable
flags.DEFINE_integer('task', 0,
                     'The Task ID. This value is used when training with '
                     'multiple workers to identify each worker.')


flags.DEFINE_integer('save_summaries_secs', 60,
                     'The frequency with which summaries are saved, in '
                     'seconds.')


flags.DEFINE_integer('max_number_of_steps', int(1e10),
                     'The maximum number of gradient steps.')

flags.DEFINE_string('checkpoint_inception', '',
                    'Checkpoint to recover inception weights from.')

flags.DEFINE_float('clip_gradient_norm', 2.0,
                   'If greater than 0 then the gradients would be clipped by '
                   'it.')

flags.DEFINE_bool('sync_replicas', False,
                  'If True will synchronize replicas during training.')


def main(_):
    print(FLAGS.task)
    print(FLAGS.checkpoint_inception)
    print(FLAGS.clip_gradient_norm)
    print(FLAGS.sync_replicas)


if __name__ == '__main__':
    app.run()

調用

 python flags.py --checkpoint_inception=logs
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章