Skip to content

Commit 808350a

Browse files
committed
calc improvements
Signed-off-by: Akshat Sinha <akshatsinhasramhardy@gmail.com>
1 parent 4fb978b commit 808350a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

monai/metrics/regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def compute_mape_metric(y_pred: torch.Tensor, y: torch.Tensor, epsilon: float =
265265
MAPE value as percentage
266266
"""
267267
flt = partial(torch.flatten, start_dim=1)
268-
percentage_error = torch.abs((y - y_pred) / (torch.abs(y) + epsilon)) * 100.0
268+
percentage_error = torch.abs(y - y_pred) / torch.clamp(torch.abs(y), min=epsilon) * 100.0
269269
return torch.mean(flt(percentage_error), dim=-1, keepdim=True)
270270

271271

0 commit comments

Comments
 (0)