Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keras + TensorFlow: “module 'tensorflow' has no attribute 'merge_all_summaries''”

Very similar to Keras + tensorflow gives the error "no attribute 'control_flow_ops'", from the Convolutional autoencoder example from https://blog.keras.io/building-autoencoders-in-keras.html I get the error

[...]lib/python3.5/site-packages/keras/callbacks.py in _set_model(self, model)
    478                     tf.histogram_summary('{}_out'.format(layer),
    479                                          layer.output)
--> 480         self.merged = tf.merge_all_summaries()
    481         if self.write_graph:
    482             if parse_version(tf.__version__) >= parse_version('0.8.0'):

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

I tried

import tensorflow as tf
tf.merge_all_summaries = tf

but that did not work. What should I do?

In AttributeError: 'module' object has no attribute 'merge_all_summaries' the error is mentioned. I also have the version 1.0.0. But what is the solution? I don't want to downgrade TensorFlow.

like image 737
Make42 Avatar asked Mar 03 '17 18:03

Make42


2 Answers

Make42 is absolutely correct that the changes they describe in their answer must be made in order to migrate a codebase to work with TensorFlow 1.0. However, the errors you are seeing are in the Keras library itself. Fortunately, these errors have been fixed in the Keras codebase since January 2017, so upgrading to Keras 1.2.2 or later will fix the error for you.

like image 113
mrry Avatar answered Sep 29 '22 04:09

mrry


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 instead of

import tensorflow as tf
tf.merge_all_summaries = tf

you should write

import tensorflow as tf
tf.merge_all_summaries = tf.summary.merge_all
tf.train.SummaryWriter = tf.summary.FileWriter
like image 44
Make42 Avatar answered Sep 29 '22 04:09

Make42