MCPcopy Create free account
hub / github.com/PythonOT/POT / loss_linear_samples_batch

Function loss_linear_samples_batch

ot/batch/_linear.py:150–175  ·  view source on GitHub ↗

r"""Computes the linear optimal transport loss given samples and transport plan. This is the equivalent of calling `dist_batch` and then `loss_linear_batch`. Parameters ---------- X : array-like, shape (B, ns, d) Samples from source distribution Y : array-like, shape (B,

(X, Y, T, metric="l2")

Source from the content-addressed store, hash-verified

148
149
150def loss_linear_samples_batch(X, Y, T, metric="l2"):
151 r"""Computes the linear optimal transport loss given samples and transport plan. This is the equivalent of
152 calling `dist_batch` and then `loss_linear_batch`.
153
154 Parameters
155 ----------
156 X : array-like, shape (B, ns, d)
157 Samples from source distribution
158 Y : array-like, shape (B, nt, d)
159 Samples from target distribution
160 T : array-like, shape (B, ns, nt)
161 Transport plan
162 metric : str, optional
163 'sqeuclidean', 'euclidean', 'minkowski' or 'kl'
164 Returns
165 -------
166 loss : array-like, shape (B,)
167 Loss value for each batch element
168
169 See Also
170 --------
171 ot.batch.dist_batch : batched cost matrix computation for computing M.
172 ot.batch.solve_batch : solver for computing the optimal T.
173 """
174 M = dist_batch(X, Y, metric=metric)
175 return loss_linear_batch(M, T)
176
177
178def dist_batch(

Callers 1

test_metricsFunction · 0.90

Calls 2

dist_batchFunction · 0.85
loss_linear_batchFunction · 0.85

Tested by 1

test_metricsFunction · 0.72