TypeError: argmax(): argument 'input' (position 1) must be Tensor, not str

Viewed 411

My code was working fine and when I tried to run it today without changing anything I got the following error: TypeError: argmax(): argument 'input' (position 1) must be Tensor, not str

Would appreciate if help could be provided.

below is the code snippet where I am getting an error. I am using BERT mdoel

start_scores, end_scores = model(torch.tensor([input_ids]), # The tokens representing our input text. token_type_ids=torch.tensor( [segment_ids])) # The segment IDs to differentiate question from answer_text

# ======== Reconstruct Answer ========
# Find the tokens with the highest `start` and `end` scores.

answer_start = torch.argmax(start_scores)
answer_end = torch.argmax(end_scores)
0 Answers
Related