我想从另一个Python脚本调用this main(_)
function而不生成新进程(以便更容易调试)。但是,编写该函数是为了使用命令行参数。最直接从另一个函数调用该函数的最简单方法是什么?
答案 0 :(得分:4)
您可以导入FLAGS
,然后定义所需的args(train_data,eval_data,save_path)。
In [13]: from tensorflow.models.embedding.word2vec_optimized import FLAGS
In [14]: from tensorflow.models.embedding.word2vec_optimized import main
In [16]: main(_)
--train_data --eval_data and --save_path must be specified.
An exception has occurred, use %tb to see the full traceback.
In [17]: FLAGS.train_data = "this"
In [18]: FLAGS.eval_data = "that"
In [19]: FLAGS.save_path = "some_path"
In [20]: main(_)
I tensorflow/core/common_runtime/local_device.cc:40] Local device intra op parallelism threads: 8