XLNetForSequenceClassification Pretrained model unable to load
I tried loading the XLNet pretrained but this occurred. I've tried this before and it worked, however, now it doesn't. Any suggestion on how to fix this problem?

model = XLNetForSequenceClassification.from_pretrained("xlnet-large-cased", num_labels = 2)
model.to(device)


---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
&lt;ipython-input-55-d6f698a3714b&gt; in &lt;module&gt;()
----&gt; 1 model = XLNetForSequenceClassification.from_pretrained("xlnet-large-cased", num_labels = 2)
      2 model.to(device)

3 frames
/usr/local/lib/python3.6/dist-packages/torch/nn/modules/sparse.py in __init__(self, num_embeddings, embedding_dim, padding_idx, max_norm, norm_type, scale_grad_by_freq, sparse, _weight)
     95         self.scale_grad_by_freq = scale_grad_by_freq
     96         if _weight is None:
---&gt; 97             self.weight = Parameter(torch.Tensor(num_embeddings, embedding_dim))
     98             self.reset_parameters()
     99         else:

RuntimeError: Trying to create tensor with negative dimension -1: [-1, 1024]


You should import XLNetForSequenceClassification from transformers and not from pytorch-transformers. First, make sure transformers is installed:
&gt; pip install transformers

Then, in your code:
from transformers import XLNetForSequenceClassification
model = XLNetForSequenceClassification.from_pretrained(&quot;xlnet-large-cased&quot;, num_labels = 2)

This should work.
