There was an error while loading. Please reload this page.
1 parent 05792b3 commit 69f97d5Copy full SHA for 69f97d5
1 file changed
deepks/model/utils.py
@@ -60,7 +60,7 @@ def loss_fn(input, target):
60
diff = target - input
61
if shrink and shrink > 0:
62
diff = F.softshrink(diff, shrink)
63
- sqdf = diff ** 2
+ sqdf = torch.abs(diff)**2 # use abs to avoid complex number
64
if cap and cap > 0: # SmoothL2 loss
65
abdf = diff.abs()
66
sqdf = torch.where(abdf < cap, sqdf, cap * (2*abdf - cap))
0 commit comments