ThilinaRajapakse/BERT_binary_text_classification

error in BERT_evel.ipynb

jxy-001 opened this issue · 2 comments

tmp_eval_loss = loss_fct(logits.view(-1, num_labels), label_ids.view(-1))

AttributeError: 'tuple' object has no attribute 'view'

You are getting this because you are using the updated BERT library. There the model outputs are tuples.
Change the line from:
logits = model(input_ids, segment_ids, input_mask, labels=None)

to:
logits = model(input_ids, segment_ids, input_mask, labels=None)[0]

See #9

thanks a lot!