Skip to content

unigram_recall

allennlp.training.metrics.unigram_recall

[SOURCE]


UnigramRecall#

@Metric.register("unigram_recall")
class UnigramRecall(Metric):
 | def __init__(self) -> None

Unigram top-K recall. This does not take word order into account. Assumes integer labels, with each item to be classified having a single correct class.

__call__#

class UnigramRecall(Metric):
 | ...
 | def __call__(
 |     self,
 |     predictions: torch.Tensor,
 |     gold_labels: torch.Tensor,
 |     mask: Optional[torch.BoolTensor] = None,
 |     end_index: int = sys.maxsize
 | )

Parameters

  • predictions : torch.Tensor
    A tensor of predictions of shape (batch_size, k, sequence_length).
  • gold_labels : torch.Tensor
    A tensor of integer class label of shape (batch_size, sequence_length).
  • mask : torch.BoolTensor, optional (default = None)
    A masking tensor the same size as gold_labels.

get_metric#

class UnigramRecall(Metric):
 | ...
 | def get_metric(self, reset: bool = False)

Returns

  • The accumulated recall.

reset#

class UnigramRecall(Metric):
 | ...
 | @overrides
 | def reset(self)