tf is defined to support the acceptance of command-line passed arguments, which is equivalent to accepting argv.
import tensorflow as tf # The first is the parameter name, the second parameter is the default value, and the third is the parameter description .DEFINE_string('str_name', 'def_v_1',"descrip1") .DEFINE_integer('int_name', 10,"descript2") .DEFINE_boolean('bool_name', False, "descript3") FLAGS = # must take arguments, otherwise: 'TypeError: main() takes no arguments (1 given)'; main's parameter names are defined arbitrarily, no requirements def main(_): print(FLAGS.str_name) print(FLAGS.int_name) print(FLAGS.bool_name) if __name__ == '__main__': () #fulfillmentmainfunction (math.)
Implementation:
[root@AliHPC-G41-211 test]# python
def_v_1
10
False
[root@AliHPC-G41-211 test]# python --str_name test_str --int_name 99 --bool_name True
test_str
99
True
This is the whole content of this article, I hope it will help you to learn more.