google-research / bert

TensorFlow code and pre-trained models for BERT
https://arxiv.org/abs/1810.04805
Apache License 2.0
37.88k stars 9.56k forks source link

TypeError: batch() got an unexpected keyword argument 'drop_remainder' #435

Open jageshmaharjan opened 5 years ago

jageshmaharjan commented 5 years ago

Trying to classify the sentiment of the movie review using TF Hub. I encounter this error. batch() got an unexpected keyword argument 'drop_remainder'.

>>> estimator.train(input_fn=train_input_fn, max_steps=num_train_steps)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jugs/anaconda3/envs/asr/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 363, in train
    loss = self._train_model(input_fn, hooks, saving_listeners)
  File "/home/jugs/anaconda3/envs/asr/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 843, in _train_model
    return self._train_model_default(input_fn, hooks, saving_listeners)
  File "/home/jugs/anaconda3/envs/asr/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 853, in _train_model_default
    input_fn, model_fn_lib.ModeKeys.TRAIN))
  File "/home/jugs/anaconda3/envs/asr/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 691, in _get_features_and_labels_from_input_fn
    result = self._call_input_fn(input_fn, mode)
  File "/home/jugs/anaconda3/envs/asr/lib/python3.6/site-packages/tensorflow/python/estimator/estimator.py", line 798, in _call_input_fn
    return input_fn(**kwargs)
  File "/home/jugs/anaconda3/envs/asr/lib/python3.6/site-packages/bert/run_classifier.py", line 759, in input_fn
    d = d.batch(batch_size=batch_size, drop_remainder=drop_remainder)
TypeError: batch() got an unexpected keyword argument 'drop_remainder'

the input to the estimator.train is:

>>> train_input_fn = bert.run_classifier.input_fn_builder(
...     features=train_features,
...     seq_length=MAX_SEQ_LENGTH,
...     is_training=True,
...     drop_remainder=False)
ChrisS87 commented 5 years ago

I have the same problem!

atebbifakhr commented 5 years ago

Hi,

Upgrade your tensorflow to tensorflow>=1.11 or remove drop_remainder argument in run_classifier.py