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

說明

Python 的 tensorflow 套件,有報錯

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

我自己的情況是,一開始在別的環境下執行是沒有問題的,後來電腦重新安裝環境成 python 3.7,對應的 tensorflow 2.0.0 版本,就產生第一個這個的報錯,接連生成多個報錯,後去問了 google 大神有找到適應的解法。

操作流程

報錯

參考- https://github.com/theislab/scgen/issues/14

程式加入

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

完成

留言