mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Fix size compatibility for model.forward
Error was coming from "modeling_pytorch.py", line 484, in forward: start_loss = loss_fct(start_logits, start_positions) --> ValueError: Expected target size (12, 1), got torch.Size([12])
This commit is contained in:
parent
8cbe7d6af8
commit
beb59080b3
@ -840,6 +840,9 @@ def main():
|
||||
#label_ids = label_ids.to(device)
|
||||
start_positions = start_positions.to(device)
|
||||
end_positions = start_positions.to(device)
|
||||
|
||||
start_positions = start_positions.view(-1, 1)
|
||||
end_positions = end_positions.view(-1, 1)
|
||||
|
||||
loss, _ = model(input_ids, segment_ids, input_mask, start_positions, end_positions)
|
||||
loss.backward()
|
||||
|
Loading…
Reference in New Issue
Block a user