torcheval.metrics.functional.num_collisions¶
- torcheval.metrics.functional.num_collisions(input: Tensor) Tensor ¶
Compute the number of collisions given a list of input(ids).
- Parameters:
input (Tensor) – a tensor of input ids (num_samples, ). class probabilities of shape (num_samples, num_classes).
Examples:
>>> import torch >>> from torcheval.metrics.functional import num_collisions >>> input = torch.tensor([3, 4, 2, 3]) >>> num_collisions(input) tensor([1, 0, 0, 1]) >>> input = torch.tensor([3, 4, 1, 3, 1, 1, 5]) >>> num_collisions(input) tensor([1, 0, 2, 1, 2, 2, 0])