diff options
author | RĂ©mi Flamary <remi.flamary@gmail.com> | 2022-04-05 11:57:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-05 11:57:10 +0200 |
commit | ad02112d4288f3efdd5bc6fc6e45444313bba871 (patch) | |
tree | f6cd539450c2ed36cf5d7014debfd82e8b9fddfb /examples/plot_optim_OTreg.py | |
parent | 0afd84d744a472903d427e3c7ae32e55fdd7b9a7 (diff) |
[MRG] Update examples in the doc (#359)
* add transparent color logo
* add transparent color logo
* move screenkhorn
* move stochastic and install ffmpeg on circleci
* try something
* add sudo
* install ffmpeg before python
* cleanup examples
* test svg scrapper
* add animation for reg path
* better example OT sivergence
* update ttles and add plots
* update free support
* proper figure indexes
* have less frame sin animation
* update readme and release file
* add tests for python 3.10
Diffstat (limited to 'examples/plot_optim_OTreg.py')
-rw-r--r-- | examples/plot_optim_OTreg.py | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/examples/plot_optim_OTreg.py b/examples/plot_optim_OTreg.py index 5eb15bd..7b021d2 100644 --- a/examples/plot_optim_OTreg.py +++ b/examples/plot_optim_OTreg.py @@ -24,7 +24,7 @@ arXiv preprint arXiv:1510.06567. """ -# sphinx_gallery_thumbnail_number = 4 +# sphinx_gallery_thumbnail_number = 5 import numpy as np import matplotlib.pylab as pl @@ -58,7 +58,7 @@ M /= M.max() G0 = ot.emd(a, b, M) -pl.figure(3, figsize=(5, 5)) +pl.figure(1, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, G0, 'OT matrix G0') ############################################################################## @@ -80,7 +80,7 @@ reg = 1e-1 Gl2 = ot.optim.cg(a, b, M, reg, f, df, verbose=True) -pl.figure(3) +pl.figure(2) ot.plot.plot1D_mat(a, b, Gl2, 'OT matrix Frob. reg') ############################################################################## @@ -102,7 +102,7 @@ reg = 1e-3 Ge = ot.optim.cg(a, b, M, reg, f, df, verbose=True) -pl.figure(4, figsize=(5, 5)) +pl.figure(3, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, Ge, 'OT matrix Entrop. reg') ############################################################################## @@ -125,6 +125,34 @@ reg2 = 1e-1 Gel2 = ot.optim.gcg(a, b, M, reg1, reg2, f, df, verbose=True) -pl.figure(5, figsize=(5, 5)) +pl.figure(4, figsize=(5, 5)) ot.plot.plot1D_mat(a, b, Gel2, 'OT entropic + matrix Frob. reg') pl.show() + + +# %% +# Comparison of the OT matrices + +nvisu = 40 + +pl.figure(5, figsize=(10, 4)) + +pl.subplot(2, 2, 1) +pl.imshow(G0[:nvisu, :]) +pl.axis('off') +pl.title('Exact OT') + +pl.subplot(2, 2, 2) +pl.imshow(Gl2[:nvisu, :]) +pl.axis('off') +pl.title('Frobenius reg.') + +pl.subplot(2, 2, 3) +pl.imshow(Ge[:nvisu, :]) +pl.axis('off') +pl.title('Entropic reg.') + +pl.subplot(2, 2, 4) +pl.imshow(Gel2[:nvisu, :]) +pl.axis('off') +pl.title('Entropic + Frobenius reg.') |