ott.neural.methods.monge_gap.monge_gap_from_samples

ott.neural.methods.monge_gap.monge_gap_from_samples#

ott.neural.methods.monge_gap.monge_gap_from_samples(source, target, cost_fn=None, epsilon=None, relative_epsilon=None, scale_cost=1.0, return_output=False, **kwargs)[source]#

Monge gap, instantiated in terms of samples before / after applying map.

\[\frac{1}{n} \sum_{i=1}^n c(x_i, y_i)) - W_{c, \varepsilon}(\frac{1}{n}\sum_i \delta_{x_i}, \frac{1}{n}\sum_i \delta_{y_i})\]

where \(W_{c, \varepsilon}\) is an entropy-regularized optimal transport cost, the ent_reg_cost.

Parameters:
  • source (Array) – samples from first measure, array of shape [n, d].

  • target (Array) – samples from second measure, array of shape [n, d].

  • cost_fn (Optional[CostFn]) – a cost function between two points in dimension \(d\). If None, SqEuclidean is used.

  • epsilon (Optional[float]) – Regularization parameter. See PointCloud

  • relative_epsilon (Optional[bool]) – when False, the parameter epsilon specifies the value of the entropic regularization parameter. When True, epsilon refers to a fraction of the mean_cost_matrix, which is computed adaptively using source and target points.

  • scale_cost (Union[int, float, Literal['mean', 'max_cost', 'median']]) – option to rescale the cost matrix. Implemented scalings are ‘median’, ‘mean’ and ‘max_cost’. Alternatively, a float factor can be given to rescale the cost such that cost_matrix /= scale_cost.

  • return_output (bool) – boolean to also return the SinkhornOutput.

  • kwargs (Any) – holds the kwargs to instantiate the or Sinkhorn solver to compute the regularized OT cost.

Return type:

Union[float, Tuple[float, SinkhornOutput]]

Returns:

The Monge gap value and optionally the SinkhornOutput