예제 #1
0
def evalerr_l(prm):
    dimN=1
    lmbda_l= prm[0]
    b_l = comcbpdn.ComplexConvBPDN(D1_d, s_test, lmbda_l, opt=opt_par, dimK=None, dimN=dimN)
    x_0_l = b_l.solve()
    x_1_l = x_0_l.squeeze()
    return (np.sum(np.abs(x_1_l)))
예제 #2
0
def evalerr(prm):
    dimN=1
    lmbda = prm[0]
    b = comcbpdn.ComplexConvBPDN(D0_d, s_test, lmbda, opt=opt_par, dimK=None, dimN=dimN)
    x_0 = b.solve()
    x_1 = x_0.squeeze()

    return (np.sum(np.abs(x_1)))
예제 #3
0
 def test_05(self):
     N = 16
     Nd = 5
     K = 2
     M = 4
     D = np.random.randn(Nd, Nd, M)
     s = np.random.randn(N, N, K)
     lmbda = 1e-1
     b = comcbpdn.ComplexConvBPDN(D, s, lmbda)
     assert b.cri.dimC == 0
     assert b.cri.dimK == 1
예제 #4
0
 def test_03(self):
     N = 16
     Nd = 5
     Cd = 3
     M = 4
     D = np.random.randn(Nd, Nd, Cd, M)
     s = np.random.randn(N, N, Cd)
     lmbda = 1e-1
     b = comcbpdn.ComplexConvBPDN(D, s, lmbda)
     assert b.cri.dimC == 1
     assert b.cri.dimK == 0
예제 #5
0
 def test_02(self):
     N = 16
     Nd = 5
     Cs = 3
     K = 5
     M = 4
     D = np.random.randn(Nd, Nd, M)
     s = np.random.randn(N, N, Cs, K)
     lmbda = 1e-1
     b = comcbpdn.ComplexConvBPDN(D, s, lmbda)
     assert b.cri.dimC == 1
     assert b.cri.dimK == 1
예제 #6
0
 def test_06(self):
     N = 16
     Nd = 5
     K = 2
     M = 4
     D = np.random.randn(Nd, Nd, M)
     s = np.random.randn(N, N, K)
     dt = np.complex
     opt = comcbpdn.ComplexConvBPDN.Options({
         'Verbose': False,
         'MaxMainIter': 20,
         'AutoRho': {
             'Enabled': True
         },
         'DataType': dt
     })
     lmbda = 1e-1
     b = comcbpdn.ComplexConvBPDN(D, s, lmbda, opt=opt)
     b.solve()
     assert b.X.dtype == dt
     assert b.Y.dtype == dt
     assert b.U.dtype == dt
예제 #7
0
optd = comccmod.ComConvCnstrMODOptions({'Verbose': False, 'MaxMainIter': 1,
            'rho': 10, 'ZeroMean': True},
            method='cns')
#
#Dictionary support projection and normalisation (cropped).
#Normalise dictionary according to dictionary Y update options.

D0n = cnvrep.Pcn(D0, D0.shape, cri.Nv, dimN=1, dimC=0, crp=True,
                 zm=optd['ZeroMean'])
#
# Update D update options to include initial values for Y and U.
optd.update({'Y0': cnvrep.zpad(cnvrep.stdformD(D0n, cri.Cd, cri.M), cri.Nv),
             'U0': np.zeros(cri.shpD + (cri.K,))})
# # #
#Create X update object.
xstep = comcbpdn.ComplexConvBPDN(D0n, s_noise, lmbda, optx)

# # the first one is coefficient map
#Create D update object.
dstep = comccmod.ComConvCnstrMOD(None, s_noise, D0.shape, optd, method='cns')
#
opt = dictlrn.DictLearn.Options({'Verbose': True, 'MaxMainIter': 1000})
d = dictlrn.DictLearn(xstep, dstep, opt)
D1 = d.solve()
x = d.getcoef()

rec = reconstruct(D1,x,cri)
rec = rec.squeeze()
print("DictLearn solve time: %.2fs" % d.timer.elapsed('solve'), "\n")

itsx = xstep.getitstat()
예제 #8
0
fig, ax = plot.subplots(nrows=2, ncols=3, sharex=True, sharey=True, figsize=(18, 8))

rec_r = b_r.reconstruct().squeeze()
fig.suptitle('real value solver ' + str(np.count_nonzero(x_r) * 100 / x_r.size) + '% non zero elements', fontsize=14)
plot.plot(s_clean.real, title='clean(real)', fig=fig, ax=ax[0, 0])
plot.plot(s_clean.imag, title='clean(imag)', fig=fig, ax=ax[1, 0])

plot.plot(s_noise.real, title='corrupted(real)', fig=fig, ax=ax[0, 1])
plot.plot(s_noise.imag, title='corrupted(imag)', fig=fig, ax=ax[1, 1])

plot.plot(rec_r.real, title='reconstructed(real)', fig=fig, ax=ax[0, 2])
plot.plot(rec_r.imag, title='reconstructed(imag)', fig=fig, ax=ax[1, 2])

fig.show()
# solve with a complex valued signal with complex valued dictionary
b_c = comcbpdn.ComplexConvBPDN(D0, s_noise, lmbda_0, opt_par, None, dimN)
x_c = b_c.solve()
rec_c = b_c.reconstruct().squeeze()

fig, ax = plot.subplots(nrows=2, ncols=3, sharex=True, sharey=True, figsize=(18, 8))
fig.suptitle('complex value solver ' + str(np.count_nonzero(x_c) * 100 / x_c.size) + '% non zero elements', fontsize=14)

plot.plot(s_clean.real, title='clean(real)', fig=fig, ax=ax[0, 0])
plot.plot(s_clean.imag, title='clean(imag)', fig=fig, ax=ax[1, 0])

plot.plot(s_noise.real, title='corrupted(real)', fig=fig, ax=ax[0, 1])
plot.plot(s_noise.imag, title='corrupted(imag)', fig=fig, ax=ax[1, 1])

plot.plot(rec_c.real, title='reconstructed(real)', fig=fig, ax=ax[0, 2])
plot.plot(rec_c.imag, title='reconstructed(imag)', fig=fig, ax=ax[1, 2])
fig.show()