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
,SqEuclidean
is used.epsilon (
Optional
[float
]) – Regularization parameter. SeePointCloud
relative_epsilon (
Optional
[bool
]) – when False, the parameterepsilon
specifies the value of the entropic regularization parameter. When True,epsilon
refers to a fraction of themean_cost_matrix
, which is computed adaptively usingsource
andtarget
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 thatcost_matrix /= scale_cost
.return_output (
bool
) – boolean to also return theSinkhornOutput
.kwargs (
Any
) – holds the kwargs to instantiate the orSinkhorn
solver to compute the regularized OT cost.
- Return type:
- Returns:
The Monge gap value and optionally the
SinkhornOutput