[英]TensorFlow: module '__main__' has no attribute 'main'
I am working on image recognition with Tensorflow following this tutorial https://www.tensorflow.org/tutorials/layers . 我正在使用Tensorflow进行图像识别,遵循本教程https://www.tensorflow.org/tutorials/layers 。 When I run the first chunk of codes, including "if name == " main ":", I get an error.
当我运行第一块代码时,包括“if name ==” main “:”,我收到错误。
if __name__ == "__main__":
tf.app.run()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-20-a542ecc63e7e> in <module>()
12
13 if __name__ == "__main__":
---> 14 tf.app.run()
~/anaconda3/lib/python3.6/site-packages/tensorflow/python/platform/app.py in run(main)
27 f = flags.FLAGS
28 flags_passthrough = f._parse_flags()
---> 29 main = main or sys.modules['__main__'].main
30 sys.exit(main(sys.argv[:1] + flags_passthrough))
AttributeError: module '__main__' has no attribute 'main'
What is the problem and how can I solve this? 有什么问题,我该如何解决?
I am using Python 3.6.2 under Anaconda environment on Jupiter Notebook. 我在Jupiter Notebook上的Anaconda环境下使用Python 3.6.2。
You don't need to use main module checker like this: 您不需要像这样使用主模块检查器:
if __name__ == "__main__":
tf.app.run()
If you are on Jupiter notebook. 如果你在Jupiter笔记本上。 This was probable an error in the documentation.
这可能是文档中的错误。 Now you can check and this kind of checker is gone.
现在你可以检查 ,这种检查器已经消失了。
You would need to use that as an entry point if you create a python .py
script. 如果您创建python
.py
脚本,则需要将其用作入口点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.