LoginSignup
4
1

More than 5 years have passed since last update.

TensorflowのTutorialのメモ

Posted at

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)

とすると無事解決した様子。

4
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
1