Below is my code
This is my code
enter review:nice
TypeError Traceback (most recent call last)
<ipython-input-72-a4ceaba31e28> in <cell line: 17>()
15 categories = [‘negative’, ‘neutral’, ‘positive’]
16 # Map the index to the corresponding category
—> 17 predicted_category = categories[predicted_index]
18
19 print(“Predicted category:”, predicted_category)
TypeError: only integer tensors of a single element can be converted to an index
I am expecting an output in the form of a predicted category for my input review
tokenizer = AutoTokenizer.from_pretrained(“mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis”)
model = AutoModel.from_pretrained(“mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis”, token=access_token)
above are the tokenizer and model that I am using
Simran Surve is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.