From ad64aba2887d4de9658585accb1705f813e34578 Mon Sep 17 00:00:00 2001 From: Mikhail Edukov Date: Sun, 25 Oct 2026 13:04:50 +0300 Subject: [PATCH] docs: fix BinaryNormalizedEntropy examples --- .../metrics/classification/binary_normalized_entropy.py | 6 +++--- .../classification/binary_normalized_entropy.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/torcheval/metrics/classification/binary_normalized_entropy.py b/torcheval/metrics/classification/binary_normalized_entropy.py index 1e3ccd42..cc9e319c 100644 --- a/torcheval/metrics/classification/binary_normalized_entropy.py +++ b/torcheval/metrics/classification/binary_normalized_entropy.py @@ -46,12 +46,12 @@ class BinaryNormalizedEntropy(Metric[torch.Tensor]): tensor([1.4183], dtype=torch.float64) >>> metric = BinaryNormalizedEntropy() - >>> metric.update(torch.tensor([0.2, 0.3]), torch.tensor([1.0, 0.0]), torch.tensor([5.0, 1.0])) + >>> metric.update(torch.tensor([0.2, 0.3]), torch.tensor([1.0, 0.0]), weight=torch.tensor([5.0, 1.0])) >>> metric.compute() tensor([3.1087], dtype=torch.float64) - >>> metric = BinaryNormalizedEntropy(from_logits = True) - >>> metric.update(tensor([-1.3863, -0.8473]), torch.tensor([1.0, 0.0])) + >>> metric = BinaryNormalizedEntropy(from_logits=True) + >>> metric.update(torch.tensor([-1.3863, -0.8473]), torch.tensor([1.0, 0.0])) >>> metric.compute() tensor([1.4183], dtype=torch.float64) diff --git a/torcheval/metrics/functional/classification/binary_normalized_entropy.py b/torcheval/metrics/functional/classification/binary_normalized_entropy.py index 12b37cc7..87782d69 100644 --- a/torcheval/metrics/functional/classification/binary_normalized_entropy.py +++ b/torcheval/metrics/functional/classification/binary_normalized_entropy.py @@ -44,25 +44,25 @@ def binary_normalized_entropy( >>> input = torch.tensor([0.2, 0.3]) >>> target = torch.tensor([1.0, 0.0]) >>> weight = None - >>> binary_normalized_entropy(input, target, weight, from_logits=False) + >>> binary_normalized_entropy(input, target, weight=weight, from_logits=False) tensor(1.4183, dtype=torch.float64) >>> input = torch.tensor([0.2, 0.3]) >>> target = torch.tensor([1.0, 0.0]) >>> weight = torch.tensor([5.0, 1.0]) - >>> binary_normalized_entropy(input, target, weight, from_logits=False) + >>> binary_normalized_entropy(input, target, weight=weight, from_logits=False) tensor(3.1087, dtype=torch.float64) >>> input = torch.tensor([-1.3863, -0.8473]) >>> target = torch.tensor([1.0, 0.0]) >>> weight = None - >>> binary_normalized_entropy(input, target, weight, from_logits=True) + >>> binary_normalized_entropy(input, target, weight=weight, from_logits=True) tensor(1.4183, dtype=torch.float64) >>> input = torch.tensor([[0.2, 0.3], [0.5, 0.1]]) >>> target = torch.tensor([[1.0, 0.0], [0.0, 1.0]]) >>> weight = None - >>> binary_normalized_entropy(input, target, weight, from_logits=True) + >>> binary_normalized_entropy(input, target, weight=weight, num_tasks=2, from_logits=False) tensor([1.4183, 2.1610], dtype=torch.float64) """ cross_entropy, num_positive, num_examples = _binary_normalized_entropy_update(