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

Move optimizers into optimize package #129

Merged
merged 18 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from 15 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
5 changes: 3 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ SCICO Release Notes
Version 0.0.2 (unreleased)
----------------------------

• Additional optimization algorithms Linearized ADMM and PDHG
• Additional optimization algorithms: Linearized ADMM and PDHG.
• Move optimization algorithms into ``optimize`` subpackage.


Version 0.0.1 (2021-11-24)
----------------------------

• Initial release
• Initial release.
4 changes: 2 additions & 2 deletions examples/scripts/ct_astra_tv_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
=====================================

This example demonstrates the use of class
[admm.ADMM](../_autosummary/scico.admm.rst#scico.admm.ADMM) to solve a
[admm.ADMM](../_autosummary/scico.optimize.admm.rst#scico.optimize.admm.ADMM) to solve a
bwohlberg marked this conversation as resolved.
Show resolved Hide resolved
few-view CT reconstruction problem with anisotropic total variation
(TV) regularization.

Expand All @@ -30,8 +30,8 @@

import scico.numpy as snp
from scico import functional, linop, loss, metric, plot
from scico.admm import ADMM, LinearSubproblemSolver
from scico.linop.radon_astra import ParallelBeamProjector
from scico.optimize.admm import ADMM, LinearSubproblemSolver
from scico.util import device_info

"""
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/ct_astra_weighted_tv_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
=====================================

This example demonstrates the use of class
[admm.ADMM](../_autosummary/scico.admm.rst#scico.admm.ADMM) to solve a
[admm.ADMM](../_autosummary/scico.optimize.admm.rst#scico.optimize.admm.ADMM) to solve a
low-dose CT reconstruction problem with anisotropic total variation
(TV) regularization.

Expand All @@ -32,8 +32,8 @@

import scico.numpy as snp
from scico import functional, linop, loss, metric, plot
from scico.admm import ADMM, LinearSubproblemSolver
from scico.linop.radon_astra import ParallelBeamProjector
from scico.optimize.admm import ADMM, LinearSubproblemSolver
from scico.util import device_info

"""
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/ct_svmbir_ppp_bm3d_admm_cg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
================================================================

This example demonstrates the use of class
[admm.ADMM](../_autosummary/scico.admm.rst#scico.admm.ADMM) to solve a
[admm.ADMM](../_autosummary/scico.optimize.admm.rst#scico.optimize.admm.ADMM) to solve a
tomographic reconstruction problem using the Plug-and-Play Priors framework
:cite:`venkatakrishnan-2013-plugandplay2`, using BM3D :cite:`dabov-2008-image`
as a denoiser and SVMBIR :cite:`svmbir-2020` for tomographic projection.
Expand All @@ -29,10 +29,10 @@

import scico.numpy as snp
from scico import metric, plot
from scico.admm import ADMM, LinearSubproblemSolver
from scico.functional import BM3D, NonNegativeIndicator
from scico.linop import Diagonal, Identity
from scico.linop.radon_svmbir import ParallelBeamProjector, SVMBIRWeightedSquaredL2Loss
from scico.optimize.admm import ADMM, LinearSubproblemSolver
from scico.util import device_info

"""
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/ct_svmbir_ppp_bm3d_admm_prox.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
==================================================================

This example demonstrates the use of class
[admm.ADMM](../_autosummary/scico.admm.rst#scico.admm.ADMM) to solve a
[admm.ADMM](../_autosummary/scico.optimize.admm.rst#scico.optimize.admm.ADMM) to solve a
tomographic reconstruction problem using the Plug-and-Play Priors framework
:cite:`venkatakrishnan-2013-plugandplay2`, using BM3D :cite:`dabov-2008-image`
as a denoiser and SVMBIR :cite:`svmbir-2020` for tomographic projection.
Expand All @@ -29,10 +29,10 @@

import scico.numpy as snp
from scico import metric, plot
from scico.admm import ADMM, LinearSubproblemSolver
from scico.functional import BM3D, NonNegativeIndicator
from scico.linop import Diagonal, Identity
from scico.linop.radon_svmbir import ParallelBeamProjector, SVMBIRWeightedSquaredL2Loss
from scico.optimize.admm import ADMM, LinearSubproblemSolver
from scico.util import device_info

"""
Expand Down
5 changes: 2 additions & 3 deletions examples/scripts/ct_svmbir_tv_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@

import scico.numpy as snp
from scico import functional, linop, metric, plot
from scico.admm import ADMM, LinearSubproblemSolver
from scico.ladmm import LinearizedADMM
from scico.linop import Diagonal
from scico.linop.radon_svmbir import ParallelBeamProjector, SVMBIRWeightedSquaredL2Loss
from scico.primaldual import PDHG
from scico.optimize import PDHG, LinearizedADMM
from scico.optimize.admm import ADMM, LinearSubproblemSolver
from scico.util import device_info

"""
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/deconv_circ_tv_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
================================================================

This example demonstrates the use of class
[admm.ADMM](../_autosummary/scico.admm.rst#scico.admm.ADMM) to solve
[admm.ADMM](../_autosummary/scico.optimize.admm.rst#scico.optimize.admm.ADMM) to solve
an image deconvolution problem with isotropic total variation (TV)
regularization.

Expand All @@ -29,7 +29,7 @@
import scico.numpy as snp
import scico.random
from scico import functional, linop, loss, metric, plot
from scico.admm import ADMM, CircularConvolveSolver
from scico.optimize.admm import ADMM, CircularConvolveSolver
from scico.util import device_info

"""
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/deconv_microscopy_allchn_tv_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
provided by the EPFL Biomedical Imaging Group.

The deconvolution problem is solved using class
[admm.ADMM](../_autosummary/scico.admm.rst#scico.admm.ADMM) to solve
[admm.ADMM](../_autosummary/scico.optimize.admm.rst#scico.optimize.admm.ADMM) to solve
an image deconvolution problem with isotropic total variation (TV)
regularization

Expand Down Expand Up @@ -43,7 +43,7 @@
import ray
import scico.numpy as snp
from scico import functional, linop, loss, plot, util
from scico.admm import ADMM, CircularConvolveSolver
from scico.optimize.admm import ADMM, CircularConvolveSolver

"""
Define helper functions.
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/deconv_microscopy_tv_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
provided by the EPFL Biomedical Imaging Group.

The deconvolution problem is solved using class
[admm.ADMM](../_autosummary/scico.admm.rst#scico.admm.ADMM) to solve
[admm.ADMM](../_autosummary/scico.optimize.admm.rst#scico.optimize.admm.ADMM) to solve
an image deconvolution problem with isotropic total variation (TV)
regularization

Expand All @@ -40,7 +40,7 @@

import scico.numpy as snp
from scico import functional, linop, loss, plot, util
from scico.admm import ADMM, CircularConvolveSolver
from scico.optimize.admm import ADMM, CircularConvolveSolver

"""
Define helper functions.
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/deconv_ppp_bm3d_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
=======================================================

This example demonstrates the use of class
[admm.ADMM](../_autosummary/scico.admm.rst#scico.admm.ADMM) to solve
[admm.ADMM](../_autosummary/scico.optimize.admm.rst#scico.optimize.admm.ADMM) to solve
an image deconvolution problem using the Plug-and-Play Priors
framework :cite:`venkatakrishnan-2013-plugandplay2`, using BM3D
:cite:`dabov-2008-image` as a denoiser.
Expand All @@ -23,7 +23,7 @@

import scico.numpy as snp
from scico import functional, linop, loss, metric, plot, random
from scico.admm import ADMM, LinearSubproblemSolver
from scico.optimize.admm import ADMM, LinearSubproblemSolver
from scico.util import device_info

"""
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/deconv_ppp_bm3d_pgm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
======================================================

This example demonstrates the use of class
[pgm.AcceleratedPGM](../_autosummary/scico.pgm.rst#scico.pgm.AcceleratedPGM)
[pgm.AcceleratedPGM](../_autosummary/scico.optimize.pgm.rst#scico.optimize.pgm.AcceleratedPGM)
to solve an image deconvolution problem using the Plug-and-Play Priors
framework :cite:`venkatakrishnan-2013-plugandplay2`
:cite:`kamilov-2017-plugandplay`, using BM3D :cite:`dabov-2008-image`
Expand All @@ -25,7 +25,7 @@
import scico.numpy as snp
import scico.random
from scico import functional, linop, loss, metric, plot
from scico.pgm import AcceleratedPGM
from scico.optimize.pgm import AcceleratedPGM
from scico.util import device_info

"""
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/deconv_ppp_dncnn_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
========================================================

This example demonstrates the use of class
[admm.ADMM](../_autosummary/scico.admm.rst#scico.admm.ADMM) to solve
[admm.ADMM](../_autosummary/scico.optimize.admm.rst#scico.optimize.admm.ADMM) to solve
an image deconvolution problem using the Plug-and-Play Priors
framework :cite:`venkatakrishnan-2013-plugandplay2`, using DnCNN
:cite:`zhang-2017-dncnn` as a denoiser.
Expand All @@ -24,7 +24,7 @@
import scico.numpy as snp
import scico.random
from scico import functional, linop, loss, metric, plot
from scico.admm import ADMM, LinearSubproblemSolver
from scico.optimize.admm import ADMM, LinearSubproblemSolver
from scico.util import device_info

"""
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/deconv_tv_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
=============================================

This example demonstrates the use of class
[admm.ADMM](../_autosummary/scico.admm.rst#scico.admm.ADMM) to solve
[admm.ADMM](../_autosummary/scico.optimize.admm.rst#scico.optimize.admm.ADMM) to solve
an image deconvolution problem with anisotropic total variation (TV)
regularization.

Expand All @@ -28,7 +28,7 @@
import scico.numpy as snp
import scico.random
from scico import functional, linop, loss, metric, plot
from scico.admm import ADMM, LinearSubproblemSolver
from scico.optimize.admm import ADMM, LinearSubproblemSolver
from scico.util import device_info

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/demosaic_ppp_bm3d_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import scico.numpy as snp
import scico.random
from scico import functional, linop, loss, metric, plot
from scico.admm import ADMM, LinearSubproblemSolver
from scico.data import kodim23
from scico.optimize.admm import ADMM, LinearSubproblemSolver
from scico.util import device_info

"""
Expand Down
2 changes: 1 addition & 1 deletion examples/scripts/denoise_tv_iso_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import scico.numpy as snp
import scico.random
from scico import functional, linop, loss, plot
from scico.admm import ADMM, LinearSubproblemSolver
from scico.optimize.admm import ADMM, LinearSubproblemSolver
from scico.util import device_info

"""
Expand Down
5 changes: 2 additions & 3 deletions examples/scripts/denoise_tv_iso_multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@
import scico.numpy as snp
import scico.random
from scico import functional, linop, loss, plot
from scico.admm import ADMM, LinearSubproblemSolver
from scico.ladmm import LinearizedADMM
from scico.primaldual import PDHG
from scico.optimize import PDHG, LinearizedADMM
from scico.optimize.admm import ADMM, LinearSubproblemSolver
from scico.util import device_info

"""
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/denoise_tv_iso_pgm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
===========================================

This example demonstrates the use of class
[pgm.AcceleratedPGM](../_autosummary/scico.pgm.rst#scico.pgm.AcceleratedPGM)
[pgm.AcceleratedPGM](../_autosummary/scico.optimize.pgm.rst#scico.optimize.pgm.AcceleratedPGM)
to solve isotropic total variation (TV) regularization. It solves the
denoising problem

Expand Down Expand Up @@ -40,7 +40,7 @@
import scico.random
from scico import functional, linop, loss, operator, plot
from scico.blockarray import BlockArray
from scico.pgm import AcceleratedPGM, RobustLineSearchStepSize
from scico.optimize.pgm import AcceleratedPGM, RobustLineSearchStepSize
from scico.typing import JaxArray
from scico.util import device_info, ensure_on_device

Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/sparsecode_admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
===========================================

This example demonstrates the use of class
[admm.ADMM](../_autosummary/scico.admm.rst#scico.admm.ADMM) to solve
[admm.ADMM](../_autosummary/scico.optimize.admm.rst#scico.optimize.admm.ADMM) to solve
the non-negative sparse coding problem problem

$$\mathrm{argmin}_{\mathbf{x}} \; \| \mathbf{y} - D \mathbf{x} \|_2^2
Expand All @@ -25,7 +25,7 @@
import jax

from scico import functional, linop, loss, plot
from scico.admm import ADMM, LinearSubproblemSolver
from scico.optimize.admm import ADMM, LinearSubproblemSolver
from scico.util import device_info

"""
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/sparsecode_pgm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
=========================================

This example demonstrates the use of class
[pgm.AcceleratedPGM](../_autosummary/scico.pgm.rst#scico.pgm.AcceleratedPGM)
[pgm.AcceleratedPGM](../_autosummary/scico.optimize.pgm.rst#scico.optimize.pgm.AcceleratedPGM)
to solve the sparse coding problem problem

$$\mathrm{argmin}_{\mathbf{x}} \; \| \mathbf{y} - D \mathbf{x} \|_2^2
Expand All @@ -24,7 +24,7 @@
import jax

from scico import functional, linop, loss, plot
from scico.pgm import AcceleratedPGM
from scico.optimize.pgm import AcceleratedPGM
from scico.util import device_info

"""
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/sparsecode_poisson_blkarr_pgm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
=======================================================================

This example demonstrates the use of class
[pgm.PGMStepSize](../_autosummary/scico.pgm.rst#scico.pgm.PGMStepSize)
[pgm.PGMStepSize](../_autosummary/scico.optimize.pgm.rst#scico.optimize.pgm.PGMStepSize)
to solve the non-negative reconstruction problem with Poisson negative
log likelihood loss

Expand All @@ -33,7 +33,7 @@
from scico import functional, loss, plot
from scico.blockarray import BlockArray
from scico.operator import Operator
from scico.pgm import (
from scico.optimize.pgm import (
AcceleratedPGM,
AdaptiveBBStepSize,
BBStepSize,
Expand Down
4 changes: 2 additions & 2 deletions examples/scripts/sparsecode_poisson_pgm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
=======================================================================

This example demonstrates the use of class
[pgm.PGMStepSize](../_autosummary/scico.pgm.rst#scico.pgm.PGMStepSize)
[pgm.PGMStepSize](../_autosummary/scico.optimize.pgm.rst#scico.optimize.pgm.PGMStepSize)
to solve the non-negative reconstruction problem with Poisson negative
log likelihood loss

Expand All @@ -30,7 +30,7 @@
import scico.numpy as snp
import scico.random
from scico import functional, linop, loss, plot
from scico.pgm import (
from scico.optimize.pgm import (
AcceleratedPGM,
AdaptiveBBStepSize,
BBStepSize,
Expand Down
22 changes: 22 additions & 0 deletions scico/optimize/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2021 by SCICO Developers
# All rights reserved. BSD 3-clause License.
# This file is part of the SCICO package. Details of the copyright and
# user license can be found in the 'LICENSE' file distributed with the
# package.

"""Optimization algorithms."""

import sys

# isort: off
from .admm import ADMM
from ._ladmm import LinearizedADMM
from .pgm import PGM, AcceleratedPGM
from ._primaldual import PDHG

__all__ = ["ADMM", "LinearizedADMM", "PGM", "AcceleratedPGM", "PDHG"]

# Imported items in __all__ appear to originate in top-level linop module
for name in __all__:
getattr(sys.modules[__name__], name).__module__ = __name__
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion scico/admm.py → scico/optimize/admm.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def internal_init(self, admm):
"CircularConvolveSolver requires f to be a scico.loss.SquaredL2Loss; "
f"got {type(admm.f)}"
)
if not (isinstance(admm.f.A, CircularConvolve) or isinstance(admm.f.A, Identity)):
if not isinstance(admm.f.A, (CircularConvolve, Identity)):
raise ValueError(
"CircularConvolveSolver requires f.A to be a scico.linop.CircularConvolve "
f"or scico.linop.Identity; got {type(admm.f.A)}"
Expand Down
Loading