Constructors¶
Module: pycsou.func.base
Interface classes for constructing functionals.
|
Stack functionals horizontally. |
|
Base class for \(\ell_p\)-norms. |
|
Base class for indicator functionals. |
Null differentiable functional. |
|
Null proximable functional. |
-
class
ProxFuncHStack
(*proxfuncs, n_jobs: int = 1, joblib_backend: str = 'loky')[source]¶ Bases:
pycsou.core.functional.ProximableFunctional
,pycsou.core.map.MapHStack
Stack functionals horizontally.
Consider a collection \(\{f_i:\mathbb{R}^{N_i}\to \mathbb{R}, i=1,\ldots, k\}\) of functionals. Their horizontal stacking is defined as the operator
\[\begin{split}h:\begin{cases}\mathbb{R}^{N_1}\times \cdots \times\mathbb{R}^{N_k}\to \mathbb{R}\\ (\mathbf{x}_1,\ldots, \mathbf{x}_k)\mapsto \sum_{i=1}^k f_i(\mathbf{x}_i). \end{cases}\end{split}\]The proximity operator of \(h\) is moreover given by ([ProxAlg] Section 2.1):
\[\mathbf{\text{prox}}_{\tau h}(\mathbf{x}_1,\ldots, \mathbf{x}_k)=\left(\mathbf{\text{prox}}_{\tau f_1}(\mathbf{x}_1),\ldots, \mathbf{\text{prox}}_{\tau f_k}(\mathbf{x}_k)\right).\]Examples
>>> from pycsou.func.penalty import L1Norm, SquaredL1Norm >>> func1 = L1Norm(dim=10) >>> func2 = SquaredL1Norm(dim=10) >>> func = ProxFuncHStack(func1, func2) >>> x = np.arange(10); y= x/2; tau=0.1 >>> np.allclose(func.prox(np.concatenate((x,y)), tau), np.concatenate((func1.prox(x, tau), func2.prox(y, tau)))) True >>> parfunc=ProxFuncHStack(func1, func2, n_jobs=-1) >>> np.allclose(func.prox(np.concatenate((x,y)), tau),parfunc.prox(np.concatenate((x,y)), tau)) True
-
__init__
(*proxfuncs, n_jobs: int = 1, joblib_backend: str = 'loky')[source]¶ - Parameters
proxfuncs (ProximableFunctional) – List of proximable functionals to stack.
n_jobs (int) – Number of cores to be used for parallel evaluation of the proximal operator. If
n_jobs==1
, the proximal operator of the functional stack is evaluated sequentially, otherwise it is evaluated in parallel. Settingn_jobs=-1
uses all available cores.joblib_backend (str) – Joblib backend (more details here).
-
prox
(x: Union[numbers.Number, numpy.ndarray], tau: numbers.Number) → Union[numbers.Number, numpy.ndarray][source]¶ Evaluate the proximity operator of the
tau
-scaled functional at the pointx
.- Parameters
x (Union[Number, np.ndarray]) – Point at which to perform the evaluation.
tau (Number) – Scale.
- Returns
Evaluation of the proximity operator of the
tau
-scaled functional at the pointx
.- Return type
Union[Number, np.ndarray]
-
-
class
DiffFuncHStack
(*difffuncs, n_jobs: int = 1, joblib_backend: str = 'loky')[source]¶ Bases:
pycsou.core.functional.DifferentiableFunctional
,pycsou.core.map.DiffMapHStack
-
__init__
(*difffuncs, n_jobs: int = 1, joblib_backend: str = 'loky')[source]¶ - Parameters
difffuncs (DifferentiableFunctional) – List of differentiable functionals to stack.
n_jobs (int) – Number of cores to be used for parallel evaluation of the functional stack and its gradient. If
n_jobs==1
, the proximal operator of the functional stack and its gradient are evaluated sequentially, otherwise they are evaluated in parallel. Settingn_jobs=-1
uses all available cores.joblib_backend (str) –
Joblib backend (more details here).
-
jacobianT
(arg: Union[numbers.Number, numpy.ndarray]) → Union[numbers.Number, numpy.ndarray][source]¶ Transpose of the Jacobian matrix of the differentiable map evaluated at
arg
.- Parameters
arg (Union[Number, np.ndarray]) – Point at which the transposed Jacobian matrix is evaluated.
- Returns
Linear operator associated to the transposed Jacobian matrix.
- Return type
-
-
class
ExplicitLinearFunctional
(vec: numpy.ndarray, dtype: type = <class 'numpy.float64'>)[source]¶ Bases:
pycsou.core.functional.LinearFunctional
Base class for linear functionals.
-
class
IndicatorFunctional
(dim: int, condition_func: Callable, projection_func: Callable)[source]¶ Bases:
pycsou.core.functional.ProximableFunctional
Base class for indicator functionals.
-
__init__
(dim: int, condition_func: Callable, projection_func: Callable)[source]¶ - Parameters
dim (int) – Dimension of the functional’s domain.
condition_func (Callable) – Condition delimiting the domain of the indicator functional.
projection_func (Callable) – Projecton onto the domain of the indicator functional.
See also
-
prox
(x: Union[numbers.Number, numpy.ndarray], tau: numbers.Number, **kwargs) → Union[numbers.Number, numpy.ndarray][source]¶ Evaluate the proximity operator of the
tau
-scaled functional at the pointx
.- Parameters
x (Union[Number, np.ndarray]) – Point at which to perform the evaluation.
tau (Number) – Scale.
- Returns
Evaluation of the proximity operator of the
tau
-scaled functional at the pointx
.- Return type
Union[Number, np.ndarray]
-
-
class
NullDifferentiableFunctional
(dim: int)[source]¶ Bases:
pycsou.core.functional.DifferentiableFunctional
Null differentiable functional.
-
jacobianT
(arg: Union[numbers.Number, numpy.ndarray]) → Union[numbers.Number, numpy.ndarray][source]¶ Transpose of the Jacobian matrix of the differentiable map evaluated at
arg
.- Parameters
arg (Union[Number, np.ndarray]) – Point at which the transposed Jacobian matrix is evaluated.
- Returns
Linear operator associated to the transposed Jacobian matrix.
- Return type
-
-
class
NullProximableFunctional
(dim: int)[source]¶ Bases:
pycsou.core.functional.ProximableFunctional
Null proximable functional.
-
prox
(x: Union[numbers.Number, numpy.ndarray], tau: numbers.Number) → Union[numbers.Number, numpy.ndarray][source]¶ Evaluate the proximity operator of the
tau
-scaled functional at the pointx
.- Parameters
x (Union[Number, np.ndarray]) – Point at which to perform the evaluation.
tau (Number) – Scale.
- Returns
Evaluation of the proximity operator of the
tau
-scaled functional at the pointx
.- Return type
Union[Number, np.ndarray]
-
-
class
LpNorm
(dim: int, proj_lq_ball: Callable)[source]¶ Bases:
pycsou.core.functional.ProximableFunctional
Base class for \(\ell_p\)-norms.
Proximity operators of \(\ell_p\)-norms are computed via Moreau’s identity and the knowledge of the projection onto the conjugate \(\ell_p\)-ball with \(1/p+1/q=1.\)
-
__init__
(dim: int, proj_lq_ball: Callable)[source]¶ - Parameters
dim (int) – Dimension of the functional’s domain.
proj_lq_ball (Callable[x: np.ndarray, radius: float]) – Projection onto the \(\ell_q\)-ball where \(1/p+1/q=1.\)
See also
-
prox
(x: Union[numbers.Number, numpy.ndarray], tau: numbers.Number) → Union[numbers.Number, numpy.ndarray][source]¶ Evaluate the proximity operator of the
tau
-scaled functional at the pointx
.- Parameters
x (Union[Number, np.ndarray]) – Point at which to perform the evaluation.
tau (Number) – Scale.
- Returns
Evaluation of the proximity operator of the
tau
-scaled functional at the pointx
.- Return type
Union[Number, np.ndarray]
-