ott.tools.sinkhorn_divergence.sinkhorn_divergence

ott.tools.sinkhorn_divergence.sinkhorn_divergence#

ott.tools.sinkhorn_divergence.sinkhorn_divergence(geom, *args, a=None, b=None, solve_kwargs=mappingproxy({}), static_b=False, offset_static_b=None, share_epsilon=True, symmetric_sinkhorn=True, **kwargs)[source]#

Compute Sinkhorn divergence between two measures.

The Sinkhorn divergence is computed between two measures \(\mu\) and \(\nu\) by specifying three Geometry objects, each describing pairwise costs within points in \(\mu,\nu\), \(\mu,\mu\), and \(\nu,\nu\).

This implementation proposes the most general interface, to generate those three geometries by specifying first the type of Geometry that is used to compare them, followed by the arguments used to generate these three Geometry instances through its corresponding prepare_divergences() method.

Parameters:
  • geom (Type[Geometry]) – Type of the geometry.

  • args (Any) – Positional arguments to prepare_divergences() that are specific to each geometry.

  • a (Optional[Array]) – the weight of each input point.

  • b (Optional[Array]) – the weight of each target point.

  • solve_kwargs (Mapping[str, Any]) – keywords arguments for solve() that is called either twice if static_b == True or three times when static_b == False.

  • static_b (bool) – if True, divergence of the second measure (with weights b) to itself is not recomputed.

  • offset_static_b (Optional[float]) – when static_b is True, use that value to offset computation. Useful when the value of the divergence of the second measure to itself is precomputed and not expected to change.

  • share_epsilon (bool) – if True, enforces that the same epsilon regularizer is shared for all 2 or 3 terms of the Sinkhorn divergence. In that case, the epsilon will be by default that used when comparing x to y (contained in the first geometry). This flag is set to True by default, because in the default setting, the epsilon regularization is a function of the std of the entries in the cost matrix.

  • symmetric_sinkhorn (bool) – Use Sinkhorn updates in Eq. 25 of [Feydy et al., 2019] for symmetric terms comparing x/x and y/y.

  • kwargs (Any) – keywords arguments to the generic class. This is specific to each geometry.

Return type:

Tuple[Array, SinkhornDivergenceOutput]

Returns:

The Sinkhorn divergence value, and output object detailing computations.