我正在尝试测试一个非常简单的短程序,如下所示
import numpy as np
import tensorflow as tf
flags = tf.app.flags
FLAGS = flags.FLAGS
import tensorvision.train as train
import tensorvision.utils as utils
flags.DEFINE_string('name', None,
'Append a name Tag to run.')
flags.DEFINE_string('hypes', 'hypes/medseg.json',
'File storing model parameters.')
if __name__ == '__main__':
tf.app.run()
但是,运行该程序会出现以下错误消息,
Traceback (most recent call last):
File "train.py", line 43, in <module>
tf.app.run()
File "/devl/tensorflow/tf_0.12/lib/python3.4/site- packages/tensorflow/python/platform/app.py", line 39, in run
main = main or sys.modules['__main__'].main
AttributeError: 'module' object has no attribute 'main'
答案 0 :(得分:12)
你需要一个&#34; def main(args)&#34;函数在您的文件中:
CREATE TABLE example_table (| a BIGINT, b BIGINT, v STRING, d TINYINT ) STORED AS TEXTFILE LOCATION /path/to/directory/
或tf.app.run()可以调用外部函数
import numpy as np
import tensorflow as tf
flags = tf.app.flags
FLAGS = flags.FLAGS
import tensorvision.train as train
import tensorvision.utils as utils
def main(args):
flags.DEFINE_string('name', None,
'Append a name Tag to run.')
flags.DEFINE_string('hypes', 'hypes/medseg.json',
'File storing model parameters.')
if __name__ == '__main__':
tf.app.run()