From ee22aa661843a8432b00eb0c5acb53917bb3821e Mon Sep 17 00:00:00 2001 From: tianyu-z Date: Mon, 29 Jul 2024 03:27:31 -0400 Subject: [PATCH] update fix for pct loss --- rice.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rice.py b/rice.py index 8b78e74..ff85355 100644 --- a/rice.py +++ b/rice.py @@ -129,10 +129,10 @@ def softthreshold(self, x, threshold, bias=0): def percentage_adjustment(self, numerator, denominator): # This function is used to handle division by zero and small values - if np.abs(denominator) < 1e-3: - return 0 - elif np.abs(numerator) < 1e-3: + if np.abs(denominator) < 1e-2 and np.abs(numerator) < 1e-2: return 0 + elif np.abs(denominator) < 1e-2: + return 1e-2 else: return self.softthreshold(numerator / denominator - 1, 1e-3)