Esempio n. 1
0
 def test_02(self):
     N = 16
     M = 4
     K = 8
     X = np.random.randn(M, K)
     S = np.random.randn(N, K)
     try:
         b = cmod.CnstrMOD(X, S)
         b.solve()
     except Exception as e:
         print(e)
         assert 0
Esempio n. 2
0
 def test_03(self):
     N = 16
     M = 4
     K = 8
     X = np.random.randn(M, K)
     S = np.random.randn(N, K)
     opt = cmod.CnstrMOD.Options({
         'Verbose': False,
         'MaxMainIter': 200,
         'RelStopTol': 1e-4,
         'L': 100.0
     })
     b = cmod.CnstrMOD(X, S, (N, M), opt=opt)
     b.solve()
     assert np.array(b.getitstat().Rsdl).min() < 1e-4
Esempio n. 3
0
 def test_06(self):
     N = 16
     M = 4
     K = 8
     X = np.random.randn(M, K)
     S = np.random.randn(N, K)
     dt = np.float64
     opt = cmod.CnstrMOD.Options({
         'Verbose': False,
         'MaxMainIter': 20,
         'DataType': dt
     })
     b = cmod.CnstrMOD(X, S, opt=opt)
     b.solve()
     assert b.X.dtype == dt
     assert b.Y.dtype == dt
Esempio n. 4
0
 def test_10(self):
     N = 16
     M = 4
     K = 8
     X = np.random.randn(M, K)
     S = np.random.randn(N, K)
     opt = cmod.CnstrMOD.Options({
         'Verbose': False,
         'MaxMainIter': 100,
         'RelStopTol': 1e-4,
         'L': 10.0,
         'StepSizePolicy': StepSizePolicyCauchy()
     })
     try:
         b = cmod.CnstrMOD(X, S, (N, M), opt=opt)
         b.solve()
     except Exception as e:
         print(e)
         assert 0
Esempio n. 5
0
    'L': 100,
    'Backtrack': BacktrackRobust()
})
b = bpdn.BPDN(D0, S, lmbda, opt)
X = b.solve()
"""
Update dictionary for training image set using PGM with Cauchy step size policy :cite:`yuan-2008-stepsize`.
"""

opt = cmod.CnstrMOD.Options({
    'Verbose': True,
    'MaxMainIter': 100,
    'L': 50,
    'StepSizePolicy': StepSizePolicyCauchy()
})
c1 = cmod.CnstrMOD(X, S, None, opt)
D11 = c1.solve()
print("CMOD solve time: %.2fs" % c1.timer.elapsed('solve'))
"""
Update dictionary for training image set using PGM with Barzilai-Borwein step size policy :cite:`barzilai-1988-stepsize`.
"""

opt = cmod.CnstrMOD.Options({
    'Verbose': True,
    'MaxMainIter': 100,
    'L': 50,
    'StepSizePolicy': StepSizePolicyBB()
})
c2 = cmod.CnstrMOD(X, S, None, opt)
D12 = c2.solve()
print("CMOD solve time: %.2fs" % c2.timer.elapsed('solve'))