Skip to content

attachment_scores

allennlp.training.metrics.attachment_scores

[SOURCE]


AttachmentScores#

@Metric.register("attachment_scores")
class AttachmentScores(Metric):
 | def __init__(self, ignore_classes: List[int] = None) -> None

Computes labeled and unlabeled attachment scores for a dependency parse, as well as sentence level exact match for both labeled and unlabeled trees. Note that the input to this metric is the sampled predictions, not the distribution itself.

Parameters

  • ignore_classes : List[int], optional (default = None)
    A list of label ids to ignore when computing metrics.

__call__#

class AttachmentScores(Metric):
 | ...
 | def __call__(
 |     self,
 |     predicted_indices: torch.Tensor,
 |     predicted_labels: torch.Tensor,
 |     gold_indices: torch.Tensor,
 |     gold_labels: torch.Tensor,
 |     mask: Optional[torch.BoolTensor] = None
 | )

Parameters

  • predicted_indices : torch.Tensor
    A tensor of head index predictions of shape (batch_size, timesteps).
  • predicted_labels : torch.Tensor
    A tensor of arc label predictions of shape (batch_size, timesteps).
  • gold_indices : torch.Tensor
    A tensor of the same shape as predicted_indices.
  • gold_labels : torch.Tensor
    A tensor of the same shape as predicted_labels.
  • mask : torch.BoolTensor, optional (default = None)
    A tensor of the same shape as predicted_indices.

get_metric#

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

Returns

  • The accumulated metrics as a dictionary.

reset#

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