I’m encountering an issue when trying to import the Sequential class from Keras. Here’s the code I’m running:
from keras.models import Sequential
from keras.layers import Embedding, LSTM, Dense
model = Sequential()
model.add(Embedding(10000, 64, input_length=80))
model.add(LSTM(100))
model.add(Dense(2, activation='sigmoid'))
model.compile(loss='binary_crossentropy', metrics=['accuracy'], optimizer='adam')
When I run this code, I get the following error:
Cell In[80], line 1
----> 1 model=Sequential()
2 model.add(Embedding(10000,64,input_length=80))
3 model.add(LSTM(100))
File c:\Users\Isaac\anaconda3\envs\textattackenv\lib\site-packages\keras\engine\training.py:184, in __new__(cls, *args, **kwargs)
File c:\Users\Isaac\anaconda3\envs\textattackenv\lib\site-packages\keras\utils\version_utils.py:61, in __new__(cls, *args, **kwargs)
File c:\Users\Isaac\anaconda3\envs\textattackenv\lib\site-packages\keras\utils\generic_utils.py:1221, in __getattr__(self, item)
File c:\Users\Isaac\anaconda3\envs\textattackenv\lib\site-packages\keras\utils\generic_utils.py:1212, in _load(self)
File c:\Users\Isaac\anaconda3\envs\textattackenv\lib\importlib\__init__.py:127, in import_module(name, package)
125 break
126 level += 1
--> 127 return _bootstrap._gcd_import(name[level:], package, level)
File <frozen importlib._bootstrap>:1014, in _gcd_import(name, package, level)
File <frozen importlib._bootstrap>:991, in _find_and_load(name, import_)
File <frozen importlib._bootstrap>:973, in _find_and_load_unlocked(name, import_)
ModuleNotFoundError: No module named 'keras.engine.base_layer_v1'
I’m not sure why this is happening. I’ve tried reinstalling Keras and TensorFlow, but the issue persists. Any help would be greatly appreciated.