plt.semilogy(criter_CGLS) plt.title('CGLS criterion') plt.show() # CGLS solves the simple least-squares problem. The same problem can be solved # by FISTA by setting up explicitly a least squares function object and using # no regularisation: # Create least squares object instance with projector, test data and a constant # coefficient of 0.5: f = Norm2sq(Cop, b, c=0.5) # Run FISTA for least squares without regularization x_fista0, it0, timing0, criter0 = FISTA(x_init, f, None, opt=opt) plt.imshow(x_fista0.subset(vertical=0).array) plt.title('FISTA Least squares') plt.show() plt.semilogy(criter0) plt.title('FISTA Least squares criterion') plt.show() # FISTA can also solve regularised forms by specifying a second function object # such as 1-norm regularisation with choice of regularisation parameter lam: # Create 1-norm function object lam = 0.1 g0 = Norm1(lam) # Run FISTA for least squares plus 1-norm function.
plt.show() # Set initial guess print("Initial guess") x_init = ImageData(geometry=ig) # Create least squares object instance with projector and data. print("Create least squares object instance with projector and data.") f = Norm2sq(Cop, padded_data2, c=0.5) # Run FISTA reconstruction for least squares without regularization print("Run FISTA for least squares") opt = {'tol': 1e-4, 'iter': 100} x_fista0, it0, timing0, criter0 = FISTA(x_init, f, None, opt=opt) plt.imshow(x_fista0.subset(horizontal_x=80).array) plt.title('FISTA LS') plt.colorbar() plt.show() # Set up 1-norm function for FISTA least squares plus 1-norm regularisation print("Run FISTA for least squares plus 1-norm regularisation") lam = 0.1 g0 = Norm1(lam) # Run FISTA for least squares plus 1-norm function. x_fista1, it1, timing1, criter1 = FISTA(x_init, f, g0, opt=opt) plt.imshow(x_fista0.subset(horizontal_x=80).array) plt.title('FISTA LS+1') plt.colorbar()
plt.semilogy(criter_CGLS) plt.title('CGLS Criterion vs iterations') plt.show() # Create least squares object instance with projector, test data and a constant # coefficient of 0.5. Note it is least squares over all channels. f = Norm2sq(Aall, data2d, c=0.5) # Options for FISTA algorithm. opt = {'tol': 1e-4, 'iter': 100} # Run FISTA for least squares without regularization and display one channel # reconstruction as image. x_fista0, it0, timing0, criter0 = FISTA(x_init, f, None, opt) plt.imshow(x_fista0.subset(channel=100).array) plt.title('FISTA LS') plt.show() plt.semilogy(criter0) plt.title('FISTA LS Criterion vs iterations') plt.show() # Set up 1-norm regularisation (over all channels), solve with FISTA, and # display one channel of reconstruction. lam = 0.1 g0 = Norm1(lam) x_fista1, it1, timing1, criter1 = FISTA(x_init, f, g0, opt) plt.imshow(x_fista1.subset(channel=100).array)