It looks like an Exception happened when trying to execute the following code:
pdb.set_trace()
loss, acc, bsz = model(batch["eq_tokens"], batch["wd_tokens"], batch["tgt_processed_tokens"], args.label_smoothing)
which caused loss
to be set to None
as per your line 265:
loss = acc = bsz = None
Hence, when you tried to call loss.item()
, your code raises an exception as loss
is None
.
As to why you get this Exception, you should try to output the trace of the error when you catch it in line 264.
Please also note that calling tensor.item()
during the forward pass is considered bad practice because it will cause unnecessary CPU/GPU transfers and slow down the training loop. Consider using tensor.detach()
and/or a proper metric tracker like the ones provided by torchmetrics
.