Skip to content

Commit 527642f

Browse files
Circle CICircle CI
authored andcommitted
CircleCI update of dev docs (4006).
1 parent f0aeca5 commit 527642f

323 files changed

Lines changed: 230558 additions & 228338 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Binary file not shown.
Binary file not shown.
Binary file not shown.

master/_downloads/19cb597692ceab77fc7a30538a6598cb/plot_ot_batch.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
},
1616
"outputs": [],
1717
"source": [
18-
"# Author: Paul Krzakala <paul.krzakala@gmail.com>\n# License: MIT License\n\n# sphinx_gallery_thumbnail_number = 1"
18+
"# Author: Paul Krzakala <paul.krzakala@gmail.com>\n# Thibaut Germain <thibaut.germain.pro@gmail.com>\n# License: MIT License\n\n# sphinx_gallery_thumbnail_number = 1"
1919
]
2020
},
2121
{
@@ -40,7 +40,7 @@
4040
"cell_type": "markdown",
4141
"metadata": {},
4242
"source": [
43-
"## Solving the Problems\n\nOnce the cost matrices are computed, we can solve the corresponding\noptimal transport problems.\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>One option is to solve them sequentially with a Python loop using\n :func:`ot.solve`.\n This is simple but inefficient for large batches.</p></div>\n\nInstead, you can use :func:`ot.batch.solve_batch`, which solves all\nproblems in parallel.\n\n"
43+
"## Solving the Problems\n\nOnce the cost matrices are computed, we can solve the corresponding\noptimal transport problems.\n\n<div class=\"alert alert-info\"><h4>Note</h4><p>One option is to solve them sequentially with a Python loop using\n :func:`ot.solve`.\n This is simple but inefficient for large batches.</p></div>\n\nInstead, you can use :func:`ot.batch.solve_batch`, which solves all\nproblems in parallel. Several methods are available: [\"sinkhorn\", \"log_sinkhorn\"]\nwhich solve regularized OT problems, and [\"proximal\"] which\nsolves regularized and unregularized OT problem using a proximal point scheme.\nBy default, the method is set to \"auto\" which automatically selects the appropriate\nmethod based on the value of `reg`. If `reg` is None or 0, the proximal point method\nis used. If `reg` is greater than 0, the Sinkhorn algorithm is used.\n\n"
4444
]
4545
},
4646
{
@@ -51,7 +51,7 @@
5151
},
5252
"outputs": [],
5353
"source": [
54-
"reg = 1.0\nmax_iter = 100\ntol = 1e-3\n\n# Naive approach\nresults_values_list = []\nfor i in range(n_problems):\n res = ot.solve(M_list[i], reg=reg, max_iter=max_iter, tol=tol, reg_type=\"entropy\")\n results_values_list.append(res.value_linear)\n\n# Batched approach\nresults_batch = ot.solve_batch(\n M=M_batch, reg=reg, max_iter=max_iter, tol=tol, reg_type=\"entropy\"\n)\nresults_values_batch = results_batch.value_linear\n\nassert np.allclose(np.array(results_values_list), results_values_batch, atol=tol * 10)"
54+
"max_iter = 10000\ntol = 1e-4\n\n# Classical OT problem\n## Naive approach\nresults_values_list = []\nfor i in range(n_problems):\n res = ot.solve(M_list[i], max_iter=max_iter, tol=tol)\n results_values_list.append(res.value_linear)\n\n## Batched approach\nresults_batch = ot.solve_batch(M=M_batch, max_iter=max_iter, tol=tol)\nresults_values_batch = results_batch.value_linear\n\nexact_validated = np.allclose(\n np.array(results_values_list), results_values_batch, atol=tol * 10\n)\n\n# Entropic regularized OT problem\n## Naive approach\nreg = 1.0\nresults_values_list = []\nfor i in range(n_problems):\n res = ot.solve(M_list[i], reg=reg, max_iter=max_iter, tol=tol, reg_type=\"entropy\")\n results_values_list.append(res.value_linear)\n\n## Batched approach\nresults_batch = ot.solve_batch(\n M=M_batch, reg=reg, max_iter=max_iter, tol=tol, reg_type=\"entropy\"\n)\nresults_values_batch = results_batch.value_linear\n\nentropic_validated = np.allclose(\n np.array(results_values_list), results_values_batch, atol=tol * 10\n)\n\nprint(\n f\"Exact solve vs proximal batch close: {exact_validated} \\nSinkhorn solve vs Sinkhorn solve_batch close: {entropic_validated}\"\n)"
5555
]
5656
},
5757
{
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)