transformers icon indicating copy to clipboard operation
transformers copied to clipboard

run_tf_ner.py TFTrainer logdir cannot be none

Open jx669 opened this issue 6 years ago • 2 comments

🐛 Bug

Information

Model I am using (Bert, XLNet ...): bert

Language I am using the model on (English, Chinese ...): bert-base-multilingual-cased

The problem arises when using:

  • [x] the official example scripts: (give details below) run_tf_ner.py

  • [ ] my own modified scripts: (give details below)

The tasks I am working on is:

  • [x] an official GLUE/SQUaD task: (give the name) germeval2014ner
  • [ ] my own task or dataset: (give details below)

To reproduce

run_tf_ner.py (original) run.sh (see below)

Steps to reproduce the behavior:

run.sh

export MAX_LENGTH=128
export BERT_MODEL=bert-base-multilingual-cased
export OUTPUT_DIR=germeval-model
export BATCH_SIZE=32
export NUM_EPOCHS=1
export SAVE_STEPS=750
export SEED=1
export data_dir=data

python run_tf_ner.py --data_dir ./data/ \
--labels ./data/labels.txt \
--model_name_or_path $BERT_MODEL \
--output_dir $OUTPUT_DIR \
--max_seq_length  $MAX_LENGTH \
--num_train_epochs $NUM_EPOCHS \
--per_gpu_train_batch_size $BATCH_SIZE \
--save_steps $SAVE_STEPS \
--seed $SEED \
--do_train \
--do_eval \
--do_predict
  1. error message
Traceback (most recent call last):
  File "run_tf_ner.py", line 295, in <module>
    main()
  File "run_tf_ner.py", line 220, in main
    compute_metrics=compute_metrics,
  File "/usr/local/lib/python3.6/dist-packages/transformers/trainer_tf.py", line 48, in __init__
    self._setup_training()
  File "/usr/local/lib/python3.6/dist-packages/transformers/trainer_tf.py", line 65, in _setup_training
    self._create_summary_writer()
  File "/usr/local/lib/python3.6/dist-packages/transformers/trainer_tf.py", line 88, in _create_summary_writer
    self.writer = tf.summary.create_file_writer(self.args.logging_dir)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/summary_ops_v2.py", line 377, in create_file_writer_v2
    raise ValueError("logdir cannot be None")
ValueError: logdir cannot be None

Expected behavior

I did not change the code or the data. I was trying to reproduce exactly the German NER tf2.0 example: https://github.com/huggingface/transformers/tree/master/examples/token-classification

Environment info

google colab gpu

  • transformers version:
  • Platform:
  • Python version:
  • PyTorch version (GPU?):
  • Tensorflow version (GPU?): tensorflow gpu 2.2.0
  • Using GPU in script?:yes
  • Using distributed or parallel set-up in script?: no

jx669 avatar May 29 '20 08:05 jx669

Hello,

This is because you have to specify --logging_dir /path/to/logs as parameter. There will be a default location for the next release of the TF Trainer.

jplu avatar May 29 '20 14:05 jplu

Right. I later passed a parameter in run_tf_ner.py and it worked. I felt somewhere in the Trainer or run_tf_ner.py, it needs to be indicated.

Thanks for your prompt response!

jx669 avatar May 29 '20 14:05 jx669