Bert: I get attribute error when I run classifier code

Created on 5 Nov 2018  路  12Comments  路  Source: google-research/bert

When I run code like:
python run_classifier.py
--task_name=MRPC
--do_train=true
--do_eval=true
--data_dir=SST-2
--vocab_file=english_L-12_H-768_A-12/vocab.txt
--bert_config_file=english_L-12_H-768_A-12/bert_config.json
--init_checkpoint=english_L-12_H-768_A-12/bert_model.ckpt
--max_seq_length=128
--train_batch_size=32
--learning_rate=2e-5
--num_train_epochs=3.0
--output_dir=output

I get an Attribute Error as following:
Traceback (most recent call last):
File "run_classifier.py", line 754, in
tf.app.run()
File "/home/xiyu/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 48, in run
_sys.exit(main(_sys.argv[:1] + flags_passthrough))
File "run_classifier.py", line 658, in main
is_per_host = tf.contrib.tpu.InputPipelineConfig.PER_HOST_V2
AttributeError: 'module' object has no attribute 'InputPipelineConfig'

My tensorflow version is 1.4.0, and my gpu is GTX1080. Do I run the shell wrong or I forget to install some packages?

Thanks very much.

Most helpful comment

Yes, BERT requires TF 1.11 (or maybe 1.10 would work, but nothing earlier).

All 12 comments

update your tensorflow to 1.11

Yes, BERT requires TF 1.11 (or maybe 1.10 would work, but nothing earlier).

@jacobdevlin-google Thanks, use tf 1.11 docker, and it works.

AttributeError: module 'tensorflow.contrib.tpu' has no attribute 'outside_compilation'
help pleaseee

I have the same error "outside_compilation". did you solve it?

I have the same error "outside_compilation". did you solve it?

Yes, just update your tensorflow to 1.11

I have the same issue on is_per_host = tf.contrib.tpu.InputPipelineConfig.PER_HOST_V2. Now that TF is updated to 2.1.0 and tf.contrib has been removed since TF2. What do I do with this? (Suppose I do not wish to downgrade to TF1.x)

I have the same issue on is_per_host = tf.contrib.tpu.InputPipelineConfig.PER_HOST_V2. Now that TF is updated to 2.1.0 and tf.contrib has been removed since TF2. What do I do with this? (Suppose I do not wish to downgrade to TF1.x)

i dont want to downgrade my tf too, but it seems no way

Instead of using is_per_host = tf.contrib.tpu.InputPipelineConfig.PER_HOST_V2, please use is_per_host = tf.compat.v1.estimator.tpu.InputPipelineConfig.PER_HOST_V2

Hope this helps!!

Instead of using is_per_host = tf.contrib.tpu.InputPipelineConfig.PER_HOST_V2, please use is_per_host = tf.compat.v1.estimator.tpu.InputPipelineConfig.PER_HOST_V2

Hope this helps!!

it not works, my tf version is 1.8.0, any other ways can help in the condition of not downgrading to tf1.0?

Instead of using is_per_host = tf.contrib.tpu.InputPipelineConfig.PER_HOST_V2, please use is_per_host = tf.compat.v1.estimator.tpu.InputPipelineConfig.PER_HOST_V2
Hope this helps!!

it not works, my tf version is 1.8.0, any other ways can help in the condition of not downgrading to tf1.0?

TF 1.8? Then you should UPgrade to TF 1.11+. That's for TF 2+. (See discussion above.)

Instead of using is_per_host = tf.contrib.tpu.InputPipelineConfig.PER_HOST_V2, please use is_per_host = tf.compat.v1.estimator.tpu.InputPipelineConfig.PER_HOST_V2
Hope this helps!!

it not works, my tf version is 1.8.0, any other ways can help in the condition of not downgrading to tf1.0?

TF 1.8? Then you should UPgrade to TF 1.11+. That's for TF 2+. (See discussion above.)

Ok, I'll try, thanks

Was this page helpful?
0 / 5 - 0 ratings