Trying to make a classifier for sentiments of texts with BERT model but getting ValueError : too many dimensions 'str'
That is the DataFrame for values of train data; so they are train_labels
0 notr
1 notr
2 notr
3 negative
4 notr
... ...
854 positive
855 notr
856 notr
857 notr
858 positive
and there is the code which is producing the error for
train_seq = torch.tensor(tokens_train['input_ids'])
train_mask = torch.tensor(tokens_train['attention_mask'])
train_y = torch.tensor(train_labels.tolist())
At train_y = torch.tensor(train_labels.tolist());
getting error:
ValueError: too many dimensions 'str'
can you help me pleaseenter image description here
enter image description here
I had the same problem:
This worksfor me I guess you need to do it at the beginning of your code after reading csv:
df['labels'] = df['labels'].replace(['negative','notr','positive'],[0,1,2])
then split for training and testing from these labels.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With