tensorflow 使用flags定义命令行参数的方法

tf定义了tf.app.flags,用于支持接受命令行传递参数,相当于接受argv。

FLAGS = tf.app.flags.FLAGS
#第一个参数是参数名称,第二个是参数默认值,第三个是参数描述
tf.app.flags.DEFINE_string(
    'dataset_name', 'pascalvoc',
    'The name of the dataset to convert.')
tf.app.flags.DEFINE_string(
    'dataset_dir', None,
    'Directory where the original dataset is stored.')
tf.app.flags.DEFINE_string(
    'output_name', 'pascalvoc',
    'Basename used for TFRecords output files.')
tf.app.flags.DEFINE_string(
    'output_dir', './',
    'Output directory where to store TFRecords files.')

在命令行中使用的方式:

python  tf_convert_data.py     \
    --dataset_name=pascalvoc    \
    --dataset_dir=./voc2007/     \
    --output_name=voc_2007_train \
    --output_dir=./records

猜你喜欢

转载自blog.csdn.net/yzy__zju/article/details/84668300
今日推荐