Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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