0

I'm new to deep learning and to model a time series data using LSTM.

following are the libraries I'm trying to import:

`from keras.preprocessing.sequence import TimeseriesGenerator
 from keras.models import Sequential
 from keras.layers import Dense
 from keras.layers import LSTM`

I'm getting the following error:

`ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-33-ebf7cdbc1753> in <module>
----> 1 from keras.preprocessing.sequence import TimeseriesGenerator
      2 from keras.models import Sequential
      3 from keras.layers import Dense
      4 from keras.layers import LSTM

~\Anaconda3\envs\learn-env\lib\site-packages\keras\__init__.py in <module>
     19 """
     20 from keras import distribute
---> 21 from keras import models
     22 from keras.engine.input_layer import Input
     23 from keras.engine.sequential import Sequential

~\Anaconda3\envs\learn-env\lib\site-packages\keras\models\__init__.py in <module>
     16 
     17 
---> 18 from keras.engine.functional import Functional
     19 from keras.engine.sequential import Sequential
     20 from keras.engine.training import Model

~\Anaconda3\envs\learn-env\lib\site-packages\keras\engine\functional.py in <module>
     22 import warnings
     23 
---> 24 import tensorflow.compat.v2 as tf
     25 
     26 from keras import backend

ModuleNotFoundError: No module named 'tensorflow.compat'`

I am using Python 3.8.5 and tensorflow 2.12.0. How can I fix this? Thanks for your help!

rahul
  • 11
  • 2

1 Answers1

0

Rename your .py script to another name and it will work just fine. Next time make sure you've thoroughly checked to see if there is no other question that solves your problem before you ask a question. This is an example of a similar question.

mail_liw
  • 106
  • 1
  • 9
  • forgive my ignorance since I'm a newbie to coding. I'm using Jupyter notebook, and I don't see any .py script file in my directory. So, I'm not sure how to implement what you suggested. Can you please elaborate? Thanks for your patience! – rahul Apr 07 '23 at 15:29
  • Oh. Then you need to install the library in Jupyter Notebooks with !pip install tensorflow – mail_liw Apr 08 '23 at 17:23