2017-03-03 34 views
1

非常相似Keras + tensorflow gives the error "no attribute 'control_flow_ops'",從卷積自動編碼例如從https://blog.keras.io/building-autoencoders-in-keras.html我得到Keras + TensorFlow:「模塊 'tensorflow' 有沒有屬性'merge_all_summaries'」

[...]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' 

我試圖

import tensorflow as tf 
tf.merge_all_summaries = tf 
錯誤

但沒有奏效。我該怎麼辦?

AttributeError: 'module' object has no attribute 'merge_all_summaries'錯誤被提及。我也有版本1.0.0。但是,解決方案是什麼?我不想降級TensorFlow。

回答

2

Make42是絕對正確的,因爲改變他們的描述必須創建their answer才能遷移代碼庫以使用TensorFlow 1.0。但是,您看到的錯誤在Keras庫本身。幸運的是,這些錯誤已在Keras代碼庫since January 2017中得到修復,因此升級到Keras 1.2.2或更高版本將爲您解決錯誤。

+0

我們可以用anaconda或至少是'pip'來做到這一點嗎? – Make42

+1

我覺得'pip install -U keras'應該這樣做。 – mrry

0

答案是根據情況進行遷移。檢查出https://www.tensorflow.org/install/migration。在那裏,你看到的

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

(其實SummaryWriter也有了變化。)因此,不是

import tensorflow as tf 
tf.merge_all_summaries = tf 

你應該寫

import tensorflow as tf 
tf.merge_all_summaries = tf.summary.merge_all 
tf.train.SummaryWriter = tf.summary.FileWriter 
相關問題