UserWarning: The number of elements in the out tensor of shape [1] is 1 
Author: lenyabloko
Pull request: no
Labels: name: wontfix

name: PyTorch

# ❓ Questions & Help

<!-- The GitHub issue tracker is primarly intended for bugs, feature requests,
     new models and benchmarks, and migration questions. For all other questions,
     we direct you to Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. Make sure to tag your question with the
     right deep learning framework as well as the huggingface-transformers tag: 
     https://stackoverflow.com/questions/tagged/huggingface-transformers 
     
     If your question wasn't answered after a period of time on Stack Overflow, you
     can always open a question on GitHub. You should then link to the SO question 
     that you posted.
     -->

## Details
<!-- Description of your issue -->
I am using HuggingFace pytorch-transformers and one of my pre-trained models refuse to fine tune giving me those UserWarnings for every torch.utils.data.DataLoader call.

I have described the details in  https://stackoverflow.com/questions/60218634/userwarning-the-number-of-elements-in-the-out-tensor-of-shape-1-is-1

Here is my Notebook so you can run and see the results:
https://colab.research.google.com/drive/1mq9RZ_BX1O5vgxCM0CvPzAm9YVKnq4DQ

But someone downgraded my question for some  reason. What am I missing?



Thanks for your help!
<!-- You should first ask your question on SO, and only if
     you didn't get an answer ask it here on GitHub. -->

**A link to original question on Stack Overflow**:  https://stackoverflow.com/questions/60218634/userwarning-the-number-of-elements-in-the-out-tensor-of-shape-1-is-1

Comments:
It is likely that your SO question was downvoted because it is a lot of unreproducible code, and not a lot of explanation. In other words: when someone reads your qusetion, it is almost impossible to answer because we cannot try your code ourselves. Try reducing it to a minimal, verifiable, executable example.

That being said: you are mixing conda and pip installations, which is a drag. Also you don't need to install pytorch-transformers AND transformers. The latter is the successor to the former, so you should only install one or the other (preferably only transformers), and fix your imports accordingly. Just install everything with pip, is my advice.

Thanks for your answer. I am following your suggestions. However when I replace
```
from pytorch_transformers import AdamW, WarmupLinearSchedule
```
with 

```
from transformers import AdamW, WarmupLinearSchedule

```

I get this error

```
ImportError                               Traceback (most recent call last)
<ipython-input-7-fc8519a4dbdc> in <module>()
     19                                   RobertaConfig, RobertaForSequenceClassification, RobertaTokenizer)
     20 
---> 21 from transformers import AdamW, WarmupLinearSchedule
     22 
     23 from utils import (convert_examples_to_features,output_modes, processors)

ImportError: cannot import name 'WarmupLinearSchedule'
```
Can you help me  out?
Thanks


You are probably looking for

https://github.com/huggingface/transformers/blob/20fc18fbda3669c2f4a3510e0705b2acd54bff07/src/transformers/optimization.py#L47-L59

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.