# Minimization of F(K*x) + G(x) K = gradient K.T = divergence amp = lambda u : np.sqrt(np.sum(u ** 2,axis=2)) F = lambda u : alpha * np.sum(amp(u)) G = lambda x : 1/2 * np.linalg.norm(y-x,'fro') ** 2 # Proximity operators normalize = lambda u : u/np.tile( (np.maximum(amp(u), 1e-10))[:,:,np.newaxis], (1,1,2)) proxF = lambda u,tau : np.tile( soft_thresholding(amp(u), alpha*tau)[:,:,np.newaxis], (1,1,2) )* normalize(u) proxFS = dual_prox(proxF) proxG = lambda x,tau : (x + tau*y) / (1+tau) callback = lambda x : G(x) + F(K(x)) t1 = time.time() xRec, cx = pp.admm(proxFS, proxG, K, y, maxiter=300, full_output=1, callback=callback) t2 = time.time() print "Performed 300 iterations in " + str(t2-t1) + " seconds." plt.subplot(221) imgplot = plt.imshow(im) imgplot.set_cmap('gray') plt.title('Original')
# Minimization of F(K*x) + G(x) K = gradient K.T = divergence amp = lambda u: np.sqrt(np.sum(u ** 2, axis=2)) F = lambda u: alpha * np.sum(amp(u)) G = lambda x: 1 / 2 * lin.norm(y - x, 'fro') ** 2 # Proximity operators normalize = lambda u: u / np.tile( (np.maximum(amp(u), 1e-10))[:, :, np.newaxis], (1, 1, 2)) prox_f = lambda u, tau: np.tile( soft_thresholding(amp(u), alpha * tau)[:, :, np.newaxis], (1, 1, 2)) * normalize(u) prox_fs = dual_prox(prox_f) prox_g = lambda x, tau: (x + tau * y) / (1 + tau) # context ctx = Context(full_output=True, maxiter=300) ctx.callback = lambda x: G(x) + F(K(x)) t1 = time.time() x_rec, cx = admm(prox_fs, prox_g, K, y, context=ctx) t2 = time.time() print("Performed 300 iterations in " + str(t2 - t1) + " seconds.") plt.subplot(221) plt.imshow(im, cmap='gray')
# Minimization of F(K*x) + G(x) K = gradient K.T = divergence amp = lambda u: np.sqrt(np.sum(u**2, axis=2)) F = lambda u: alpha * np.sum(amp(u)) G = lambda x: 1 / 2 * lin.norm(y - x, 'fro')**2 # Proximity operators normalize = lambda u: u / np.tile( (np.maximum(amp(u), 1e-10))[:, :, np.newaxis], (1, 1, 2)) prox_f = lambda u, tau: np.tile( soft_thresholding(amp(u), alpha * tau)[:, :, np.newaxis], (1, 1, 2)) * normalize(u) prox_fs = dual_prox(prox_f) prox_g = lambda x, tau: (x + tau * y) / (1 + tau) callback = lambda x: G(x) + F(K(x)) t1 = time.time() x_rec, cx = admm(prox_fs, prox_g, K, y, maxiter=300, full_output=1, callback=callback) t2 = time.time() print "Performed 300 iterations in " + str(t2 - t1) + " seconds."