Click here to Skip to main content
15,882,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i am new to nlp and i want to build a bert model for sentiment Analysis so i am following this tuto
https://curiousily.com/posts/sentiment-analysis-with-bert-and-hugging-face-using-pytorch-and-python/
but i am getting the error bellow

What I have tried:

F.softmax(model(input_ids, attention_mask), dim = 1)

When i want to execute this cell I get an error:
dropout(): argument 'input' (position 1) must be Tensor, not str
Posted
Updated 26-Dec-20 21:33pm
v3

1 solution

The error message could not be clearer. You are passing a string where it expects a Tensor object. But your question would be better directed to the writer of the tutorial.
 
Share this answer
 
Comments
mohamed amine boukriba 27-Dec-20 7:05am    
NO i am not passing a string this the code for checking the tensors
print(input_ids.shape)
print(attention_mask.shape)
and i am getting:
torch.Size([16, 202])
torch.Size([16, 202])
Richard MacCutchan 27-Dec-20 7:12am    
Well that is what the error message says, and I cannot see the code that causes the problem.
mohamed amine boukriba 27-Dec-20 7:35am    
check the tuto there s code there maybe you ll find something
Richard MacCutchan 27-Dec-20 7:42am    
Sorry, that is your job.
mohamed amine boukriba 27-Dec-20 7:53am    
hahaha i already did that and i didn't come with anything i thought maybe you could

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900