I am working on image recognition with Tensorflow following this tutorial 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__":
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.
You don't need to use main module checker like this:
if __name__ == "__main__":
tf.app.run()
If you are on Jupiter notebook. 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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.