GoogleのTensorflowのTutorialsのMNISTで躓いた時のメモ。
環境
macOS 10.13.3
tensorflow 1.6.0
Python 3.6.0
状況
https://www.tensorflow.org/tutorials/layers
に載っている一番最初のコード
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
# Imports
import numpy as np
import tensorflow as tf
tf.logging.set_verbosity(tf.logging.INFO)
# Our application logic will be added here
if __name__ == "__main__":
tf.app.run()
これを実行した。すると
main = main or _sys.modules['__main__'].main
AttributeError: module '__main__' has no attribute 'main'
というエラーが出た。
解決
Githubの下記のページを参照した。
https://github.com/tensorflow/tensorflow/issues/2310
def main(_):
tf.logging.set_verbosity(tf.logging.INFO)
if __name__ == "__main__":
tf.app.run(main=main)
とすると無事解決した様子。