Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in ergas calculation #2498

Merged
merged 11 commits into from
Apr 15, 2024
2 changes: 1 addition & 1 deletion src/torchmetrics/functional/image/ergas.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _ergas_compute(
rmse_per_band = torch.sqrt(sum_squared_error / (h * w))
mean_target = torch.mean(target, dim=2)

ergas_score = 100 * ratio * torch.sqrt(torch.sum((rmse_per_band / mean_target) ** 2, dim=1) / c)
ergas_score = 100 / ratio * torch.sqrt(torch.sum((rmse_per_band / mean_target) ** 2, dim=1) / c)
return reduce(ergas_score, reduction)


Expand Down
2 changes: 1 addition & 1 deletion tests/unittests/image/test_ergas.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _reference_ergas(
rmse_per_band = torch.sqrt(sum_squared_error / (h * w))
mean_target = torch.mean(sk_target, dim=2)
# compute ergas score
ergas_score = 100 * ratio * torch.sqrt(torch.sum((rmse_per_band / mean_target) ** 2, dim=1) / c)
ergas_score = 100 / ratio * torch.sqrt(torch.sum((rmse_per_band / mean_target) ** 2, dim=1) / c)
# reduction
if reduction == "sum":
return torch.sum(ergas_score)
Expand Down
Loading