-
Notifications
You must be signed in to change notification settings - Fork 259
Open
Description
def safe_divide(a, b):
den = b.clamp(min=1e-9) + b.clamp(max=1e-9) # ???
den = den + den.eq(0).type(den.type()) * 1e-9
return a / den * b.ne(0).type(b.type())
and
b = torch.randn((1, 10))
print((b.clamp(min=1e-9) + b.clamp(max=1e-9)) == (b + 1e-9))
# output = tensor([[True, True, True, True, True, True, True, True, True, True]])
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels