diff options
author | Rémi Flamary <remi.flamary@gmail.com> | 2017-08-30 17:10:22 +0200 |
---|---|---|
committer | Rémi Flamary <remi.flamary@gmail.com> | 2017-08-30 17:10:22 +0200 |
commit | 164dc24d7cdf61acd045f6b879ae2955b7dfcd18 (patch) | |
tree | ff0a9c03bca5e72a3b152b7755b5b24417113cc8 /docs/source/auto_examples/plot_optim_OTreg.py | |
parent | ab5918b2e2dc88a3520c059e6a79a6f81959381e (diff) |
example+rst titles
Diffstat (limited to 'docs/source/auto_examples/plot_optim_OTreg.py')
-rw-r--r-- | docs/source/auto_examples/plot_optim_OTreg.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/docs/source/auto_examples/plot_optim_OTreg.py b/docs/source/auto_examples/plot_optim_OTreg.py index 276b250..d36b269 100644 --- a/docs/source/auto_examples/plot_optim_OTreg.py +++ b/docs/source/auto_examples/plot_optim_OTreg.py @@ -12,6 +12,10 @@ import matplotlib.pylab as pl import ot +############################################################################## +# Generate data +############################################################################## + #%% parameters n = 100 # nb bins @@ -27,6 +31,10 @@ b = ot.datasets.get_1D_gauss(n, m=60, s=10) M = ot.dist(x.reshape((n, 1)), x.reshape((n, 1))) M /= M.max() +############################################################################## +# Solve EMD +############################################################################## + #%% EMD G0 = ot.emd(a, b, M) @@ -34,6 +42,10 @@ G0 = ot.emd(a, b, M) pl.figure(3, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, G0, 'OT matrix G0') +############################################################################## +# Solve EMD with Frobenius norm regularization +############################################################################## + #%% Example with Frobenius norm regularization @@ -52,6 +64,10 @@ Gl2 = ot.optim.cg(a, b, M, reg, f, df, verbose=True) pl.figure(3) ot.plot.plot1D_mat(a, b, Gl2, 'OT matrix Frob. reg') +############################################################################## +# Solve EMD with entropic regularization +############################################################################## + #%% Example with entropic regularization @@ -70,8 +86,11 @@ Ge = ot.optim.cg(a, b, M, reg, f, df, verbose=True) pl.figure(4, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, Ge, 'OT matrix Entrop. reg') -#%% Example with Frobenius norm + entropic regularization with gcg +############################################################################## +# Solve EMD with Frobenius norm + entropic regularization +############################################################################## +#%% Example with Frobenius norm + entropic regularization with gcg def f(G): return 0.5 * np.sum(G**2) |