pygmtools.utils.gaussian_aff_fn

pygmtools.utils.gaussian_aff_fn(feat1, feat2, sigma=1.0, backend=None)[source]

Gaussian kernel affinity function. The affinity is defined as

\[\exp(-\frac{(\mathbf{f}_1 - \mathbf{f}_2)^2}{\sigma})\]
Parameters
  • feat1\((b\times n_1 \times f)\) the feature vectors \(\mathbf{f}_1\)

  • feat2\((b\times n_2 \times f)\) the feature vectors \(\mathbf{f}_2\)

  • sigma – (default: 1) the parameter \(\sigma\) in Gaussian kernel

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

Returns

\((b\times n_1\times n_2)\) element-wise Gaussian affinity matrix