bert
bert copied to clipboard
module 'tensorflow' has no attribute 'gfile'
I tried using bert-tokenizer only for tokenization but cannot vouch for it . Further tried below.
You need to use tensorflow 1.11.0. TF syntax has changed for 2.0 which is why you're getting your errors.
But the migration will be worthless as many things are deprecated in 2.0
On Tue, 7 Jan 2020, 09:57 adilapapaya, [email protected] wrote:
You need to use tensorflow 1.11.0. TF syntax has changed for 2.0 which is why you're getting your errors.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/google-research/bert/issues/977?email_source=notifications&email_token=AFIHA62FH3GBZHDOOAIPEFLQ4QAELA5CNFSM4KB2YJR2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIHU2WY#issuecomment-571428187, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFIHA65NKJCU24NAKBTL46DQ4QAELANCNFSM4KB2YJRQ .
A quick monkey patch of tensorflow is a quick and ugly fix for this. Put the following line after you import tensorflow:
tf.gfile = tf.io.gfile
@nobillygreen Thank you man for this hack
Gettting this new error: AttributeError: module 'tensorflow' has no attribute 'GraphDef'
A quick monkey patch of tensorflow is a quick and ugly fix for this. Put the following line after you import tensorflow:
tf.gfile = tf.io.gfile
@nobillygreen I tried it and i had another error: module 'tensorflow._api.v2.io.gfile' has no attribute 'MkDir'
@nobillygreen same to me, I had another error
I get the same error even after changing it to .io. Any other suggestions? Reading people's comments elsewhere, I even tried importing 'tensorflow.compat.v1 as tf' instead of 'import tensorflow as tf'
126 #with tf.gfile.GFile(vocab_file, "r") as reader:
127 with tf.io.gfile.GFile(vocab_file, "r") as reader:
AttributeError: module 'tensorflow' has no attribute 'gfile'
A quick monkey patch of tensorflow is a quick and ugly fix for this. Put the following line after you import tensorflow:
tf.gfile = tf.io.gfile
My Python version is 3.7.15
And tensorflow
version is 2.9.2
I faced the same problem as @kb2009
The solution to change tf.gfile
to tf.io.gfile
did not work until I added: tf.gfile = tf.io.gfile
@nobillygreen I tried it and i had another error: module 'tensorflow._api.v2.io.gfile' has no attribute 'MkDir'
type makedir
instead of MkDir