kodumun aşağıdaki kısmında:
from keras import layers
from tensorflow.keras.utils import plot_model
Cannot find reference ‘keras’ in ‘init .py | init .py’ hatasını alıyorum. Yardımcı olabilecek var mıdır?
Merhaba,
PyCharm mı kullanıyorsunuz?
pip install transformers
ile çözebilirsin diyorlar, ayrıca hatayı alanlar genelde PyCharm kullanıyormuş, python versiyonuyla da alakalı olabilir deniyor.
opened 04:29PM - 18 Jan 23 UTC
closed 10:40AM - 02 Feb 23 UTC
stat:awaiting response from contributor
I have a code for LSTM including transformers.
The error is the following:
… ```
Traceback (most recent call last):
File "C:\UsersLSTM_TL.py", line 12, in <module>
from tensorflow.keras.layers import Input, Transformer
ImportError: cannot import name 'Transformer' from 'tensorflow.keras.layers' (C:\Users\cttc\anaconda3\envs\testenv\lib\site-packages\keras\api\_v2\keras\layers\__init__.py)
```
The line is:
...
`model.add(Transformer(num_layers=6, d_model=64, num_heads=8, dff=256, dropout=0.2))
`...
In the imports I do have:
```
from tensorflow.keras.layers import Input, Transformer
from tensorflow.keras.models import Model
from tensorflow.keras import optimizers
```
In which the keras part appears with a red underline with the following error: "`cannot find reference 'keras in __init__ py __init__ py`".
I'm running this on:
- Windows 10 64bits
- Anaconda3 2022.10 (Python 3.9.13 64-bit)
- PyCharm 2022.3.1
- Inside Conda Env setup as Python 3.10.4 (previously installed).
I've installed tensorflow on Administrator Anaconda Prompt with conda install tensorflow (it was successful)
denedim ama olmadı malaesef