. Advertisement .
..3..
. Advertisement .
..4..
For the problem “attributeerror: module ‘tensorflow’ has no attribute ‘get_default_graph’.” I tried to fix it, but it doesn’t work and returns the result I want. Here is my program:
from keras.models import Sequential
model = Sequential()
model.add(Dense(32, input_dim=784))
model.add(Activation('relu'))
model.add(LSTM(17))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
and
AttributeError: module 'tensorflow' has no attribute 'get_default_graph'
has occurred. I’ve checked the entire command line but still can’t find the mistake.
The cause: Tensorflow version changes are the cause of this attributeerror: module ‘tensorflow’ has no attribute ‘get_default_graph’ error.
Solution:
Change:
into:
tf.compat.v1.get_default_graph()
was used for tf 2.1.0 – e.g.