Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: 'module' object has no attribute 'merge_all_summaries'

Ubuntu 14.04.

Python 2.7.13 :: Anaconda custom (64-bit)

I installed Tensorflow follow the tutorial: https://www.tensorflow.org/install/

when I enter

~/anaconda2/lib/python2.7/site-packages/tensorflow/examples/tutorials/mnist

and attempt to run the already existed python file:

fully_connected_feed.py

I met the below AttributeError:

:~/anaconda2/lib/python2.7/site-packages/tensorflow/examples/tutorials/mnist$ python fully_connected_feed.py 
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcublas.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcufft.so.8.0 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:135] successfully opened CUDA library libcurand.so.8.0 locally
Extracting Mnist_data/train-images-idx3-ubyte.gz
Extracting Mnist_data/train-labels-idx1-ubyte.gz
Extracting Mnist_data/t10k-images-idx3-ubyte.gz
Extracting Mnist_data/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
  File "fully_connected_feed.py", line 229, in <module>
    tf.app.run()
  File "/home/hok/anaconda2/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 44, in run
    _sys.exit(main(_sys.argv[:1] + flags_passthrough))
  File "fully_connected_feed.py", line 225, in main
    run_training()
  File "fully_connected_feed.py", line 154, in run_training
    summary_op = tf.merge_all_summaries()
AttributeError: 'module' object has no attribute 'merge_all_summaries'

But the same code run successfully in other computer. So I think that must be the configuration problem in my computer.

I have followed the same steps to install tensorflow many times and use it to run Deep Learning for a period of time. But it was the first time I met such problem.

There are many suggestions in Google say such kind of AttributeError maybe the problem with python version. But it's not.

like image 961
123 Avatar asked Feb 05 '23 00:02

123


1 Answers

In https://stackoverflow.com/a/40066895/4533188 you can read up on an answer to a similar problem: The answer is to migrate as appropriate. Check out https://www.tensorflow.org/install/migration. There you see that

- tf.merge_summary
    - should be renamed to tf.summary.merge
- tf.train.SummaryWriter
    - should be renamed to tf.summary.FileWriter

(Actually SummaryWriter has also been changed.) So you should be able to solve your problem if you write before your code

import tensorflow as tf
tf.merge_all_summaries = tf.summary.merge_all
tf.train.SummaryWriter = tf.summary.FileWriter

(I had the same issue in Keras + TensorFlow: “module 'tensorflow' has no attribute 'merge_all_summaries''”.)

like image 68
Make42 Avatar answered Feb 08 '23 17:02

Make42