LoginSignup
12
4

More than 3 years have passed since last update.

module 'keras.backend' has no attribute 'control_flow_ops'というエラーに対処するために

Last updated at Posted at 2019-10-29

はじめに

kerasのバージョンアップに伴い、以上のエラーが出てしまいました。これの解決方法を備忘録として残しておきます。

環境

MacOS Mojave
Python 3.7.2
Keras 2.3.1
tensorflow 1.13.1

手順

kerasの場所を調べる

terminalでpythonの対話シェルを開き、以下のコマンドでkerasのパスを特定します。
(***には自分の環境のパスを入れます。)

>>>import keras
>>>keras.__file__
/***/python3.7/site-packages/keras/__init__.py

/***/python3.7/site-packages/keras/backend/__init__.pyを開く

場所が特定できたら、/***/python3.7/site-packages/keras/backendに入っている__init__.pyを開きます。

from tensorflow.python.ops import control_flow_opsを追加する

from .load_backend importの並びの中に
from tensorflow.python.ops import control_flow_ops
を追加します。

__init__.py
                  .
                  .
                  .
from .load_backend import eager
from .load_backend import size
from .load_backend import control_dependencies

from tensorflow.python.ops import control_flow_ops

終わり

私はこの方法で動かすことができました。もしかしたら、物によっては動かないかもしれないので悪しからず、、、

12
4
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
12
4