Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup examples
  • Loading branch information
rflamary committed Apr 4, 2022
commit a65ed521e172ed7a1f0bc903dd3f1f7390e5696d
8 changes: 4 additions & 4 deletions examples/backends/plot_wass1d_torch.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
r"""
=================================
Wasserstein 1D with PyTorch
=================================
=================================================
Wasserstein 1D (flow and barycenter) with PyTorch
=================================================

In this small example, we consider the following minization problem:
In this small example, we consider the following minimization problem:

.. math::
\mu^* = \min_\mu W(\mu,\nu)
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_OT_2D_samples.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
====================================================
2D Optimal transport between empirical distributions
Optimal Transport between 2D empirical distributions
====================================================

Illustration of 2D optimal transport between discributions that are weighted
Expand Down
24 changes: 12 additions & 12 deletions examples/plot_OT_L1_vs_L2.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
2D Optimal transport for different metrics
==========================================

2D OT on empirical distributio with different gound metric.
2D OT on empirical distributio with different ground metric.

Stole the figure idea from Fig. 1 and 2 in
https://arxiv.org/pdf/1706.07650.pdf
Expand All @@ -23,7 +23,7 @@
import ot
import ot.plot

##############################################################################
# %%
# Dataset 1 : uniform sampling
# ----------------------------

Expand All @@ -46,7 +46,7 @@
M2 /= M2.max()

# loss matrix
Mp = np.sqrt(ot.dist(xs, xt, metric='euclidean'))
Mp = ot.dist(xs, xt, metric='cityblock')
Mp /= Mp.max()

# Data
Expand All @@ -71,7 +71,7 @@

pl.subplot(1, 3, 3)
pl.imshow(Mp, interpolation='nearest')
pl.title('Sqrt Euclidean cost')
pl.title('L1 (cityblock cost')
pl.tight_layout()

##############################################################################
Expand Down Expand Up @@ -109,22 +109,22 @@
pl.plot(xt[:, 0], xt[:, 1], 'xr', label='Target samples')
pl.axis('equal')
# pl.legend(loc=0)
pl.title('OT sqrt Euclidean')
pl.title('OT L1 (cityblock)')
pl.tight_layout()

pl.show()


##############################################################################
# %%
# Dataset 2 : Partial circle
# --------------------------

n = 50 # nb samples
n = 20 # nb samples
xtot = np.zeros((n + 1, 2))
xtot[:, 0] = np.cos(
(np.arange(n + 1) + 1.0) * 0.9 / (n + 2) * 2 * np.pi)
(np.arange(n + 1) + 1.0) * 0.8 / (n + 2) * 2 * np.pi)
xtot[:, 1] = np.sin(
(np.arange(n + 1) + 1.0) * 0.9 / (n + 2) * 2 * np.pi)
(np.arange(n + 1) + 1.0) * 0.8 / (n + 2) * 2 * np.pi)

xs = xtot[:n, :]
xt = xtot[1:, :]
Expand All @@ -140,7 +140,7 @@
M2 /= M2.max()

# loss matrix
Mp = np.sqrt(ot.dist(xs, xt, metric='euclidean'))
Mp = ot.dist(xs, xt, metric='cityblock')
Mp /= Mp.max()


Expand All @@ -166,7 +166,7 @@

pl.subplot(1, 3, 3)
pl.imshow(Mp, interpolation='nearest')
pl.title('Sqrt Euclidean cost')
pl.title('L1 (cityblock) cost')
pl.tight_layout()

##############################################################################
Expand Down Expand Up @@ -204,7 +204,7 @@
pl.plot(xt[:, 0], xt[:, 1], 'xr', label='Target samples')
pl.axis('equal')
# pl.legend(loc=0)
pl.title('OT sqrt Euclidean')
pl.title('OT L1 (cityblock)')
pl.tight_layout()

pl.show()