Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
Update auc.py
Browse files Browse the repository at this point in the history
Not sure should it be more efficient leaving `torch.unique` at line #50 there or not.
  • Loading branch information
guoquan committed May 6, 2019
1 parent ad3c37c commit 839503a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion allennlp/training/metrics/auc.py
Expand Up @@ -52,7 +52,7 @@ def __call__(self,
raise ConfigurationError("AUC can be used for binary tasks only. gold_labels has {} unique labels, "
"expected at maximum 2.".format(unique_gold_labels.numel()))

gold_labels_is_binary = set(torch.sort(unique_gold_labels)[0].numpy()) <= set([0, 1])
gold_labels_is_binary = set(unique_gold_labels.tolist()) <= {0, 1}
if not gold_labels_is_binary and self._positive_label not in unique_gold_labels:
raise ConfigurationError("gold_labels should be binary with 0 and 1 or initialized positive_label "
"{} should be present in gold_labels".format(self._positive_label))
Expand Down

0 comments on commit 839503a

Please sign in to comment.