-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DOC: improve doc of proximal interface
- Loading branch information
Showing
4 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.. _proximal_lang_in_depth: | ||
|
||
####################### | ||
Using ODL with ProxImaL | ||
####################### | ||
|
||
`Proximal | ||
<http://www.proximal-lang.org/en/latest/>`_ is a Python-embedded modeling language for image optimization problems and can be used with ODL to solve typical inverse problems phrased as optimization problems. The package is especially suited for non-differentiable problems such as total variance denoising. | ||
|
||
Here is a minimal example of solving Poisson's equation equation on an interval with a TV type regularizer (:math:`\min_x \ 10||-\Delta x - rhs||_2^2 + ||\nabla x||_1`):: | ||
|
||
>>> space = odl.uniform_discr(0, 1, 5) | ||
>>> op = -odl.Laplacian(space) | ||
>>> proximal_lang_op = odl.as_proximal_lang_operator(op) | ||
>>> rhs = space.element(lambda x: (x>0.4) & (x<0.6)) # indicator function on [0.4, 0.6] | ||
>>> x = proximal.Variable(space.shape) | ||
>>> prob = proximal.Problem([10 * proximal.sum_squares(x - rhs.asarray()), | ||
>>> proximal.norm1(proximal.grad(x))]) | ||
>>> prob.solve() | ||
>>> x.value | ||
array([ 0.02352054, 0.02647946, 0.9 , 0.02647946, 0.02352054]) | ||
|
||
Notable differences between ODL and ProxImaL | ||
============================================ | ||
|
||
It may be tempting to try to convert an arbitrary problem from ODL into ProxImaL, but some differences exist. | ||
|
||
Norms | ||
----- | ||
Norms in ODL are scaled according to the underlying function space. Hence a sequence of statements converging discretizations give rise to a converging norm:: | ||
|
||
>>> for n in range(2, 10000): | ||
... X = odl.uniform_discr(0, 1, n) | ||
... print(X.element(lambda x: x).norm()) | ||
0.559016994375 | ||
0.576628129734 | ||
0.577343052266 | ||
0.577350268468 | ||
>>> 1 / np.sqrt(3) # exact result | ||
0.577350269189 | ||
|
||
this is not the case in proximal, where the norm depends on the number of discretization points. Hence a scaling that is correct for a problem in ODL needs not be correct in proximal. This also changes the definition of things like the operator norm. | ||
|
||
This also has the added effect of changing the definition of derived features, like the spectral norm of operators. | ||
|
||
Spaces | ||
------ | ||
ODL can represent some complicated spaces, like :math:`\mathbb{R}^3 \times \mathbb{C}^2` through the `ProductSpace` class:: | ||
|
||
>>> space = odl.ProductSpace(odl.rn(3), odl.cn(2)) | ||
|
||
This can then be used in solvers and other structures. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters