Example #1
0
    def test_18(self):
        N = 64
        M = 4
        Nd = 8
        D0 = cr.normalise(cr.zeromean(np.random.randn(Nd, Nd, M), (Nd, Nd, M),
                                      dimN=2),
                          dimN=2)
        X = np.zeros((N, N, M))
        xr = np.random.randn(N, N, M)
        xp = np.abs(xr) > 3
        X[xp] = np.random.randn(X[xp].size)
        S = np.sum(ifftn(
            fftn(D0, (N, N), (0, 1)) * fftn(X, None, (0, 1)), None,
            (0, 1)).real,
                   axis=2)
        L = 50.0
        opt = ccmod.ConvCnstrMOD.Options({
            'Verbose': False,
            'MaxMainIter': 3000,
            'ZeroMean': True,
            'RelStopTol': 0.,
            'L': L,
            'Monotone': True
        })
        Xr = X.reshape(X.shape[0:2] + (
            1,
            1,
        ) + X.shape[2:])
        Sr = S.reshape(S.shape + (1, ))
        c = ccmod.ConvCnstrMOD(Xr, Sr, D0.shape, opt)
        c.solve()
        D1 = cr.bcrop(c.X, D0.shape).squeeze()

        assert rrs(D0, D1) < 1e-4
        assert np.array(c.getitstat().Rsdl)[-1] < 1e-5
Example #2
0
 def test_02(self):
     N = 16
     M = 8
     X = np.random.randn(N, N, 1, 1, M)
     S = np.random.randn(N, N, 1)
     try:
         c = ccmod.ConvCnstrMOD(X, S, ((4, 4, 4), (8, 8, 4)))
         c.solve()
     except Exception as e:
         print(e)
         assert 0
Example #3
0
 def test_01(self):
     N = 16
     M = 4
     Nd = 8
     X = np.random.randn(N, N, 1, 1, M)
     S = np.random.randn(N, N, 1)
     try:
         c = ccmod.ConvCnstrMOD(X, S, (Nd, Nd, M))
         c.solve()
     except Exception as e:
         print(e)
         assert 0
Example #4
0
 def test_06(self):
     N = 16
     M = 4
     Nd = 8
     X = np.random.randn(N, N, 1, 1, M)
     S = np.random.randn(N, N)
     try:
         opt = ccmod.ConvCnstrMOD.Options({
             'Verbose': False,
             'MaxMainIter': 20
         })
         c = ccmod.ConvCnstrMOD(X, S, (Nd, Nd, 1, M), opt=opt, dimK=0)
         c.solve()
     except Exception as e:
         print(e)
         assert 0
Example #5
0
 def test_05(self):
     N = 16
     M = 4
     Nd = 8
     X = np.random.randn(N, N, 1, 1, M)
     S = np.random.randn(N, N, 1)
     dt = np.float64
     opt = ccmod.ConvCnstrMOD.Options({
         'Verbose': False,
         'MaxMainIter': 20,
         'Backtrack': BacktrackStandard(),
         'DataType': dt
     })
     c = ccmod.ConvCnstrMOD(X, S, (Nd, Nd, M), opt=opt)
     c.solve()
     assert c.X.dtype == dt
     assert c.Xf.dtype == complex_dtype(dt)
     assert c.Yf.dtype == complex_dtype(dt)
Example #6
0
 def test_10(self):
     N = 16
     M = 4
     K = 2
     Nc = 3
     Nd = 8
     X = np.random.randn(N, N, Nc, K, M)
     S = np.random.randn(N, N, Nc, K)
     try:
         opt = ccmod.ConvCnstrMOD.Options({
             'Verbose': False,
             'MaxMainIter': 20
         })
         c = ccmod.ConvCnstrMOD(X, S, (Nd, Nd, Nc, M), opt=opt)
         c.solve()
     except Exception as e:
         print(e)
         assert 0
Example #7
0
 def test_03(self):
     N = 16
     M = 4
     Nc = 3
     Nd = 8
     X = np.random.randn(N, N, Nc, 1, M)
     S = np.random.randn(N, N, Nc)
     L = 2e3
     try:
         opt = ccmod.ConvCnstrMOD.Options({
             'Verbose': False,
             'MaxMainIter': 100,
             'L': L
         })
         c = ccmod.ConvCnstrMOD(X, S, (Nd, Nd, 1, M), opt=opt, dimK=0)
         c.solve()
     except Exception as e:
         print(e)
         assert 0
     assert np.array(c.getitstat().Rsdl)[-1] < 5e-3
Example #8
0
    'Verbose': True,
    'MaxMainIter': 100,
    'HighMemSolve': True
})
c = cbpdn.ConvBPDN(D0, sh, lmbda, opt)
X = c.solve()
"""
Update dictionary for training image set. Nesterov momentum coefficients :cite:`beck-2009-fast`.
"""

opt = ccmod.ConvCnstrMOD.Options({
    'Verbose': True,
    'MaxMainIter': 100,
    'L': 50
})
c1 = ccmod.ConvCnstrMOD(X, sh, D0.shape, opt)
c1.solve()
D11 = c1.getdict().squeeze()
print("ConvCnstrMOD solve time: %.2fs" % c1.timer.elapsed('solve'))
"""
Update dictionary for training image set. Linear momentum coefficients :cite:`chambolle-2015-convergence`.
"""

opt = ccmod.ConvCnstrMOD.Options({
    'Verbose': True,
    'MaxMainIter': 100,
    'Momentum': MomentumLinear(),
    'L': 50
})
c2 = ccmod.ConvCnstrMOD(X, sh, D0.shape, opt)
c2.solve()