zoukankan      html  css  js  c++  java
  • tensorflow models flags 初步使用

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

    测试Demo代码如下:

    from absl import app as absl_app
    from absl import flags
    
    from official.utils.flags import core as flags_core
    
    flags.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_aaa
    bbb

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

  • 相关阅读:
    springcloud--zuul(过滤器)
    springcloud--ruul(路由网关)
    spingcloud--hystrix(断路器)
    springcloud--Feign(WebService客户端)
    springcloud--ribbo(负载均衡)
    IO流常用模式
    ArrayList与LindedList区别
    抽象类与接口的区别
    SpringMVC核心
    MVC设计模式
  • 原文地址:https://www.cnblogs.com/xbit/p/10065067.html
Copyright © 2011-2022 走看看