Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/pearson
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda authored Apr 26, 2023
2 parents f69221c + b3c8ebb commit 6ac7ab6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/torchmetrics/functional/classification/stat_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,17 +302,17 @@ def _multiclass_stat_scores_tensor_validation(
check = num_unique_values > num_classes if ignore_index is None else num_unique_values > num_classes + 1
if check:
raise RuntimeError(
"Detected more unique values in `target` than `num_classes`. Expected only "
f"{num_classes if ignore_index is None else num_classes + 1} but found"
f"{num_unique_values} in `target`."
"Detected more unique values in `target` than `num_classes`. Expected only"
f" {num_classes if ignore_index is None else num_classes + 1} but found"
f" {num_unique_values} in `target`."
)

if not preds.is_floating_point():
unique_values = torch.unique(preds)
if len(unique_values) > num_classes:
raise RuntimeError(
"Detected more unique values in `preds` than `num_classes`. Expected only "
f"{num_classes} but found {len(unique_values)} in `preds`."
"Detected more unique values in `preds` than `num_classes`. Expected only"
f" {num_classes} but found {len(unique_values)} in `preds`."
)


Expand Down

0 comments on commit 6ac7ab6

Please sign in to comment.