Error running Keras.models.Sequential() with tensorflow

Asked

Viewed 139 times

0

I imported Keras.models as specified in the documentation

Importing:

from keras.models import Sequential 

When creating the model I try to run Sequential returns an error:

Execution:

 model = Sequential()

Error log:

Traceback (most recent call last):
  File "/Users/marcosmw/Documents/Meus_codigos/neural_network/classificacao_imagens/clk.py", line 90, in <module>
    model = Sequential()
  File "/Users/marcosmw/opt/anaconda3/lib/python3.7/site-packages/keras/engine/sequential.py", line 87, in __init__
    super(Sequential, self).__init__(name=name)
  File "/Users/marcosmw/opt/anaconda3/lib/python3.7/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/Users/marcosmw/opt/anaconda3/lib/python3.7/site-packages/keras/engine/network.py", line 96, in __init__
    self._init_subclassed_network(**kwargs)
  File "/Users/marcosmw/opt/anaconda3/lib/python3.7/site-packages/keras/engine/network.py", line 294, in _init_subclassed_network
    self._base_init(name=name)
  File "/Users/marcosmw/opt/anaconda3/lib/python3.7/site-packages/keras/engine/network.py", line 109, in _base_init
    name = prefix + '_' + str(K.get_uid(prefix))
  File "/Users/marcosmw/opt/anaconda3/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py", line 74, in get_uid
    graph = tf.get_default_graph()
AttributeError: module 'tensorflow' has no attribute 'get_default_graph'

Operating system: Macos Catalina 10.15.1 Version fo Tensorflow : 2.0.0 version of Keras: 2.2.4

  • Beyond the Sequential you are also importing the Backend?

  • Yes, I have already made version changes to the anaconda and continues with the error

1 answer

0

I don’t think your problem is with the Sequential, but with the Backend.

Supersedes the

from keras import backend

for

from tensorflow.keras import backend

If you want to read the issue github click here and then here

Browser other questions tagged

You are not signed in. Login or sign up in order to post.