簡體   English   中英

AttributeError: 'module' 對象沒有屬性 'Graph'

[英]AttributeError: 'module' object has no attribute 'Graph'

在 MacOS 中,我按照 tensorflow.org 網站上的標准說明使用 Pip 安裝 tensorflow。

當我啟動 Spyder 時,我能夠毫無錯誤地執行以下指令:

import tensorflow as tf

但是當我嘗試運行以下指令時:g = tf.Graph(),我收到以下錯誤:

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

當我在“python”或“ipython”而不是Spyder中做同樣的事情時,我沒有收到這個錯誤。 但我想使用Spyder。

我嘗試使用 Conda 而不是 Pip 進行安裝,但出現了相同的症狀。

這些步驟對我有用:(linux、pip、tf1.4-gpu)

  • 卸載 tensorflow pip uninstall tensorflow-gpu
  • 刪除 pip 緩存rm -rf ~/.cache/pip/*
  • 重新安裝 tensorflow pip install -U tensorflow-gpu

對於最近來的任何人,使用 Keras 時可能會出現此錯誤。 通過改變所有解決它

from keras.something import something

from tensorflow.keras.something import something

可以看到關於這個的github問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM