Open erenat77 opened 3 years ago
Unfortunately, I ran into the same problem, and solved the issue by downgrading to tensorflow=2.3
This is cause by mix usage of tensorflow.python.keras and tensorflow.keras, when i replace all tensorflow.python.keras by tensorflow.keras, it work.
I got it to work by following @czf1009 advice. This is what I did:
1) I cloned the latest versions of this repos into my virtual environment (venv) lib/python3.8/site-packages folder
(I believe these can be cloned to a local folder as well)
2) I modified the following files on the bert (bert-for-tf2) repo
Where it says "from tensorflow.python import keras" replaced by "from tensorflow import keras"
3)To remove some warnings , I pip installed gast==0.3.3 and abs-py=1.0.0
Hope it helps!
Created https://github.com/kpe/bert-for-tf2/pull/94 with the solution from @lgalant
Thanks everybody,
TL;DR
in file {venv}/lib/python3.X/site-packages/bert/transformer.py
from tensorflow.python import keras
to
from tensorflow import keras
in file {venv}/lib/python3.X/site-packages/bert/attention.py
from tensorflow.python import keras
from tensorflow.python.keras import backend as K
to
from tensorflow import keras
from tensorflow.keras import backend as K