tf.flags.DEFINE解释

tf.flags.DEFINE_xxx()

最近在Bert代码中,看到了tf.flags.DEFINE的代码,不知道是什么含义,于是找到了一些资料。具体如下:
flags = tf.flags
FLAGS = flags.FLAGS
flags.DEFINE_xxx()
FLAGS.parse_flags()

函数意义

利用该函数,可以实现在命令行中设置需要设定的参数来运行程序。
这样的话,就可以不用在源代码中指定参数,相当于在命令行中传递需要设定的参数。

具体例子

程序run_classifer.py中的部分代码如下:

flags.DEFINE_string(
    "data_dir", None,
    "The input data dir. Should contain the .tsv files (or other data files) "
    "for the task.")

flags.DEFINE_string(
    "bert_config_file", None,
    "The config json file corresponding to the pre-trained BERT model. "
    "This specifies the model architecture.")

flags.DEFINE_string("task_name", None, "The name of the task to train.")

flags.DEFINE_string("vocab_file", None,
                    "The vocabulary file that the BERT model was trained on.")

flags.DEFINE_string(
    "output_dir", None,
    "The output directory where the
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值