Skip to content

Commit

Permalink
fix model export when early stop=weight diff(#4659)
Browse files Browse the repository at this point in the history
Signed-off-by: Yu Wu <yolandawu131@gmail.com>
Signed-off-by: sagewe <wbwmat@gmail.com>
  • Loading branch information
nemirorox authored and sagewe committed Jul 21, 2023
1 parent 9e70e1e commit b77563a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion python/fate/ml/utils/_convergence.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ def __init__(self, eps):
def is_converge(self, delta_weight, weight=None):
weight_diff = torch.linalg.norm(delta_weight, 2)
if weight is None:
return weight_diff < self.eps
# avoid tensor[bool]
if weight_diff < self.eps:
return True
return False
if self.pre_weight is None:
self.pre_weight = weight
return False
Expand Down

0 comments on commit b77563a

Please sign in to comment.