本文摘自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可以根据值寻找键吗
Python中有哪些数据类型
Python中的seth是什么意思
简介Python中的__init__的作用
Python数据分析用什么软件
Python需要什么开发环境及电脑的配置
如何检测一个变量是否存在
Python如何查看父类
Python条件语句是什么?条件语句的一般格式是什么样的?
更多相关阅读请进入《Python》频道 >>
人民邮电出版社
python入门书籍,非常畅销,超高好评,python官方公认好书。
转载请注明出处:木庄网络博客 » tensorflow 使用flags定义命令行参数的方法