transport.matrix.marginal_error
def marginal_error(log_plan: torch.Tensor, a: torch.Tensor, b: torch.Tensor) -> tuple[float, float]Compute the max marginal error of a log-domain transport plan.
Useful for checking Sinkhorn convergence quality after ``solve()``.
Works with any backend that returns a log-plan (``LOG_SINKHORN``,
``UNBALANCED_SINKHORN``, ``EXACT_EMD``).
Parameters
| Name | Type | Description |
|---|---|---|
| log_plan | torch.Tensor | Log-domain transport plan (B, N, M) or (N, M), as returned by ``solve()``. |
| a | torch.Tensor | Source marginals (B, N) or (N,). Must match the ``a`` passed to ``solve()``, or uniform weights if ``a=None`` was used. |
| b | torch.Tensor | Target marginals (B, M) or (M,). |
Returns
(row_err, col_err) — Max absolute deviation of plan row-sums and col-sums from ``a`` and ``b``, respectively.
Source: torchmatch/transport/matrix/_solve.py:231