Numpy format string issue in TFTrainer
See original GitHub issue🐛 Bug
Information
Model I am using (Bert, XLNet …): bert
Language I am using the model on (English, Chinese …): English
The problem arises when using:
- the official example scripts: (give details below)
- my own modified scripts: (give details below)
The tasks I am working on is:
- an official GLUE/SQUaD task: tf_ner
- my own task or dataset: (give details below)
To reproduce
Steps to reproduce the behavior:
Running the run_tf_ner
example raises the following exception:
Traceback (most recent call last): File "run_tf_ner.py", line 282, in <module> main() File "run_tf_ner.py", line 213, in main trainer.train() File "venv/lib/python3.7/site-packages/transformers/trainer_tf.py", line 308, in train logger.info("Epoch {} Step {} Train Loss {:.4f}".format(epoch, step, training_loss.numpy())) TypeError: unsupported format string passed to numpy.ndarray.__format__
This issue was reported by multiple people: https://github.com/numpy/numpy/issues/12491 https://github.com/numpy/numpy/issues/5543
I think the easiest solution is to avoid using the numpy format string this way in TFTrainer
.
Environment info
transformers
version: 2.1.0- Platform: Ubuntu-18.04
- Python version: 3.7.7
- PyTorch version (GPU?): N/A
- Tensorflow version (GPU?): 2.1.0
- Using GPU in script?: Yes
- Using distributed or parallel set-up in script?: No
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:19 (8 by maintainers)
Top GitHub Comments
Cool! Happy we found the problem.
When you run the TF Trainer you have to specify over which task it will be trained on, here for example it is
token-classification
when it on text content it will betext-classification
(the default) and the same for the two other tasks QA and MC.This behavior will be removed in the next version of the TF trainer.
@xl2602 Thanks for your feedback,
-1
was also the default value ofpad_token_label_id
in the previous version of the script.@jx669 and @xl2602 Can you try to add the
--mode token-classification
parameter?