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

匿名 (未验证) 提交于 2019-12-03 01:20:02

问题:

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.

回答1:

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.



回答2:

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 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!