Error started happening today: ImportError: cannot import name 'get_linear_schedule_with_warmup'
See original GitHub issueš Bug
Model I am using (Bert, XLNetā¦): Bert
Language I am using the model on (English, Chineseā¦): English
The problem arise when using:
- [ x] the official example scripts: (give details)
The squad script: https://github.com/huggingface/transformers/blob/master/examples/run_squad.py
The tasks I am working on is:
- [X ] an official GLUE/SQUaD task: (give the name)
Squad 2.0 from https://rajpurkar.github.io/SQuAD-explorer/
- my own task or dataset: (give details)
To Reproduce
!pip install transformers
import urllib.request
url = 'https://rajpurkar.github.io/SQuAD-explorer/dataset/train-v2.0.json'
urllib.request.urlretrieve(url, 'train-v2.0.json')
url = 'https://rajpurkar.github.io/SQuAD-explorer/dataset/dev-v2.0.json'
urllib.request.urlretrieve(url, 'dev-v2.0.json')
!wget 'https://raw.githubusercontent.com/huggingface/transformers/master/examples/run_squad.py'
!wget 'https://raw.githubusercontent.com/huggingface/pytorch-transformers/master/examples/utils_squad.py'
!wget 'https://raw.githubusercontent.com/huggingface/pytorch-transformers/master/examples/utils_squad_evaluate.py'
# $SQUAD_DIR/train-v1.1.json
SQUAD_Train = '/content/train-v2.0.json'
SQUAD_Dev = '/content/dev-v2.0.json'
!python run_squad.py \
--model_type bert \
--model_name_or_path bert-base-cased \
--do_train \
--do_eval \
--do_lower_case \
--train_file '$SQUAD_Train' \
--predict_file '$SQUAD_Dev' \
--per_gpu_train_batch_size 12 \
--learning_rate 3e-5 \
--num_train_epochs 2.0 \
--max_seq_length 384 \
--doc_stride 128 \
--version_2_with_negative \
--output_dir /tmp/debug_squad/
Results in
ImportError: cannot import name āget_linear_schedule_with_warmupā
I ran it yesterday and it worked fine, but today itās not working.
For convenience, hereās a colab notebook with the code
https://colab.research.google.com/drive/1tNisXX5siuNnkuEQ-X_XdEdDTtdJ0qeL
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:11 (6 by maintainers)
Top Results From Across the Web
ImportError: cannot import name 'warmup_linear'
While trying to import warmup_linear , IĀ ...
Read more >cannot import name 'get_scheduler' from 'transformers ...
Hi, I'm new to Transformer models, just following the tutorials. On Huggingface website, under Course/ 3 Fine tuning a pretrained model/ full training,Ā ......
Read more >"ImportError: cannot import name 'BatchSampler'" - Part 1 (2018)
The error I'm getting is āImportError: cannot import name 'BatchSampler'ā ... Same thing happened for me today, running native Ubuntu 16.04Ā ...
Read more >ImportError: cannot import name 'LinkToken' from 'brownie'
address}") print("All done!") # ... David from freecodecamp.org already created this browie-config.yaml file which exludes reports about theĀ ...
Read more >1913266 ā mkdocs fails to build with Python 3.10: ImportError
Bug 1913266 - mkdocs fails to build with Python 3.10: ImportError: cannot import name 'Sequence' from 'collections'.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The version of the lib you use is not in sync with the scripts you run (cc @rlouf, @LysandreJik)
If you run the scripts from
master
, then you also need to install the lib frommaster
:This is a frequent issue so maybe we should do something about it, @thomwolf
They are the same schedulers but we introduced breaking changes, and indeed renamed
warmup_steps
->num_warmup_steps
andt_total
-> Ėnum_training_steps`.And yes, to work on the same version of the lib as the examples, go in the root directory and:
@julien-c I asked for advice on this one.