Norm function class hierarchy¶
Base class¶
-
class
pyunlocbox.functions.
norm
(lambda_=1, y=0, w=1, A=None, At=None, tight=True, nu=1, *args, **kwargs)[source]¶ Bases:
pyunlocbox.functions.func
Base class which defines the attributes of the norm objects.
See generic attributes descriptions of the
pyunlocbox.functions.func
base class.Parameters: lambda_ : float, optional
Regularization parameter \(\lambda\). Default is 1.
y : array_like, optional
Measurements. Default is 0.
w : array_like, optional
Weights for a weighted norm. Default is 1.
A : function or ndarray, optional
The forward operator. Default is the identity, \(A(x)=x\). If A is an
ndarray
, it will be converted to the operator form.At : function or ndarray, optional
The adjoint operator. If At is an
ndarray
, it will be converted to the operator form. If A is anndarray
, default is the transpose of A. If A is a function, default is A, \(At(x)=A(x)\).tight : bool, optional
True
if A is a tight frame,False
otherwise. Default isTrue
.nu : float, optional
Bound on the norm of the operator A, i.e. \(||A(x)||^2 \leq \nu ||x||^2\). Default is 1.
L1-norm¶
-
class
pyunlocbox.functions.
norm_l1
(lambda_=1, y=0, w=1, A=None, At=None, tight=True, nu=1, *args, **kwargs)[source]¶ Bases:
pyunlocbox.functions.norm
L1-norm function object.
See generic attributes descriptions of the
pyunlocbox.functions.norm
base class.Notes
- The L-1 norm of the vector x is given by \(\lambda ||w \cdot (A(x)-y)||_1\)
- The L1-norm proximal operator evaluated at x is given by \(\min_z \frac{1}{2} ||x-z||_2^2 + \gamma ||w \cdot (A(z)-y)||_1\) where \(\gamma = \lambda \cdot T\) This is simply a soft thresholding.
Examples
>>> import pyunlocbox >>> f = pyunlocbox.functions.norm_l1(verbosity='low') >>> f.eval([1, 2, 3, 4]) norm_l1 evaluation : 1.000000e+01 10 >>> f.prox([1, 2, 3, 4], 1) array([ 0., 1., 2., 3.])
L2-norm¶
-
class
pyunlocbox.functions.
norm_l2
(lambda_=1, y=0, w=1, A=None, At=None, tight=True, nu=1, *args, **kwargs)[source]¶ Bases:
pyunlocbox.functions.norm
L2-norm function object.
See generic attributes descriptions of the
pyunlocbox.functions.norm
base class.Notes
- The squared L-2 norm of the vector x is given by \(\lambda ||w \cdot (A(x)-y)||_2^2\)
- The squared L2-norm proximal operator evaluated at x is given by \(\min_z \frac{1}{2} ||x-z||_2^2 + \gamma ||w \cdot (A(z)-y)||_2^2\) where \(\gamma = \lambda \cdot T\)
- The squared L2-norm gradient evaluated at x is given by \(2 \lambda \cdot At(w \cdot (A(x)-y))\)
Examples
>>> import pyunlocbox >>> f = pyunlocbox.functions.norm_l2(verbosity='low') >>> x = [1, 2, 3, 4] >>> f.eval(x) norm_l2 evaluation : 3.000000e+01 30 >>> f.prox(x, 1) array([ 0.33333333, 0.66666667, 1. , 1.33333333]) >>> f.grad(x) array([2, 4, 6, 8])