pygmtools.utils.compute_affinity_score

pygmtools.utils.compute_affinity_score(X, K, backend=None)[source]

Compute the affinity score of graph matching. It is the objective score of the corresponding Quadratic Assignment Problem.

\[\texttt{vec}(\mathbf{X})^\top \mathbf{K} \texttt{vec}(\mathbf{X})\]

here \(\texttt{vec}\) means column-wise vectorization.

Parameters
  • X\((b\times n_1 \times n_2)\) the permutation matrix that represents the matching result

  • K\((b\times n_1n_2 \times n_1n_2)\) the affinity matrix

  • backend – (default: pygmtools.BACKEND variable) the backend for computation.

Returns

\((b)\) the objective score

Note

This function also supports non-batched input if the first dimension of X, K is removed.