ott.solvers.linear.sinkhorn.SinkhornOutput#
- class ott.solvers.linear.sinkhorn.SinkhornOutput(f=None, g=None, errors=None, reg_ot_cost=None, ot_prob=None, threshold=None, converged=None, inner_iterations=None)[source]#
Holds the output of a Sinkhorn solver applied to a problem.
Objects of this class contain both solutions and problem definition of a regularized OT problem, along several methods that can be used to access its content, to, for instance, materialize an OT matrix or apply it to a vector (without having to materialize it when not needed).
- Parameters:
f (Array | None) – dual variables vector of size
ot.prob.shape[0]
returned by Sinkhorng (Array | None) – dual variables vector of size
ot.prob.shape[1]
returned by Sinkhornerrors (Array | None) – vector or errors, along iterations. This vector is of size
max_iterations // inner_iterations
where those were the parameters passed on to theSinkhorn
solver. For each entry indexed ati
,errors[i]
can be either a real non-negative value (meaning the algorithm recorded that error at thei * inner_iterations
iteration), ajnp.inf
value (meaning the algorithm computed that iteration but did not compute its error, because, for instance,i < min_iterations // inner_iterations
), or a-1
, meaning that execution was terminated before that iteration, because the criterion was found to be smaller thanthreshold
.reg_ot_cost (float | None) – the regularized optimal transport cost. By default this is the linear contribution + KL term. See
ent_reg_cost
,primal_cost
anddual_cost
for other objective values.ot_prob (LinearProblem | None) – stores the definition of the OT problem, including geometry, marginals, unbalanced regularizers, etc.
threshold (Array | None) – convergence threshold used to control the termination of the algorithm.
converged (bool | None) – whether the output corresponds to a solution whose error is below the convergence threshold.
inner_iterations (int | None) – number of iterations that were run between two computations of errors.
Methods
apply
(inputs[, axis, lse_mode])Apply the transport to a ndarray; axis=1 for its transpose.
cost_at_geom
(other_geom)Return reg-OT cost for matrix, evaluated at other cost matrix.
count
(value, /)Return number of occurrences of value.
index
(value[, start, stop])Return first index of value.
marginal
(axis)- param axis:
set
(**kwargs)Return a copy of self, with potential overwrites.
set_cost
(ot_prob, lse_mode, use_danskin)- param ot_prob:
Return the entropic map estimator.
transport_cost_at_geom
(other_geom)Return bare transport cost of current solution at any geometry.
Attributes
Alias for field number 6
Return dual transport cost, without considering regularizer.
Entropy regularized cost.
Alias for field number 2
Alias for field number 0
Alias for field number 1
Alias for field number 7
KL regularized OT transport cost.
Transport matrix if it can be instantiated.
Returns the total number of iterations that were needed to terminate.
Alias for field number 4
Return transport cost of current transport solution at geometry.
Alias for field number 3
Alias for field number 5
Sum of transport matrix.