Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIRT objective #1790

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Wrappers/Python/cil/optimisation/algorithms/SIRT.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,5 @@ def update_objective(self):
.. math:: \frac{1}{2}\|A x - b\|^{2}

"""
self.loss.append(0.5*self.r.squared_norm())
self.loss.append(0.5*(self.operator.direct(self.x)-self.data).squared_norm())

9 changes: 6 additions & 3 deletions Wrappers/Python/test/test_algorithms.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,9 @@ def test_SIRT_relaxation_parameter(self):
np.testing.assert_array_almost_equal(alg.x.array, self.b2.array)

np.testing.assert_almost_equal(0.5 *alg.D.array, alg._Dscaled.array)


np.testing.assert_allclose(alg.get_last_loss(), 0.5*np.linalg.norm(alg.x.as_array()-self.b2.as_array())**2, rtol=1e-5)


def test_SIRT_nan_inf_values(self):
Aop_nan_inf = self.Aop
Aop_nan_inf.A[0:10,:] = 0.
Expand Down Expand Up @@ -773,7 +774,8 @@ def test_SIRT_with_TV(self):
fista=FISTA(initial=initial,f=f, g=constraint, max_iteration=1000)
fista.run(100, verbose=0)
self.assertNumpyArrayAlmostEqual(fista.x.as_array(), sirt.x.as_array())

np.testing.assert_allclose(sirt.get_last_loss(), 0.5*np.linalg.norm(sirt.x.as_array()-data.as_array())**2, rtol=1e-5)

def test_SIRT_with_TV_warm_start(self):
data = dataexample.SIMPLE_PHANTOM_2D.get(size=(128,128))
ig = data.geometry
Expand All @@ -784,6 +786,7 @@ def test_SIRT_with_TV_warm_start(self):
sirt.run(25, verbose=0)

self.assertNumpyArrayAlmostEqual(sirt.x.as_array(), ig.allocate(0.25).as_array(),3)
np.testing.assert_allclose(sirt.get_last_loss(), 0.5*np.linalg.norm(sirt.x.as_array()-data.as_array())**2, rtol=1e-5)


class TestSPDHG(unittest.TestCase):
Expand Down
Loading