summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRémi Flamary <remi.flamary@gmail.com>2018-09-24 11:00:14 +0200
committerRémi Flamary <remi.flamary@gmail.com>2018-09-24 11:00:14 +0200
commitae1ede4ed31973213b5945721b7b9fe8e4992a1c (patch)
tree1ba2f750b21f6666e808c7ebc7e476f36996ddac /docs
parent9fb56beed1ca54bf3913f6a9ea589173b2a5097f (diff)
update doc+notebooks for convolutional
Diffstat (limited to 'docs')
-rw-r--r--docs/cache_nbrun2
-rw-r--r--docs/source/auto_examples/auto_examples_jupyter.zipbin119618 -> 123577 bytes
-rw-r--r--docs/source/auto_examples/auto_examples_python.zipbin79365 -> 81978 bytes
-rw-r--r--docs/source/auto_examples/images/sphx_glr_plot_convolutional_barycenter_001.pngbin0 -> 319138 bytes
-rw-r--r--docs/source/auto_examples/images/thumb/sphx_glr_plot_convolutional_barycenter_thumb.pngbin0 -> 54369 bytes
-rw-r--r--docs/source/auto_examples/index.rst20
-rw-r--r--docs/source/auto_examples/plot_convolutional_barycenter.ipynb90
-rw-r--r--docs/source/auto_examples/plot_convolutional_barycenter.py92
-rw-r--r--docs/source/auto_examples/plot_convolutional_barycenter.rst151
9 files changed, 354 insertions, 1 deletions
diff --git a/docs/cache_nbrun b/docs/cache_nbrun
index 0745a21..575adc8 100644
--- a/docs/cache_nbrun
+++ b/docs/cache_nbrun
@@ -1 +1 @@
-{"plot_otda_mapping_colors_images.ipynb": "4f0587a00a3c082799a75a0ed36e9ce1", "plot_optim_OTreg.ipynb": "481801bb0d133ef350a65179cf8f739a", "plot_otda_color_images.ipynb": "d047d635f4987c81072383241590e21f", "plot_stochastic.ipynb": "e2c520150378ae4635f74509f687fa01", "plot_WDA.ipynb": "27f8de4c6d7db46497076523673eedfb", "plot_otda_linear_mapping.ipynb": "a472c767abe82020e0a58125a528785c", "plot_OT_1D_smooth.ipynb": "3a059103652225a0c78ea53895cf79e5", "plot_OT_L1_vs_L2.ipynb": "5d565b8aaf03be4309eba731127851dc", "plot_barycenter_1D.ipynb": "5f6fb8aebd8e2e91ebc77c923cb112b3", "plot_otda_classes.ipynb": "39087b6e98217851575f2271c22853a4", "plot_otda_d2.ipynb": "e6feae588103f2a8fab942e5f4eff483", "plot_otda_mapping.ipynb": "2f1ebbdc0f855d9e2b7adf9edec24d25", "plot_gromov.ipynb": "24f2aea489714d34779521f46d5e2c47", "plot_compute_emd.ipynb": "f5cd71cad882ec157dc8222721e9820c", "plot_OT_1D.ipynb": "b5348bdc561c07ec168a1622e5af4b93", "plot_gromov_barycenter.ipynb": "953e5047b886ec69ec621ec52f5e21d1", "plot_free_support_barycenter.ipynb": "246dd2feff4b233a4f1a553c5a202fdc", "plot_otda_semi_supervised.ipynb": "f6dfb02ba2bbd939408ffcd22a3b007c", "plot_OT_2D_samples.ipynb": "07dbc14859fa019a966caa79fa0825bd", "plot_barycenter_lp_vs_entropic.ipynb": "51833e8c76aaedeba9599ac7a30eb357"} \ No newline at end of file
+{"plot_otda_mapping_colors_images.ipynb": "4f0587a00a3c082799a75a0ed36e9ce1", "plot_optim_OTreg.ipynb": "481801bb0d133ef350a65179cf8f739a", "plot_barycenter_1D.ipynb": "5f6fb8aebd8e2e91ebc77c923cb112b3", "plot_stochastic.ipynb": "e2c520150378ae4635f74509f687fa01", "plot_WDA.ipynb": "27f8de4c6d7db46497076523673eedfb", "plot_otda_linear_mapping.ipynb": "a472c767abe82020e0a58125a528785c", "plot_OT_1D_smooth.ipynb": "3a059103652225a0c78ea53895cf79e5", "plot_OT_L1_vs_L2.ipynb": "5d565b8aaf03be4309eba731127851dc", "plot_otda_color_images.ipynb": "d047d635f4987c81072383241590e21f", "plot_otda_classes.ipynb": "39087b6e98217851575f2271c22853a4", "plot_otda_d2.ipynb": "e6feae588103f2a8fab942e5f4eff483", "plot_otda_mapping.ipynb": "2f1ebbdc0f855d9e2b7adf9edec24d25", "plot_gromov.ipynb": "24f2aea489714d34779521f46d5e2c47", "plot_compute_emd.ipynb": "f5cd71cad882ec157dc8222721e9820c", "plot_OT_1D.ipynb": "b5348bdc561c07ec168a1622e5af4b93", "plot_gromov_barycenter.ipynb": "953e5047b886ec69ec621ec52f5e21d1", "plot_free_support_barycenter.ipynb": "246dd2feff4b233a4f1a553c5a202fdc", "plot_convolutional_barycenter.ipynb": "a72bb3716a1baaffd81ae267a673f9b6", "plot_otda_semi_supervised.ipynb": "f6dfb02ba2bbd939408ffcd22a3b007c", "plot_OT_2D_samples.ipynb": "07dbc14859fa019a966caa79fa0825bd", "plot_barycenter_lp_vs_entropic.ipynb": "51833e8c76aaedeba9599ac7a30eb357"} \ No newline at end of file
diff --git a/docs/source/auto_examples/auto_examples_jupyter.zip b/docs/source/auto_examples/auto_examples_jupyter.zip
index c6a7e90..304bb06 100644
--- a/docs/source/auto_examples/auto_examples_jupyter.zip
+++ b/docs/source/auto_examples/auto_examples_jupyter.zip
Binary files differ
diff --git a/docs/source/auto_examples/auto_examples_python.zip b/docs/source/auto_examples/auto_examples_python.zip
index 28ff08e..3be8a76 100644
--- a/docs/source/auto_examples/auto_examples_python.zip
+++ b/docs/source/auto_examples/auto_examples_python.zip
Binary files differ
diff --git a/docs/source/auto_examples/images/sphx_glr_plot_convolutional_barycenter_001.png b/docs/source/auto_examples/images/sphx_glr_plot_convolutional_barycenter_001.png
new file mode 100644
index 0000000..14a72a3
--- /dev/null
+++ b/docs/source/auto_examples/images/sphx_glr_plot_convolutional_barycenter_001.png
Binary files differ
diff --git a/docs/source/auto_examples/images/thumb/sphx_glr_plot_convolutional_barycenter_thumb.png b/docs/source/auto_examples/images/thumb/sphx_glr_plot_convolutional_barycenter_thumb.png
new file mode 100644
index 0000000..af8aad2
--- /dev/null
+++ b/docs/source/auto_examples/images/thumb/sphx_glr_plot_convolutional_barycenter_thumb.png
Binary files differ
diff --git a/docs/source/auto_examples/index.rst b/docs/source/auto_examples/index.rst
index 5cbfba6..259fca1 100644
--- a/docs/source/auto_examples/index.rst
+++ b/docs/source/auto_examples/index.rst
@@ -149,6 +149,26 @@ This is a gallery of all the POT example files.
.. raw:: html
+ <div class="sphx-glr-thumbcontainer" tooltip="This example is designed to illustrate how the Convolutional Wasserstein Barycenter function of...">
+
+.. only:: html
+
+ .. figure:: /auto_examples/images/thumb/sphx_glr_plot_convolutional_barycenter_thumb.png
+
+ :ref:`sphx_glr_auto_examples_plot_convolutional_barycenter.py`
+
+.. raw:: html
+
+ </div>
+
+
+.. toctree::
+ :hidden:
+
+ /auto_examples/plot_convolutional_barycenter
+
+.. raw:: html
+
<div class="sphx-glr-thumbcontainer" tooltip=" ">
.. only:: html
diff --git a/docs/source/auto_examples/plot_convolutional_barycenter.ipynb b/docs/source/auto_examples/plot_convolutional_barycenter.ipynb
new file mode 100644
index 0000000..4981ba3
--- /dev/null
+++ b/docs/source/auto_examples/plot_convolutional_barycenter.ipynb
@@ -0,0 +1,90 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "%matplotlib inline"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "\n# Convolutional Wasserstein Barycenter example\n\n\nThis example is designed to illustrate how the Convolutional Wasserstein Barycenter\nfunction of POT works.\n\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "# Author: Nicolas Courty <ncourty@irisa.fr>\n#\n# License: MIT License\n\n\nimport numpy as np\nimport pylab as pl\nimport ot"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Data preparation\n----------------\n\nThe four distributions are constructed from 4 simple images\n\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "f1 = 1 - pl.imread('../data/redcross.png')[:, :, 2]\nf2 = 1 - pl.imread('../data/duck.png')[:, :, 2]\nf3 = 1 - pl.imread('../data/heart.png')[:, :, 2]\nf4 = 1 - pl.imread('../data/tooth.png')[:, :, 2]\n\nA = []\nf1 = f1 / np.sum(f1)\nf2 = f2 / np.sum(f2)\nf3 = f3 / np.sum(f3)\nf4 = f4 / np.sum(f4)\nA.append(f1)\nA.append(f2)\nA.append(f3)\nA.append(f4)\nA = np.array(A)\n\nnb_images = 5\n\n# those are the four corners coordinates that will be interpolated by bilinear\n# interpolation\nv1 = np.array((1, 0, 0, 0))\nv2 = np.array((0, 1, 0, 0))\nv3 = np.array((0, 0, 1, 0))\nv4 = np.array((0, 0, 0, 1))"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Barycenter computation and visualization\n----------------------------------------\n\n\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "pl.figure(figsize=(10, 10))\npl.title('Convolutional Wasserstein Barycenters in POT')\ncm = 'Blues'\n# regularization parameter\nreg = 0.004\nfor i in range(nb_images):\n for j in range(nb_images):\n pl.subplot(nb_images, nb_images, i * nb_images + j + 1)\n tx = float(i) / (nb_images - 1)\n ty = float(j) / (nb_images - 1)\n\n # weights are constructed by bilinear interpolation\n tmp1 = (1 - tx) * v1 + tx * v2\n tmp2 = (1 - tx) * v3 + tx * v4\n weights = (1 - ty) * tmp1 + ty * tmp2\n\n if i == 0 and j == 0:\n pl.imshow(f1, cmap=cm)\n pl.axis('off')\n elif i == 0 and j == (nb_images - 1):\n pl.imshow(f3, cmap=cm)\n pl.axis('off')\n elif i == (nb_images - 1) and j == 0:\n pl.imshow(f2, cmap=cm)\n pl.axis('off')\n elif i == (nb_images - 1) and j == (nb_images - 1):\n pl.imshow(f4, cmap=cm)\n pl.axis('off')\n else:\n # call to barycenter computation\n pl.imshow(ot.bregman.convolutional_barycenter2d(A, reg, weights), cmap=cm)\n pl.axis('off')\npl.show()"
+ ]
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.6.5"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+} \ No newline at end of file
diff --git a/docs/source/auto_examples/plot_convolutional_barycenter.py b/docs/source/auto_examples/plot_convolutional_barycenter.py
new file mode 100644
index 0000000..e74db04
--- /dev/null
+++ b/docs/source/auto_examples/plot_convolutional_barycenter.py
@@ -0,0 +1,92 @@
+
+#%%
+# -*- coding: utf-8 -*-
+"""
+============================================
+Convolutional Wasserstein Barycenter example
+============================================
+
+This example is designed to illustrate how the Convolutional Wasserstein Barycenter
+function of POT works.
+"""
+
+# Author: Nicolas Courty <ncourty@irisa.fr>
+#
+# License: MIT License
+
+
+import numpy as np
+import pylab as pl
+import ot
+
+##############################################################################
+# Data preparation
+# ----------------
+#
+# The four distributions are constructed from 4 simple images
+
+
+f1 = 1 - pl.imread('../data/redcross.png')[:, :, 2]
+f2 = 1 - pl.imread('../data/duck.png')[:, :, 2]
+f3 = 1 - pl.imread('../data/heart.png')[:, :, 2]
+f4 = 1 - pl.imread('../data/tooth.png')[:, :, 2]
+
+A = []
+f1 = f1 / np.sum(f1)
+f2 = f2 / np.sum(f2)
+f3 = f3 / np.sum(f3)
+f4 = f4 / np.sum(f4)
+A.append(f1)
+A.append(f2)
+A.append(f3)
+A.append(f4)
+A = np.array(A)
+
+nb_images = 5
+
+# those are the four corners coordinates that will be interpolated by bilinear
+# interpolation
+v1 = np.array((1, 0, 0, 0))
+v2 = np.array((0, 1, 0, 0))
+v3 = np.array((0, 0, 1, 0))
+v4 = np.array((0, 0, 0, 1))
+
+
+##############################################################################
+# Barycenter computation and visualization
+# ----------------------------------------
+#
+
+pl.figure(figsize=(10, 10))
+pl.title('Convolutional Wasserstein Barycenters in POT')
+cm = 'Blues'
+# regularization parameter
+reg = 0.004
+for i in range(nb_images):
+ for j in range(nb_images):
+ pl.subplot(nb_images, nb_images, i * nb_images + j + 1)
+ tx = float(i) / (nb_images - 1)
+ ty = float(j) / (nb_images - 1)
+
+ # weights are constructed by bilinear interpolation
+ tmp1 = (1 - tx) * v1 + tx * v2
+ tmp2 = (1 - tx) * v3 + tx * v4
+ weights = (1 - ty) * tmp1 + ty * tmp2
+
+ if i == 0 and j == 0:
+ pl.imshow(f1, cmap=cm)
+ pl.axis('off')
+ elif i == 0 and j == (nb_images - 1):
+ pl.imshow(f3, cmap=cm)
+ pl.axis('off')
+ elif i == (nb_images - 1) and j == 0:
+ pl.imshow(f2, cmap=cm)
+ pl.axis('off')
+ elif i == (nb_images - 1) and j == (nb_images - 1):
+ pl.imshow(f4, cmap=cm)
+ pl.axis('off')
+ else:
+ # call to barycenter computation
+ pl.imshow(ot.bregman.convolutional_barycenter2d(A, reg, weights), cmap=cm)
+ pl.axis('off')
+pl.show()
diff --git a/docs/source/auto_examples/plot_convolutional_barycenter.rst b/docs/source/auto_examples/plot_convolutional_barycenter.rst
new file mode 100644
index 0000000..a28db2f
--- /dev/null
+++ b/docs/source/auto_examples/plot_convolutional_barycenter.rst
@@ -0,0 +1,151 @@
+
+
+.. _sphx_glr_auto_examples_plot_convolutional_barycenter.py:
+
+
+============================================
+Convolutional Wasserstein Barycenter example
+============================================
+
+This example is designed to illustrate how the Convolutional Wasserstein Barycenter
+function of POT works.
+
+
+
+.. code-block:: python
+
+
+ # Author: Nicolas Courty <ncourty@irisa.fr>
+ #
+ # License: MIT License
+
+
+ import numpy as np
+ import pylab as pl
+ import ot
+
+
+
+
+
+
+
+Data preparation
+----------------
+
+The four distributions are constructed from 4 simple images
+
+
+
+.. code-block:: python
+
+
+
+ f1 = 1 - pl.imread('../data/redcross.png')[:, :, 2]
+ f2 = 1 - pl.imread('../data/duck.png')[:, :, 2]
+ f3 = 1 - pl.imread('../data/heart.png')[:, :, 2]
+ f4 = 1 - pl.imread('../data/tooth.png')[:, :, 2]
+
+ A = []
+ f1 = f1 / np.sum(f1)
+ f2 = f2 / np.sum(f2)
+ f3 = f3 / np.sum(f3)
+ f4 = f4 / np.sum(f4)
+ A.append(f1)
+ A.append(f2)
+ A.append(f3)
+ A.append(f4)
+ A = np.array(A)
+
+ nb_images = 5
+
+ # those are the four corners coordinates that will be interpolated by bilinear
+ # interpolation
+ v1 = np.array((1, 0, 0, 0))
+ v2 = np.array((0, 1, 0, 0))
+ v3 = np.array((0, 0, 1, 0))
+ v4 = np.array((0, 0, 0, 1))
+
+
+
+
+
+
+
+
+Barycenter computation and visualization
+----------------------------------------
+
+
+
+
+.. code-block:: python
+
+
+ pl.figure(figsize=(10, 10))
+ pl.title('Convolutional Wasserstein Barycenters in POT')
+ cm = 'Blues'
+ # regularization parameter
+ reg = 0.004
+ for i in range(nb_images):
+ for j in range(nb_images):
+ pl.subplot(nb_images, nb_images, i * nb_images + j + 1)
+ tx = float(i) / (nb_images - 1)
+ ty = float(j) / (nb_images - 1)
+
+ # weights are constructed by bilinear interpolation
+ tmp1 = (1 - tx) * v1 + tx * v2
+ tmp2 = (1 - tx) * v3 + tx * v4
+ weights = (1 - ty) * tmp1 + ty * tmp2
+
+ if i == 0 and j == 0:
+ pl.imshow(f1, cmap=cm)
+ pl.axis('off')
+ elif i == 0 and j == (nb_images - 1):
+ pl.imshow(f3, cmap=cm)
+ pl.axis('off')
+ elif i == (nb_images - 1) and j == 0:
+ pl.imshow(f2, cmap=cm)
+ pl.axis('off')
+ elif i == (nb_images - 1) and j == (nb_images - 1):
+ pl.imshow(f4, cmap=cm)
+ pl.axis('off')
+ else:
+ # call to barycenter computation
+ pl.imshow(ot.bregman.convolutional_barycenter2d(A, reg, weights), cmap=cm)
+ pl.axis('off')
+ pl.show()
+
+
+
+.. image:: /auto_examples/images/sphx_glr_plot_convolutional_barycenter_001.png
+ :align: center
+
+
+
+
+**Total running time of the script:** ( 1 minutes 11.608 seconds)
+
+
+
+.. only :: html
+
+ .. container:: sphx-glr-footer
+
+
+ .. container:: sphx-glr-download
+
+ :download:`Download Python source code: plot_convolutional_barycenter.py <plot_convolutional_barycenter.py>`
+
+
+
+ .. container:: sphx-glr-download
+
+ :download:`Download Jupyter notebook: plot_convolutional_barycenter.ipynb <plot_convolutional_barycenter.ipynb>`
+
+
+.. only:: html
+
+ .. rst-class:: sphx-glr-signature
+
+ `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_