def test_01(self): Nr = 16 Nc = 17 C = 3 Nd = 5 Md = 4 Mb = 4 D = cp.random.randn(Nd, Nd, Md) B = cp.random.randn(C, Mb) s = cp.random.randn(Nr, Nc, C) lmbda = 1e-1 try: opt = pdcsc.ConvProdDictBPDN.Options({'LinSolveCheck': True}) b = pdcsc.ConvProdDictBPDN(D, B, s, lmbda, opt=opt, dimK=0) b.solve() except Exception as e: print(e) assert 0 assert list2array(b.getitstat().XSlvRelRes).max() < 1e-4
'RelStopTol': 5e-3, 'AuxVarObj': False}) """ Initialise and run CSC solver. """ if not cupy_enabled(): print('CuPy/GPU device not available: running without GPU acceleration\n') else: id = select_device_by_load() info = gpu_info() if info: print('Running on GPU %d (%s)\n' % (id, info[id].name)) b = pdcsc.ConvProdDictBPDN(np2cp(D), np2cp(B), np2cp(shc), lmbda, opt, dimK=0) X = cp2np(b.solve()) print("ConvProdDictBPDN solve time: %.2fs" % b.timer.elapsed('solve')) """ Compute partial and full reconstructions from sparse representation $X$ with respect to convolutional dictionary $D$ and standard dictionary $B$. The partial reconstructions are $DX$ and $XB$, and the full reconstruction is $DXB$. """ DX = fft.fftconv(D[..., np.newaxis, np.newaxis, :], X, axes=(0, 1)) XB = linalg.dot(B, X, axis=2) shr = cp2np(b.reconstruct().squeeze()) imgr = slc + shr print("Reconstruction PSNR: %.2fdB\n" % metric.psnr(img, imgr))