# Text classification with roberta

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftext-classification-with-roberta%2F21239%3E%5C
**Category:** Models\
**Created:** [August 4, 2022, 8:54am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftext-classification-with-roberta%2F21239 "2022-08-04T08:54:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anissou](https://avatars.discourse-cdn.com/v4/letter/a/278dde/32.png) [@Anissou](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FAnissou)%5C
**Post date:** [August 4, 2022, 8:54am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Ftext-classification-with-roberta%2F21239%2F1 "2022-08-04T08:54:55Z")

</div>

Hello guys,  
im trying to use a pretrained models from hugging face to my costume dataset (4 classes),  
the problem is that only one model that gave me no errors (distilbert-base-uncased),  
but I use other models like Roberta, I got dimensions problems !!! I don’t know how to fix it !

############### here is my code ###################  
from transformers import TFRobertaForSequenceClassification, TFAutoModelForSequenceClassification

model = TFRobertaForSequenceClassification.from\_pretrained(‘siebert/sentiment-roberta-large-english’,num\_labels=4)

optimizer = tf.keras.optimizers.Adam(learning\_rate=4e-4)

model.compile(optimizer=optimizer,  
loss=tf.keras.losses.SparseCategoricalCrossentropy(from\_logits=True),  
metrics=tf.metrics.SparseCategoricalAccuracy()) # can also use any keras loss fn

model.fit(train\_dataset.batch(16), epochs=30, batch\_size=16)

########## here is the error ###################  
cannot reshape array of size 2048 into shape (1024,4)

can someone help me plzzzz
