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

Change

Import keras.<something>.<something>

to

Import tensorflow.keras.<something>.<something>

where "something" refers to the module you want to import. It worked for me.


Another cause due to which this is happening is that in tensorflow_backend.py

located in : lib/python3.6/site-packages/keras/backend/

uses tf.compat.v1.get_default_graph for obtaining graph

instead of tf.get_default_graph.

By replacing this in the directory this problem can be solved successfully.