scico.loss¶
Loss function classes.
Classes
|
Generic loss function. |
|
Poisson negative log likelihood loss. |
|
Weighted squared \(\ell_2\) with absolute value loss. |
|
Weighted squared \(\ell_2\) loss. |
|
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.
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 toNone
, in which case self.A is aIdentity
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}))\). IfNone
, then__call__
andprox
(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:
- 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:
- class scico.loss.SquaredL2Loss(y, A=None, scale=0.5, W=None, prox_kwargs=None)[source]¶
Bases:
Loss
Weighted squared \(\ell_2\) loss.
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\) isNone
, 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:
- 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:
- property hessian: LinearOperator¶
Compute the Hessian of linear operator A.
If self.A is a
scico.linop.LinearOperator
, returns ascico.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.
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.
- class scico.loss.SquaredL2AbsLoss(y, A=None, scale=0.5, W=None)[source]¶
Bases:
Loss
Weighted squared \(\ell_2\) with absolute value loss.
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 ofscico.linop.Identity
. This is not proximal operator according to the strict definition since the loss function is non-convex (Sec. 3) [47].- Parameters:
- __call__(x)[source]¶
Evaluate this loss at point \(\mb{x}\).
- Parameters:
x (
Union
[Array
,BlockArray
]) – Point at which to evaluate loss.- Return type:
- 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:
- class scico.loss.SquaredL2SquaredAbsLoss(y, A=None, scale=0.5, W=None)[source]¶
Bases:
Loss
Weighted squared \(\ell_2\) with squared absolute value loss.
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 ofscico.linop.Identity
. This is not proximal operator according to the strict definition since the loss function is non-convex (Sec. 3) [47].- Parameters:
- __call__(x)[source]¶
Evaluate this loss at point \(\mb{x}\).
- Parameters:
x (
Union
[Array
,BlockArray
]) – Point at which to evaluate loss.- Return type:
- 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: