ImportError: cannot import name 'WarmupLinearSchedule'
Author: Dhanachandra
Pull request: no
Labels: name: wontfix

$ 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: thomas@huggingface.co
License: Apache
Location: /home/ubuntu/anaconda3/lib/python3.6/site-packages
Requires: numpy, requests, regex, sacremoses, tqdm, sentencepiece, boto3
Required-by: 


Comments:
It is in the [optimization.py](https://github.com/huggingface/transformers/blob/df99f8c5a1c54d64fb013b43107011390c3be0d5/transformers/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: [thomas@huggingface.co](mailto:thomas@huggingface.co)
> 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:

```python
scheduler = WarmupLinearSchedule(optimizer, warmup_steps=WARMUP_STEPS, t_total = -1)
```

becomes...

```python
scheduler = get_linear_schedule_with_warmup(optimizer, num_warmup_steps=WARMUP_STEPS, num_training_steps = -1)
```

For future visitors, see [docs](https://huggingface.co/transformers/main_classes/optimizer_schedules.html?highlight=get_linear_schedule_with_warmup#transformers.get_linear_schedule_with_warmup)

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.