Skip to content

Commit 69f97d5

Browse files
committed
Fix loss bug.
1 parent 05792b3 commit 69f97d5

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

deepks/model/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def loss_fn(input, target):
6060
diff = target - input
6161
if shrink and shrink > 0:
6262
diff = F.softshrink(diff, shrink)
63-
sqdf = diff ** 2
63+
sqdf = torch.abs(diff)**2 # use abs to avoid complex number
6464
if cap and cap > 0: # SmoothL2 loss
6565
abdf = diff.abs()
6666
sqdf = torch.where(abdf < cap, sqdf, cap * (2*abdf - cap))

0 commit comments

Comments
 (0)