bert
bert copied to clipboard
Fix gfile and flags no attribute error for TensorFlow V2
There are "no attribute" errors such as
AttributeError: module 'tensorflow' has no attribute 'gfile'
AttributeError: module 'tensorflow' has no attribute 'flags'
because tensorflow V2 is automatically installed from pip install -r requirements.txt.
To fix this error, I added version check code and make it works properly in TensorFlow V2 environments.
Also, TensorFlow V1 users can use this code. because if tf.version is lower than 2.0.0, it will use legacy code.