Transformers: ImportError: cannot import name 'WarmupLinearSchedule'

Created on 6 Dec 2019  路  9Comments  路  Source: huggingface/transformers

$ pip show transformers
Name: transformers
Version: 2.2.1
Summary: State-of-the-art Natural Language Processing for TensorFlow 2.0 and PyTorch
Home-page: https://github.com/huggingface/transformers
Author: Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Google AI Language Team Authors, Open AI team Authors, Facebook AI Authors, Carnegie Mellon University Authors
Author-email: [email protected]
License: Apache
Location: /home/ubuntu/anaconda3/lib/python3.6/site-packages
Requires: numpy, requests, regex, sacremoses, tqdm, sentencepiece, boto3
Required-by:

wontfix

Most helpful comment

Use get_linear_schedule_with_warmup() instead of WarmupLinearSchedule. I think they have the same function.

The API is not quite the same, but it's similar enough that it should be easy enough to convert.

For example:

scheduler = WarmupLinearSchedule(optimizer, warmup_steps=WARMUP_STEPS, t_total = -1)

becomes...

scheduler = get_linear_schedule_with_warmup(optimizer, num_warmup_steps=WARMUP_STEPS, num_training_steps = -1)

For future visitors, see docs

All 9 comments

It is in the optimization.py, at line 45. It creates a schedule with a learning rate that decreases linearly after linearly increasing during a warmup period. In order to import it, you have to do the following:

> from transformers import get_linear_schedule_with_warmup
> ...

I've tested this statement with Python 3.6.9, Transformers 2.2.1 (installed with pip install transformers), PyTorch 1.3.1 and TensorFlow 2.0.

$ pip show transformers
Name: transformers
Version: 2.2.1
Summary: State-of-the-art Natural Language Processing for TensorFlow 2.0 and PyTorch
Home-page: https://github.com/huggingface/transformers
Author: Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Google AI Language Team Authors, Open AI team Authors, Facebook AI Authors, Carnegie Mellon University Authors
Author-email: [email protected]
License: Apache
Location: /home/ubuntu/anaconda3/lib/python3.6/site-packages
Requires: numpy, requests, regex, sacremoses, tqdm, sentencepiece, boto3
Required-by:

I have the same error

Do you see my comment above? Did you try out?

I have the same error

Do you see my comment above? Did you try out?

I have the same error

I try to install from the git, fix the problem

I tried both pip and git, still having the issue

Still having this issue on 2.3.0 too

Use get_linear_schedule_with_warmup() instead of WarmupLinearSchedule. I think they have the same function.

Use get_linear_schedule_with_warmup() instead of WarmupLinearSchedule. I think they have the same function.

The API is not quite the same, but it's similar enough that it should be easy enough to convert.

For example:

scheduler = WarmupLinearSchedule(optimizer, warmup_steps=WARMUP_STEPS, t_total = -1)

becomes...

scheduler = get_linear_schedule_with_warmup(optimizer, num_warmup_steps=WARMUP_STEPS, num_training_steps = -1)

For future visitors, see docs

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hsajjad picture hsajjad  路  3Comments

HansBambel picture HansBambel  路  3Comments

guanlongtianzi picture guanlongtianzi  路  3Comments

rsanjaykamath picture rsanjaykamath  路  3Comments

alphanlp picture alphanlp  路  3Comments