Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot Import Name 'keras_export' From 'tensorflow.python.util.tf_export'

I am trying to use the BERT in Keras with keras_bert and tensorflow, the complete code is here, but I am getting this error:

The error is on this line:

from tensorflow.python.util.tf_export import keras_export

The error is:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-18-eea03a4a6625> in <module>
----> 1 from tensorflow.python.util.tf_export import keras_export

ImportError: cannot import name 'keras_export' from 'tensorflow.python.util.tf_export' (C:\Users\DILAW\Anaconda3\lib\site-packages\tensorflow\python\util\tf_export.py)
like image 205
Walid Bousseta Avatar asked Aug 27 '19 14:08

Walid Bousseta


2 Answers

Tensorflow is not uninstalled when tensorflow-gpu is install. That is the problem in importing the keras_import. So if we uninstall the tensorflow then the problem is solved.

tensorflow_version 2.x
!pip uninstall -y tensorflow
!pip install tensorflow-gpu==1.14.0

Hope it works!!

like image 97
Uvan Shankar Avatar answered Oct 20 '22 01:10

Uvan Shankar


the last tensorflow update have change alot of thinks, also the BERT model have a new method to use it please chek here for more information link.

like image 36
Walid Bousseta Avatar answered Oct 19 '22 23:10

Walid Bousseta