summaryrefslogtreecommitdiff
path: root/examples/backends/plot_optim_gromov_pytorch.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/backends/plot_optim_gromov_pytorch.py')
-rw-r--r--examples/backends/plot_optim_gromov_pytorch.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/examples/backends/plot_optim_gromov_pytorch.py b/examples/backends/plot_optim_gromov_pytorch.py
index cdc1587..0ae2890 100644
--- a/examples/backends/plot_optim_gromov_pytorch.py
+++ b/examples/backends/plot_optim_gromov_pytorch.py
@@ -1,7 +1,7 @@
r"""
-=================================
+=======================================================
Optimizing the Gromov-Wasserstein distance with PyTorch
-=================================
+=======================================================
In this example, we use the pytorch backend to optimize the Gromov-Wasserstein
(GW) loss between two graphs expressed as empirical distribution.
@@ -11,7 +11,7 @@ graph so that it minimizes the GW with a given Stochastic Block Model graph.
We can see that this actually recovers the proportion of classes in the SBM
and allows for an accurate clustering of the nodes using the GW optimal plan.
-In the second part, we optimize simultaneously the weights and the sructure of
+In the second part, we optimize simultaneously the weights and the structure of
the template graph which allows us to perform graph compression and to recover
other properties of the SBM.
@@ -38,7 +38,7 @@ from ot.gromov import gromov_wasserstein2
# %%
# Graph generation
-# ---------------
+# ----------------
rng = np.random.RandomState(42)
@@ -95,8 +95,8 @@ pl.axis("off")
# %%
# Optimizing GW w.r.t. the weights on a template structure
-# ------------------------------------------------
-# The adajacency matrix C1 is block diagonal with 3 blocks. We want to
+# --------------------------------------------------------
+# The adjacency matrix C1 is block diagonal with 3 blocks. We want to
# optimize the weights of a simple template C0=eye(3) and see if we can
# recover the proportion of classes from the SBM (up to a permutation).
@@ -155,7 +155,7 @@ print("True proportions : ", ratio)
# %%
# Community clustering with uniform and estimated weights
-# --------------------------------------------
+# -------------------------------------------------------
# The GW OT plan can be used to perform a clustering of the nodes of a graph
# when computing the GW with a simple template like C0 by labeling nodes in
# the original graph using by the index of the noe in the template receiving
@@ -193,7 +193,7 @@ pl.axis("off")
# classes
-def graph_compession_gw(nb_nodes, C2, a2, nb_iter_max=100, lr=1e-2):
+def graph_compression_gw(nb_nodes, C2, a2, nb_iter_max=100, lr=1e-2):
""" solve min_a GW(C1,C2,a, a2) by gradient descent"""
# use pyTorch for our data
@@ -237,8 +237,8 @@ def graph_compession_gw(nb_nodes, C2, a2, nb_iter_max=100, lr=1e-2):
nb_nodes = 3
-a0_est2, C0_est2, loss_iter2 = graph_compession_gw(nb_nodes, C1, ot.unif(n),
- nb_iter_max=100, lr=5e-2)
+a0_est2, C0_est2, loss_iter2 = graph_compression_gw(nb_nodes, C1, ot.unif(n),
+ nb_iter_max=100, lr=5e-2)
pl.figure(4)
pl.plot(loss_iter2)