Skip to content

Instantly share code, notes, and snippets.

@BloodAxe
Created August 19, 2020 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BloodAxe/396010353909fc4e6342009c8d40b7b7 to your computer and use it in GitHub Desktop.
Save BloodAxe/396010353909fc4e6342009c8d40b7b7 to your computer and use it in GitHub Desktop.
import torch
def main():
torch.autograd.detect_anomaly()
...
# Rest of the training code
# OR
class MyNumericallyUnstableLoss(nn.Module):
def forward(self, input, target):
with torch.autograd.set_detect_anomaly(True):
loss = input * target
return loss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment