Import error while using tensorflow to import LSTM model

Issue

I have started dabbling with ML/DL and I am trying to import the LSTM model using the following code :

from tensorflow.keras.layers import LSTM

However, I am getting the following traceback error and am unsure how to proceed.

C:\Users\Ahmed_Abdelmuniem\AppData\Local\Programs\Python\Python39\python.exe C:/Users/Ahmed_Abdelmuniem/PycharmProjects/pythonProject/main.py
2021-08-19 10:42:59.820385: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2021-08-19 10:42:59.821236: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "C:\Users\Ahmed_Abdelmuniem\PycharmProjects\pythonProject\main.py", line 1, in <module>
    from tensorflow.keras.layers import LSTM
  File "C:\Users\Ahmed_Abdelmuniem\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\__init__.py", line 55, in <module>
    from ._api.v2 import compat
  File "C:\Users\Ahmed_Abdelmuniem\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\_api\v2\compat\__init__.py", line 39, in <module>
    from . import v1
  File "C:\Users\Ahmed_Abdelmuniem\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\_api\v2\compat\v1\__init__.py", line 34, in <module>
    from . import compat
  File "C:\Users\Ahmed_Abdelmuniem\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\_api\v2\compat\v1\compat\__init__.py", line 39, in <module>
    from . import v1
  File "C:\Users\Ahmed_Abdelmuniem\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\_api\v2\compat\v1\compat\v1\__init__.py", line 36, in <module>
    from tensorflow._api.v2.compat.v1 import data
  File "C:\Users\Ahmed_Abdelmuniem\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\_api\v2\compat\v1\data\__init__.py", line 13, in <module>
    from . import experimental
  File "C:\Users\Ahmed_Abdelmuniem\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\_api\v2\compat\v1\data\experimental\__init__.py", line 86, in <module>
    from . import service
  File "C:\Users\Ahmed_Abdelmuniem\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\_api\v2\compat\v1\data\experimental\service\__init__.py", line 363, in <module>
    from tensorflow.python.data.experimental.ops.data_service_ops import ShardingPolicy
ImportError: cannot import name 'ShardingPolicy' from 'tensorflow.python.data.experimental.ops.data_service_ops' (C:\Users\Ahmed_Abdelmuniem\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\python\data\experimental\ops\data_service_ops.py)

Process finished with exit code 1

I’m sure it doesn’t need to be said, but I am very new to tensorflow and still a beginner at python.

Solution

Alright, the solution turned out to be a re-installation with admin rights, as it seems certain parts didn’t install properly as without admin access pip didn’t have the right to edit certain folders.

Answered By – Ahmed

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published