|
3 | 3 | ============================================== |
4 | 4 |
|
5 | 5 | In this example we want to compare three popular solvers in compressive |
6 | | -sensing problem, namely :py:class:`pylops.optimization.sparsity.ISTA`, |
7 | | -:py:class:`pylops.optimization.sparsity.FISTA`, and |
| 6 | +sensing problem, namely :py:class:`pylops.optimization.sparsity.ista`, |
| 7 | +:py:class:`pylops.optimization.sparsity.fista`, and |
8 | 8 | :py:class:`pyproximal.optimization.primal.TwIST`. |
9 | 9 |
|
10 | 10 | Whilst all solvers try to solve an unconstrained problem with a L1 |
|
38 | 38 | A = np.random.randn(N, M) |
39 | 39 | A = A / np.linalg.norm(A, axis=0) |
40 | 40 | Aop = pylops.MatrixMult(A) |
| 41 | +Aop.explicit = False # temporary solution whilst PyLops gets updated |
41 | 42 |
|
42 | 43 | x = np.random.rand(M) |
43 | 44 | x[x < 0.9] = 0 |
44 | | -y = Aop*x |
| 45 | +y = Aop * x |
45 | 46 |
|
46 | 47 | ############################################################################### |
47 | 48 | # We try now to recover the sparse signal with our 3 different solvers |
|
50 | 51 |
|
51 | 52 | # ISTA |
52 | 53 | x_ista, niteri, costi = \ |
53 | | - pylops.optimization.sparsity.ISTA(Aop, y, maxit, eps=eps, tol=1e-10, |
54 | | - show=False, returninfo=True) |
| 54 | + pylops.optimization.sparsity.ista(Aop, y, niter=maxit, eps=eps, tol=1e-10, |
| 55 | + show=False) |
55 | 56 |
|
56 | 57 | # FISTA |
57 | 58 | x_fista, niterf, costf = \ |
58 | | - pylops.optimization.sparsity.FISTA(Aop, y, maxit, eps=eps, |
59 | | - tol=1e-10, show=False, returninfo=True) |
| 59 | + pylops.optimization.sparsity.fista(Aop, y, niter=maxit, eps=eps, |
| 60 | + tol=1e-10, show=False) |
60 | 61 |
|
61 | 62 | # TWIST (Note that since the smallest eigenvalue is zero, we arbitrarily |
62 | 63 | # choose a small value for the solver to converge stably) |
|
77 | 78 | plt.setp(m, markersize=7) |
78 | 79 | m, s, b = ax.stem(x_fista, linefmt='--g', basefmt='--g', |
79 | 80 | markerfmt='go', label='FISTA') |
80 | | -plt.setp(m, markersize = 7) |
| 81 | +plt.setp(m, markersize=7) |
81 | 82 | m, s, b = ax.stem(x_twist, linefmt='--b', basefmt='--b', |
82 | 83 | markerfmt='bo', label='TWIST') |
83 | | -plt.setp(m, markersize = 7) |
| 84 | +plt.setp(m, markersize=7) |
84 | 85 | ax.set_title('Model', size=15, fontweight='bold') |
85 | 86 | ax.legend() |
86 | 87 | plt.tight_layout() |
|
0 commit comments