本文摘自php中文网,作者不言,侵删。
本篇文章主要介绍了tensorflow 使用flags定义命令行参数的方法,现在分享给大家,也给大家做个参考。一起过来看看吧tf定义了tf.app.flags,用于支持接受命令行传递参数,相当于接受argv。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import tensorflow as tf
tf.app.flags.DEFINE_string( 'str_name' , 'def_v_1' , "descrip1" )
tf.app.flags.DEFINE_integer( 'int_name' , 10 , "descript2" )
tf.app.flags.DEFINE_boolean( 'bool_name' , False , "descript3" )
FLAGS = tf.app.flags.FLAGS
def main(_):
print (FLAGS.str_name)
print (FLAGS.int_name)
print (FLAGS.bool_name)
if __name__ = = '__main__' :
tf.app.run()
|
执行:
[root@AliHPC-G41-211 test]# python tt.py
def_v_1
10
False
[root@AliHPC-G41-211 test]# python tt.py --str_name test_str --int_name 99 --bool_name True
test_str
99
True
相关推荐:
将TensorFlow的模型网络导出为单个文件的方法
以上就是tensorflow 使用flags定义命令行参数的方法的详细内容,更多文章请关注木庄网络博客!!
相关阅读 >>
Python中制表符是什么意思
Python的len函数什么意思
Python解释器是什么
Python卸载后怎么也安装不上
go语言对比 c++引用传参
Python中猴子补丁是什么?怎么用?
Python可变数据类型有哪些
Python中单下划线和双下划线有什么区别
基于Python的图片修复程序(实现水印去除)
Python如何处理表格?
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » tensorflow 使用flags定义命令行参数的方法