1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

module 'tensorflow' has no attribute 'get_default_graph' 出たときの対処方法

Last updated at Posted at 2020-12-05

発端

自社の解析サーバーのCICDを修正する際に、解析サーバーだけではなくローカルで動かしたいと思い、修正していたときの出来事。
モックも作成したし、うまくいくだろうと思ったら、次のようなエラーが発生した。

module 'tensorflow' has no attribute 'get_default_graph'

tensorflow か・・・・・・

環境

Keras==2.2.0
tensorflow==2.3.0

対処方法

pip install Keras==2.3.1

すると以下のエラーが発生

module 'tensorflow.python.framework.ops' has no attribute '_TensorLike'

次に keras を使用しているスクリプトファイルにて以下のような修正をした

# Before: from keras.models import load_model
# After:
from tensorflow.keras.models import load_model

したら、うまくいった。
やれやれ。

参考文献

https://qiita.com/white1107/items/67ec0826a07a84442d31
https://stackoverflow.com/questions/53135439/issue-with-add-method-in-tensorflow-attributeerror-module-tensorflow-python

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?