Tensorflow XLMRoberta Multi-Class Problem
## Details

I am attempting to fine tune an XLMRoberta sequence classification model. I have an array of text snippets from physicians labelled 1-8 with various diagnostic indications. I've created a tensorflow dataset object with the 
```
convert_raw_to_xlmroberta_tfdataset()
```
 function seen here (https://stackoverflow.com/questions/62095316/tensorflow-xlmroberta-multi-class)

I then create the model:
```
from transformers import TFXLMRobertaForSequenceClassification
import tensorflow as tf



learning_rate = 2e-5

number_of_epochs = 2
model = TFXLMRobertaForSequenceClassification.from_pretrained("jplu/tf-xlm-roberta-base")
optimizer = tf.keras.optimizers.Adam(learning_rate=learning_rate, epsilon=1e-08)
loss = tf.keras.losses.SparseCategoricalCrossentropy()
metric = tf.keras.metrics.SparseCategoricalAccuracy('accuracy')
model.compile(optimizer=optimizer, loss=loss, metrics=[metric])
```
but consistently get this error:
```
ValueError: Shapes (None, 1, 8) and (None, 2) are incompatible
```
(full trace at the above SO link). 

I've tried both Sparse Categorical Cross Entropy and just Categorical Cross Entropy. I've used one-hot encoded labels and "normal" labels. Is it even possible to do multi-class classification with TFXLMRoberta? It started to work when I fed in a binary dummy set of labels.


Hello! If you're using 8 labels, you'll need to tell the model that it needs to do 8-way classification. You can do so by specifying the `num_labels` argument during instantiation:

```py
model = TFXLMRobertaForSequenceClassification.from_pretrained(
    "jplu/tf-xlm-roberta-base", 
    num_labels=8
)
```

Let me know if this fixes your issue.<|||||>Yes! That fixed the issue. I apologize for my oversight of that argument. Thank you very much for your time.<|||||>Sure, my pleasure!