function

assignment.assignment_cost

def assignment_cost(cost: torch.Tensor, matches: torch.Tensor, reduction: str = 'sum') -> torch.Tensor

Compute the total cost of a LAP assignment.

Parameters

NameTypeDescription
costtorch.TensorCost matrix (N, M) or (B, N, M). float32 or float64.
matchestorch.TensorRow→col assignment (N,) or (B, N). int64. Unmatched rows have ``-1``.
reduction = 'sum'strHow to aggregate per-row costs: ``"sum"`` (default) sums all matched rows; ``"mean"`` divides by the number of matched rows; ``"none"`` returns per-row costs with unmatched rows set to 0.

Returns

total — Scalar for 2-D input or (B,) for 3-D input, unless ``reduction="none"``, in which case the shape is (N,) or (B, N).

Source: torchmatch/assignment/_cost.py:8