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\). IfNone,SqEuclideanis used.epsilon (
Optional[float]) – Regularization parameter. SeePointCloudrelative_epsilon (
Optional[Literal['mean','std']]) – when False, the parameterepsilonspecifies the value of the entropic regularization parameter. When True,epsilonrefers to a fraction of themean_cost_matrix, which is computed adaptively usingsourceandtargetpoints.scale_cost (
Union[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 thatcost_matrix /= scale_cost.return_output (
bool) – boolean to also return theSinkhornOutput.kwargs (
Any) – holds the kwargs to instantiate the orSinkhornsolver to compute the regularized OT cost.
- Return type:
Union[float,Tuple[float,SinkhornOutput]]- Returns:
The Monge gap value and optionally the
SinkhornOutput