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")
| 148 | |
| 149 | |
| 150 | def 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 | |
| 178 | def dist_batch( |