博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
tensorflow models flags 初步使用
阅读量:4544 次
发布时间:2019-06-08

本文共 1575 字,大约阅读时间需要 5 分钟。

 

参考官方仓库:https://github.com/tensorflow/models/tree/master/official/utils/flags

测试Demo代码如下:

from absl import app as absl_appfrom absl import flagsfrom official.utils.flags import core as flags_coreflags.DEFINE_string(name="my_flag_a", default="aaa", help="an example flag")flags.DEFINE_string(name="my_flag_b", default="bbb", help="an other example flag")def main(_):    flags_obj = flags.FLAGS    print(flags_obj)    print(flags_obj.my_flag_a)    print(flags_obj.my_flag_b)if __name__ == "__main__":    absl_app.run(main)

Terminal运行执行如下脚本:

python tensorflow_example/test_absl_flags.py --log_dir "./logs"  --my_flag_a "flag_aaa"

输出结果:

tensorflow_example/test_absl_flags.py:  --my_flag_a: an example flag    (default: 'aaa')  --my_flag_b: an other example flag    (default: 'bbb')absl.app:  -?,--[no]help: show this help    (default: 'false')  --[no]helpfull: show full help    (default: 'false')  -h,--[no]helpshort: show this help    (default: 'false')  ......absl.logging:  --[no]alsologtostderr: also log to stderr?    (default: 'false')  --log_dir: directory to write logfiles into  ......absl.flags:  --flagfile: Insert flag definitions from the given file into the command line.    (default: '')  --undefok: comma-separated list of flag names that it is okay to specify on the command line even if the program does not define a flag with that name.  IMPORTANT: flags in this    list that have arguments MUST use the --flag=value format.    (default: '')flag_aaabbb

其中最后两行,表示flags_obj.my_flag_a为设置后的值,flags_obj.my_flag_b为默认值

 

转载于:https://www.cnblogs.com/xbit/p/10065067.html

你可能感兴趣的文章
Python的平凡之路(19)
查看>>
数据分析---《Python for Data Analysis》学习笔记【03】
查看>>
ACM练习网站
查看>>
输入输出外挂(纯数字型)
查看>>
限制输出字数,超过的用...省略
查看>>
bnuoj25660 Two Famous Companies
查看>>
股票投资
查看>>
C# 启动另一个程序
查看>>
木桶效应
查看>>
springMVC3学习(二)--ModelAndView对象
查看>>
postgres前言(常用语句熟悉 系列一)
查看>>
Windows 上 GitHub Desktop 的操作[转]
查看>>
Leetcode-916. Word Subsets-(Medium)
查看>>
C# 解决无法识别的属性 configProtectionProvider
查看>>
js中的this
查看>>
ACM_三角形蛇形矩阵
查看>>
在IIS服务器上部署svg/woff/woff2字体
查看>>
计算机基础作业 网页制作
查看>>
HDU 4467 Graph
查看>>
并发容器之ConcurrentHashMap(转载)
查看>>