scico.loss#

Loss function classes.

Classes

Loss(y[, A, f, scale])

Generic loss function.

PoissonLoss(y[, A, scale])

Poisson negative log likelihood loss.

SquaredL2AbsLoss(y[, A, scale, W])

Weighted squared \(\ell_2\) with absolute value loss.

SquaredL2Loss(y[, A, scale, W, prox_kwargs])

Weighted squared \(\ell_2\) loss.

SquaredL2SquaredAbsLoss(y[, A, scale, W])

Weighted squared \(\ell_2\) with squared absolute value loss.

class scico.loss.Loss(y, A=None, f=None, scale=1.0)[source]#

Bases: Functional

Generic loss function.

Inheritance diagram of Loss

Generic loss function

\[\alpha f(\mb{y}, A(\mb{x})) \;,\]

where \(\alpha\) is the scaling parameter and \(f(\cdot)\) is the loss functional.

Parameters:
  • y (Union[Array, BlockArray]) – Measurement.

  • A (Union[Callable, Operator, None]) – Forward operator. Defaults to None, in which case self.A is a Identity with input shape and dtype determined by the shape and dtype of y.

  • f (Optional[Functional]) – Functional \(f\). If defined, the loss function is \(\alpha f(\mb{y} - A(\mb{x}))\). If None, then __call__ and prox (where appropriate) must be defined in a derived class.

  • scale (float) – Scaling parameter. Default: 1.0.

__call__(x)[source]#

Evaluate this loss at point \(\mb{x}\).

Parameters:

x (Union[Array, BlockArray]) – Point at which to evaluate loss.

Return type:

float

prox(v, lam=1, **kwargs)[source]#

Scaled proximal operator of loss function.

Evaluate scaled proximal operator of this loss function, with scaling \(\lambda\) = lam and evaluated at point \(\mb{v}\) = v. If prox is not defined in a derived class, and if operator \(A\) is the identity operator, then the proximal operator is computed using the proximal operator of functional \(l\), via Theorem 6.11 in [7].

Parameters:
  • v (Union[Array, BlockArray]) – Point at which to evaluate prox function.

  • lam (float) – Proximal parameter \(\lambda\).

  • kwargs – Additional arguments that may be used by derived classes. These include x0, an initial guess for the minimizer in the defintion of \(\mathrm{prox}\).

Return type:

Union[Array, BlockArray]

set_scale(new_scale)[source]#

Update the scale attribute.

class scico.loss.SquaredL2Loss(y, A=None, scale=0.5, W=None, prox_kwargs=None)[source]#

Bases: Loss

Weighted squared \(\ell_2\) loss.

Inheritance diagram of SquaredL2Loss

Weighted squared \(\ell_2\) loss

\[\alpha \norm{\mb{y} - A(\mb{x})}_W^2 = \alpha \left(\mb{y} - A(\mb{x})\right)^T W \left(\mb{y} - A(\mb{x})\right) \;,\]

where \(\alpha\) is the scaling parameter and \(W\) is an instance of scico.linop.Diagonal. If \(W\) is None, the weighting is an identity operator, giving an unweighted squared \(\ell_2\) loss.

Parameters:
__call__(x)[source]#

Evaluate this loss at point \(\mb{x}\).

Parameters:

x (Union[Array, BlockArray]) – Point at which to evaluate loss.

Return type:

float

prox(v, lam=1.0, **kwargs)[source]#

Scaled proximal operator of loss function.

Evaluate scaled proximal operator of this loss function, with scaling \(\lambda\) = lam and evaluated at point \(\mb{v}\) = v. If prox is not defined in a derived class, and if operator \(A\) is the identity operator, then the proximal operator is computed using the proximal operator of functional \(l\), via Theorem 6.11 in [7].

Parameters:
  • v (Union[Array, BlockArray]) – Point at which to evaluate prox function.

  • lam (float) – Proximal parameter \(\lambda\).

  • kwargs – Additional arguments that may be used by derived classes. These include x0, an initial guess for the minimizer in the defintion of \(\mathrm{prox}\).

Return type:

Union[Array, BlockArray]

property hessian: LinearOperator#

Compute the Hessian of linear operator A.

If self.A is a scico.linop.LinearOperator, returns a scico.linop.LinearOperator corresponding to the Hessian \(2 \alpha \mathrm{A^H W A}\). Otherwise not implemented.

class scico.loss.PoissonLoss(y, A=None, scale=0.5)[source]#

Bases: Loss

Poisson negative log likelihood loss.

Inheritance diagram of PoissonLoss

Poisson negative log likelihood loss

\[\alpha \left( \sum_i [A(x)]_i - y_i \log\left( [A(x)]_i \right) + \log(y_i!) \right) \;,\]

where \(\alpha\) is the scaling parameter.

Parameters:
const#

Constant term, \(\ln(y!)\), in Poisson log likehood.

__call__(x)[source]#

Evaluate this loss at point \(\mb{x}\).

Parameters:

x (Union[Array, BlockArray]) – Point at which to evaluate loss.

Return type:

float

class scico.loss.SquaredL2AbsLoss(y, A=None, scale=0.5, W=None)[source]#

Bases: Loss

Weighted squared \(\ell_2\) with absolute value loss.

Inheritance diagram of SquaredL2AbsLoss

Weighted squared \(\ell_2\) with absolute value loss

\[\alpha \norm{\mb{y} - | A(\mb{x}) |\,}_W^2 = \alpha \left(\mb{y} - | A(\mb{x}) |\right)^T W \left(\mb{y} - | A(\mb{x}) |\right) \;,\]

where \(\alpha\) is the scaling parameter and \(W\) is an instance of scico.linop.Diagonal.

Proximal operator prox is implemented when \(A\) is an instance of scico.linop.Identity. This is not proximal operator according to the strict definition since the loss function is non-convex (Sec. 3) [46].

Parameters:
__call__(x)[source]#

Evaluate this loss at point \(\mb{x}\).

Parameters:

x (Union[Array, BlockArray]) – Point at which to evaluate loss.

Return type:

float

prox(v, lam=1.0, **kwargs)[source]#

Scaled proximal operator of loss function.

Evaluate scaled proximal operator of this loss function, with scaling \(\lambda\) = lam and evaluated at point \(\mb{v}\) = v. If prox is not defined in a derived class, and if operator \(A\) is the identity operator, then the proximal operator is computed using the proximal operator of functional \(l\), via Theorem 6.11 in [7].

Parameters:
  • v (Union[Array, BlockArray]) – Point at which to evaluate prox function.

  • lam (float) – Proximal parameter \(\lambda\).

  • kwargs – Additional arguments that may be used by derived classes. These include x0, an initial guess for the minimizer in the defintion of \(\mathrm{prox}\).

Return type:

Union[Array, BlockArray]

class scico.loss.SquaredL2SquaredAbsLoss(y, A=None, scale=0.5, W=None)[source]#

Bases: Loss

Weighted squared \(\ell_2\) with squared absolute value loss.

Inheritance diagram of SquaredL2SquaredAbsLoss

Weighted squared \(\ell_2\) with squared absolute value loss

\[\alpha \norm{\mb{y} - | A(\mb{x}) |^2 \,}_W^2 = \alpha \left(\mb{y} - | A(\mb{x}) |^2 \right)^T W \left(\mb{y} - | A(\mb{x}) |^2 \right) \;,\]

where \(\alpha\) is the scaling parameter and \(W\) is an instance of scico.linop.Diagonal.

Proximal operator prox is implemented when \(A\) is an instance of scico.linop.Identity. This is not proximal operator according to the strict definition since the loss function is non-convex (Sec. 3) [46].

Parameters:
__call__(x)[source]#

Evaluate this loss at point \(\mb{x}\).

Parameters:

x (Union[Array, BlockArray]) – Point at which to evaluate loss.

Return type:

float

prox(v, lam=1.0, **kwargs)[source]#

Scaled proximal operator of loss function.

Evaluate scaled proximal operator of this loss function, with scaling \(\lambda\) = lam and evaluated at point \(\mb{v}\) = v. If prox is not defined in a derived class, and if operator \(A\) is the identity operator, then the proximal operator is computed using the proximal operator of functional \(l\), via Theorem 6.11 in [7].

Parameters:
  • v (Union[Array, BlockArray]) – Point at which to evaluate prox function.

  • lam (float) – Proximal parameter \(\lambda\).

  • kwargs – Additional arguments that may be used by derived classes. These include x0, an initial guess for the minimizer in the defintion of \(\mathrm{prox}\).

Return type:

Union[Array, BlockArray]