"vscode:/vscode.git/clone" did not exist on "2082f213c214b8b9d15a92ac98ebe63e2dd6c99d"
Commit 5a004f04 authored by Marta's avatar Marta
Browse files

zero out nan components in loss

parent 45a98436
......@@ -1473,6 +1473,9 @@ class AlphaFoldLoss(nn.Module):
weight = self.config[k].weight
if weight:
loss = loss_fn()
if(torch.isnan(loss) or torch.isinf(loss)):
logging.warning(f"{k} loss is NaN. Skipping example...")
loss = loss.new_tensor(0., requires_grad=True)
cum_loss = cum_loss + weight * loss
return cum_loss
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment