atoms.svd_norms

Module: atoms.svd_norms

Inheritance diagram for regreg.atoms.svd_norms:

digraph inheritancefbf9bde437 { rankdir=LR; size="8.0, 12.0"; "atoms.cones.cone" [URL="regreg.atoms.cones.html#regreg.atoms.cones.cone",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="A class that defines the API for cone constraints."]; "regreg.atoms.atom" -> "atoms.cones.cone" [arrowsize=0.5,style="setlinewidth(0.5)"]; "atoms.seminorms.seminorm" [URL="regreg.atoms.seminorms.html#regreg.atoms.seminorms.seminorm",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="An atom that can be in lagrange or bound form."]; "regreg.atoms.atom" -> "atoms.seminorms.seminorm" [arrowsize=0.5,style="setlinewidth(0.5)"]; "atoms.svd_norms.nuclear_norm" [URL="#regreg.atoms.svd_norms.nuclear_norm",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="The nuclear norm"]; "atoms.svd_norms.svd_atom" -> "atoms.svd_norms.nuclear_norm" [arrowsize=0.5,style="setlinewidth(0.5)"]; "atoms.svd_norms.nuclear_norm_epigraph" [URL="#regreg.atoms.svd_norms.nuclear_norm_epigraph",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top"]; "atoms.svd_norms.svd_cone" -> "atoms.svd_norms.nuclear_norm_epigraph" [arrowsize=0.5,style="setlinewidth(0.5)"]; "atoms.svd_norms.nuclear_norm_epigraph_polar" [URL="#regreg.atoms.svd_norms.nuclear_norm_epigraph_polar",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top"]; "atoms.svd_norms.svd_cone" -> "atoms.svd_norms.nuclear_norm_epigraph_polar" [arrowsize=0.5,style="setlinewidth(0.5)"]; "atoms.svd_norms.operator_norm" [URL="#regreg.atoms.svd_norms.operator_norm",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="The operator norm"]; "atoms.svd_norms.svd_atom" -> "atoms.svd_norms.operator_norm" [arrowsize=0.5,style="setlinewidth(0.5)"]; "atoms.svd_norms.operator_norm_epigraph" [URL="#regreg.atoms.svd_norms.operator_norm_epigraph",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top"]; "atoms.svd_norms.svd_cone" -> "atoms.svd_norms.operator_norm_epigraph" [arrowsize=0.5,style="setlinewidth(0.5)"]; "atoms.svd_norms.operator_norm_epigraph_polar" [URL="#regreg.atoms.svd_norms.operator_norm_epigraph_polar",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top"]; "atoms.svd_norms.svd_cone" -> "atoms.svd_norms.operator_norm_epigraph_polar" [arrowsize=0.5,style="setlinewidth(0.5)"]; "atoms.svd_norms.svd_atom" [URL="#regreg.atoms.svd_norms.svd_atom",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top"]; "atoms.seminorms.seminorm" -> "atoms.svd_norms.svd_atom" [arrowsize=0.5,style="setlinewidth(0.5)"]; "atoms.svd_norms.svd_cone" [URL="#regreg.atoms.svd_norms.svd_cone",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top"]; "atoms.cones.cone" -> "atoms.svd_norms.svd_cone" [arrowsize=0.5,style="setlinewidth(0.5)"]; "problems.composite.composite" [URL="regreg.problems.composite.html#regreg.problems.composite.composite",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="A generic way to specify a problem in composite form."]; "problems.composite.nonsmooth" [URL="regreg.problems.composite.html#regreg.problems.composite.nonsmooth",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="A composite subclass that explicitly returns 0"]; "problems.composite.composite" -> "problems.composite.nonsmooth" [arrowsize=0.5,style="setlinewidth(0.5)"]; "regreg.atoms.atom" [URL="regreg.atoms.html#regreg.atoms.atom",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="A class that defines the API for support functions."]; "problems.composite.nonsmooth" -> "regreg.atoms.atom" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

This module contains the implementation operator and nuclear norms, used in matrix completion problems and other low-rank factorization problems.

Classes

nuclear_norm

class regreg.atoms.svd_norms.nuclear_norm(shape, lagrange=None, bound=None, offset=None, quadratic=None, initial=None)

Bases: regreg.atoms.svd_norms.svd_atom

The nuclear norm

__init__(shape, lagrange=None, bound=None, offset=None, quadratic=None, initial=None)

Initialize self. See help(type(self)) for accurate signature.

classmethod affine(linear_operator, offset, lagrange=None, diag=False, bound=None, quadratic=None)

This is the same as the linear class method but with offset as a positional argument

apply_offset(x)

If self.offset is not None, return x-self.offset, else return x.

property bound
bound_prox(X, bound=None)

Return unique minimizer

\[{B}^{\delta}(\theta) = \text{argmin}_{B \in \mathbb{R}^{{n \times p}}} \frac{1}{2} \|\theta-B\|^2_2 \ \text{s.t.} \ \|B\|_* \leq \delta\]

where \(\delta\) is the bound parameter and \(\theta\) is arg.

If the argument bound is None and the atom is in bound mode, self.bound is used as the bound parameter, else an exception is raised.

The class atom’s bound_prox just returns the appropriate bound parameter for use by the subclasses.

Parameters

arg : np.ndarray(np.float)

Argument of the proximal map.

bound : float (optional)

Bound for the constraint on the seminorm. Defaults to self.bound.

Returns

Z : np.ndarray(np.float)

The proximal map of arg.

static check_subgradient(atom, prox_center)

For a given seminorm, verify the KKT condition for the problem for the proximal problem

\[\text{minimize}_u \frac{1}{2} \|u-z\|^2_2 + h(z)\]

where \(z\) is the prox_center and \(h\) is atom which may be in Lagrange or bound form.

If the atom is in Lagrange form, this function should return two values equal to the seminorm of the minimizer. If it is bound form it should return two values equal to the dual seminorm of the residual, i.e. the prox_center minus the minimizer.

Parameters

atom : seminorm

prox_center : np.ndarray(np.float)

Center for the proximal map.

Returns

v1, v2 : float

Two values that should be equal if the proximal map is correct.

property conjugate
constraint(X, bound=None)

Verify \(\|B\|_* \leq \delta\), where \(\delta\) is bound.

If the result is True, returns 0, else returns np.inf.

The class seminorm’s constraint just returns the appropriate bound parameter for use by the subclasses.

property dual
get_bound()

Get method of the bound property.

>>> import regreg.api as rr
>>> constraint = rr.nuclear_norm((5,4), bound=2.3) 
>>> constraint.bound
2.3
get_conjugate()

Return the conjugate of an given atom.

>>> import regreg.api as rr
>>> penalty = rr.nuclear_norm((5,4), lagrange=3.4)
>>> penalty.get_conjugate() 
operator_norm(..., bound=3.4...)
get_dual()

Return the dual of an atom. This dual is formed by making introducing new variables \(v=Ax\) where \(A\) is self.linear_transform.

>>> import regreg.api as rr
>>> penalty = rr.nuclear_norm((5,4), lagrange=2.3)
>>> penalty 
nuclear_norm(..., lagrange=2.3...)
>>> penalty.dual 
(<regreg.affine.identity object at 0x...>, operator_norm(..., bound=2.3...))

If there is a linear part to the penalty, the linear_transform may not be identity. For example, the 1D fused LASSO penalty:

>>> D = (np.identity(4) + np.diag(-np.ones(3),1))[:-1]
>>> D
array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]])
>>> linear_atom = rr.l1norm.linear(D, lagrange=2.3)
>>> linear_atom 
affine_atom(l1norm((3,), lagrange=2.3...), array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]]))
>>> linear_atom.dual 
(<regreg.affine.linear_transform object at 0x...>, supnorm((3,), bound=2.3...))
get_lagrange()

Get method of the lagrange property.

>>> import regreg.api as rr
>>> penalty = rr.nuclear_norm((5,4), lagrange=3.4)
>>> penalty.lagrange
3.4
get_offset()
get_quadratic()

Get the quadratic part of the composite.

property lagrange
lagrange_prox(X, lipschitz=1, lagrange=None)

Return unique minimizer

\[{B}^{\lambda}(\theta) = \text{argmin}_{B \in \mathbb{R}^{{n \times p}}} \frac{L}{2} \|\theta-B\|^2_2 + \lambda \|B\|_* \]

Above, \(\lambda\) is the Lagrange parameter and \(L\) is the Lipschitz parameter and \(\theta\) is arg.

If the argument lagrange is None and the atom is in lagrange mode, self.lagrange is used as the lagrange parameter, else an exception is raised.

The class atom’s lagrange_prox just returns the appropriate lagrange parameter for use by the subclasses.

Parameters

arg : np.ndarray(np.float)

Argument of the proximal map.

lipschitz : float

Coefficient in front of the quadratic.

lagrange : float (optional)

Lagrange factor in front of the seminorm. Defaults to self.lagrange.

Returns

Z : np.ndarray(np.float)

The proximal map of arg.

latexify(var=None, idx='')

Return a LaTeX representation of an object.

>>> import regreg.api as rr
>>> penalty = rr.l1norm(10, lagrange=0.9)
>>> penalty.latexify(var=r'\gamma') 
'\\lambda_{} \\|\\gamma\\|_1'
Parameters

var : string

Argument of the functions

idx : string

Optional subscript index.

Returns

L : string

A LaTeX representation of the atom.

classmethod linear(linear_operator, lagrange=None, diag=False, bound=None, quadratic=None, offset=None)
property linear_transform

The linear transform applied before a penalty is computed. Defaults to regreg.affine.identity

>>> from regreg.api import l1norm
>>> penalty = l1norm(30, lagrange=3.4)
>>> type(penalty.linear_transform)
<class 'regreg.affine.identity'>
nonsmooth_objective(arg, check_feasibility=False)

The nonsmooth objective function of the atom. Includes self.quadratic.objective(arg).

>>> import regreg.api as rr
>>> penalty = rr.l1norm(4, lagrange=2)
>>> penalty.nonsmooth_objective([3, 4, 5, 9])
42.0
>>> 2 * sum([3, 4, 5, 9])
42
Parameters

arg : np.ndarray(np.float)

Argument of the seminorm.

check_feasibility : bool

If True, then return np.inf if appropriate.

Returns

value : np.float

The seminorm of arg.

objective(x, check_feasibility=False)
objective_template = '\\|%(var)s\\|_*'
objective_vars = {'dualnormklass': 'operator_norm', 'initargs': '(5,4)', 'linear': 'D', 'normklass': 'nuclear_norm', 'offset': '\\alpha', 'shape': '{n \\times p}', 'var': 'B'}
property offset
prox_tol = 1e-10
proximal(quadratic, prox_control=None)

The proximal operator. If the atom is in Lagrange mode, this has the form

\[B^{\lambda}(\theta) = \text{argmin}_{B \in \mathbb{R}^{{n \times p}}} \frac{L}{2} \|\theta-B\|^2_2 + \lambda h(B-\alpha) + \langle B, \eta \rangle\]

where \(\alpha\) is self.offset, \(\eta\) is quadratic.linear_term, \(\theta\) is quadratic.center and

\[h(B) = \|B\|_*\]

If the atom is in bound mode, then this has the form

\[B^{\delta}(\theta) = \text{argmin}_{B \in \mathbb{R}^{{n \times p}}} \frac{L}{2} \|\theta-B\|^2_2 + \langle B, \eta \rangle \ \text{s.t.} \ h(B - \alpha) \leq \delta\]
>>> import regreg.api as rr
>>> penalty = rr.l1norm(4, lagrange=2)
>>> Q = rr.identity_quadratic(1.5, [3, -4, -1, 1], 0, 0)
>>> penalty.proximal(Q) 
array([ 1.6666..., -2.6666..., -0.        ,  0.        ])
Parameters

quadratic : regreg.identity_quadratic.identity_quadratic

A quadratic added to the atom before minimizing.

prox_control : [None, dict]

This argument is ignored for seminorms, but otherwise is passed to regreg.algorithms.FISTA if the atom needs to be solved iteratively.

Returns

Z : np.ndarray(np.float)

The proximal map of the implied center of quadratic.

proximal_optimum(quadratic)
proximal_step(quadratic, prox_control=None)

Compute the proximal optimization

Parameters

prox_control: [None, dict]

If not None, then a dictionary of parameters for the prox procedure

property quadratic

Quadratic part of the object, instance of regreg.identity_quadratic.identity_quadratic.

seminorm(X, check_feasibility=False, lagrange=None)

Return \(\lambda \cdot \|B\|_*\), where \(\lambda\) is lagrange. If check_feasibility is True, and seminorm is unbounded, will return np.inf if appropriate.

The class seminorm’s seminorm just returns the appropriate lagrange parameter for use by the subclasses.

set_bound(bound)

Set method of the bound property.

>>> import regreg.api as rr
>>> constraint = rr.nuclear_norm((5,4), bound=3.4) 
>>> constraint.bound
3.4
>>> constraint.bound = 2.3
>>> constraint.bound
2.3
>>> penalty = rr.nuclear_norm((5,4), lagrange=2.3)
>>> penalty.bound = 3.4 
Traceback (most recent call last):
...
AttributeError: atom is in lagrange mode
set_lagrange(lagrange)

Set method of the lagrange property.

>>> import regreg.api as rr
>>> penalty = rr.nuclear_norm((5,4), lagrange=3.4)
>>> penalty.lagrange
3.4
>>> penalty.lagrange = 2.3
>>> penalty.lagrange
2.3
>>> constraint = rr.nuclear_norm((5,4), bound=3.4)
>>> constraint.lagrange = 3.4 
Traceback (most recent call last):
...
AttributeError: atom is in bound mode
set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

classmethod shift(offset, lagrange=None, diag=False, bound=None, quadratic=None)
smooth_objective(x, mode='both', check_feasibility=False)

The zero function.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)
tol = 1e-05

nuclear_norm_epigraph

class regreg.atoms.svd_norms.nuclear_norm_epigraph(input_shape, offset=None, quadratic=None, initial=None)

Bases: regreg.atoms.svd_norms.svd_cone

__init__(input_shape, offset=None, quadratic=None, initial=None)

Initialize self. See help(type(self)) for accurate signature.

classmethod affine(linear_operator, offset, diag=False, quadratic=None)
apply_offset(x)

If self.offset is not None, return x-self.offset, else return x.

static check_subgradient(atom, prox_center)

For a given seminorm, verify the KKT condition for the problem for the proximal problem

\[\text{minimize}_u \frac{1}{2} \|u-z\|^2_2 + h(z)\]

where \(z\) is the prox_center and \(h\) is atom.

This should return two values that are 0, one is the inner product of the minimizer and the residual, the other is just 0.

Parameters

atom : cone

A cone instance with a proximal method.

prox_center : np.ndarray(np.float)

Center for the proximal map.

Returns

v1, v2 : float

Two values that should be equal if the proximal map is correct.

cone_prox(normX, lipschitz=1)

Return (unique) minimizer

\[B^{\lambda}(u) = \text{argmin}_{B \in \mathbb{R}^{n \times p + 1}} \frac{1}{2} \|B-u\|^2_2 + I^{\infty}(\|B[:-1]\|_* \leq B[-1])\]
property conjugate
constraint(normX)

The constraint

\[I^{\infty}(\|B[:-1]\|_* \leq B[-1])\]
property dual
get_conjugate()

Return the conjugate of an given atom.

>>> import regreg.api as rr
>>> penalty = rr.nuclear_norm_epigraph((5,4))
>>> penalty.get_conjugate() 
nuclear_norm_epigraph_polar((5,4), offset=None)
get_dual()

Return the dual of an atom. This dual is formed by making the substitution \(v=Ax\) where \(A\) is the self.linear_transform.

>>> import regreg.api as rr
>>> penalty = rr.nuclear_norm_epigraph((5,4))
>>> penalty 
nuclear_norm_epigraph((5,4), offset=None)
>>> penalty.dual 
(<regreg.affine.identity object at 0x...>, nuclear_norm_epigraph_polar((5,4), offset=None))

If there is a linear part to the penalty, the linear_transform may not be identity:

>>> D = (np.identity(4) + np.diag(-np.ones(3),1))[:-1]
>>> D
array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]])
>>> linear_atom = rr.nonnegative.linear(D)
>>> linear_atom 
affine_cone(nonnegative((3,), offset=None), array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]]))
>>> linear_atom.dual 
(<regreg.affine.linear_transform object at 0x...>, nonpositive((3,), offset=None))
get_offset()
get_quadratic()

Get the quadratic part of the composite.

latexify(var=None, idx='')
classmethod linear(linear_operator, diag=False, offset=None, quadratic=None)
property linear_transform

The linear transform applied before a penalty is computed. Defaults to regreg.affine.identity

>>> from regreg.api import l1norm
>>> penalty = l1norm(30, lagrange=3.4)
>>> type(penalty.linear_transform)
<class 'regreg.affine.identity'>
nonsmooth_objective(x, check_feasibility=False)
>>> import regreg.api as rr
>>> cone = rr.nonnegative(4)
>>> cone.nonsmooth_objective([3, 4, 5, 9])
0.0
objective(x, check_feasibility=False)
objective_template = 'I^{\\infty}(\\|%(var)s[:-1]\\|_* \\leq %(var)s[-1])'
objective_vars = {'coneklass': 'nuclear_norm_epigraph', 'dualconeklass': 'nuclear_norm_epigraph_polar', 'dualnormklass': 'operator_norm', 'initargs': '(5,4)', 'linear': 'D', 'normklass': 'nuclear_norm', 'offset': '\\alpha', 'shape': '{n \\times p + 1}', 'var': 'B'}
property offset
proximal(quadratic, prox_control=None)

The proximal operator.

\[v^{\lambda}(x) = \text{argmin}_{v \in \mathbb{R}^{{n \times p + 1}}} \frac{L}{2} \|x-\alpha - v\|^2_2 + I^{\infty}(\|B[:-1]\|_* \leq B[-1]) + \langle v, \eta \rangle\]

where \(\alpha\) is self.offset, \(\eta\) is quadratic.linear_term.

>>> import regreg.api as rr
>>> cone = rr.nonnegative((4,))
>>> Q = rr.identity_quadratic(1.5, [3, -4, -1, 1], 0, 0)
>>> np.allclose(cone.proximal(Q), [3, 0, 0, 1]) 
True
Parameters

quadratic : regreg.identity_quadratic.identity_quadratic

A quadratic added to the atom before minimizing.

prox_control : [None, dict]

This argument is ignored for seminorms, but otherwise is passed to regreg.algorithms.FISTA if the atom needs to be solved iteratively.

Returns

Z : np.ndarray(np.float)

The proximal map of the implied center of quadratic.

proximal_optimum(quadratic)
proximal_step(quadratic, prox_control=None)

Compute the proximal optimization

Parameters

prox_control: [None, dict]

If not None, then a dictionary of parameters for the prox procedure

property quadratic

Quadratic part of the object, instance of regreg.identity_quadratic.identity_quadratic.

set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

smooth_objective(x, mode='both', check_feasibility=False)

The zero function.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)
tol = 1e-05

nuclear_norm_epigraph_polar

class regreg.atoms.svd_norms.nuclear_norm_epigraph_polar(input_shape, offset=None, quadratic=None, initial=None)

Bases: regreg.atoms.svd_norms.svd_cone

__init__(input_shape, offset=None, quadratic=None, initial=None)

Initialize self. See help(type(self)) for accurate signature.

classmethod affine(linear_operator, offset, diag=False, quadratic=None)
apply_offset(x)

If self.offset is not None, return x-self.offset, else return x.

static check_subgradient(atom, prox_center)

For a given seminorm, verify the KKT condition for the problem for the proximal problem

\[\text{minimize}_u \frac{1}{2} \|u-z\|^2_2 + h(z)\]

where \(z\) is the prox_center and \(h\) is atom.

This should return two values that are 0, one is the inner product of the minimizer and the residual, the other is just 0.

Parameters

atom : cone

A cone instance with a proximal method.

prox_center : np.ndarray(np.float)

Center for the proximal map.

Returns

v1, v2 : float

Two values that should be equal if the proximal map is correct.

cone_prox(normX, lipschitz=1)

Return (unique) minimizer

\[B^{\lambda}(u) = \text{argmin}_{B \in \mathbb{R}^{n \times p + 1}} \frac{1}{2} \|B-u\|^2_2 + I^{\infty}(\|B[:-1]\|_{op} \leq -B[-1])\]
property conjugate
constraint(normX)

The constraint

\[I^{\infty}(\|B[:-1]\|_{op} \leq -B[-1])\]
property dual
get_conjugate()

Return the conjugate of an given atom.

>>> import regreg.api as rr
>>> penalty = rr.nuclear_norm_epigraph_polar((5,4))
>>> penalty.get_conjugate() 
nuclear_norm_epigraph((5,4), offset=None)
get_dual()

Return the dual of an atom. This dual is formed by making the substitution \(v=Ax\) where \(A\) is the self.linear_transform.

>>> import regreg.api as rr
>>> penalty = rr.nuclear_norm_epigraph_polar((5,4))
>>> penalty 
nuclear_norm_epigraph_polar((5,4), offset=None)
>>> penalty.dual 
(<regreg.affine.identity object at 0x...>, nuclear_norm_epigraph((5,4), offset=None))

If there is a linear part to the penalty, the linear_transform may not be identity:

>>> D = (np.identity(4) + np.diag(-np.ones(3),1))[:-1]
>>> D
array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]])
>>> linear_atom = rr.nonnegative.linear(D)
>>> linear_atom 
affine_cone(nonnegative((3,), offset=None), array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]]))
>>> linear_atom.dual 
(<regreg.affine.linear_transform object at 0x...>, nonpositive((3,), offset=None))
get_offset()
get_quadratic()

Get the quadratic part of the composite.

latexify(var=None, idx='')
classmethod linear(linear_operator, diag=False, offset=None, quadratic=None)
property linear_transform

The linear transform applied before a penalty is computed. Defaults to regreg.affine.identity

>>> from regreg.api import l1norm
>>> penalty = l1norm(30, lagrange=3.4)
>>> type(penalty.linear_transform)
<class 'regreg.affine.identity'>
nonsmooth_objective(x, check_feasibility=False)
>>> import regreg.api as rr
>>> cone = rr.nonnegative(4)
>>> cone.nonsmooth_objective([3, 4, 5, 9])
0.0
objective(x, check_feasibility=False)
objective_template = 'I^{\\infty}(\\|%(var)s[:-1]\\|_{op} \\leq -%(var)s[-1])'
objective_vars = {'coneklass': 'nuclear_norm_epigraph_polar', 'dualconeklass': 'nuclear_norm_epigraph', 'dualnormklass': 'operator_norm', 'initargs': '(5,4)', 'linear': 'D', 'normklass': 'nuclear_norm', 'offset': '\\alpha', 'shape': '{n \\times p + 1}', 'var': 'B'}
property offset
proximal(quadratic, prox_control=None)

The proximal operator.

\[v^{\lambda}(x) = \text{argmin}_{v \in \mathbb{R}^{{n \times p + 1}}} \frac{L}{2} \|x-\alpha - v\|^2_2 + I^{\infty}(\|B[:-1]\|_{op} \leq -B[-1]) + \langle v, \eta \rangle\]

where \(\alpha\) is self.offset, \(\eta\) is quadratic.linear_term.

>>> import regreg.api as rr
>>> cone = rr.nonnegative((4,))
>>> Q = rr.identity_quadratic(1.5, [3, -4, -1, 1], 0, 0)
>>> np.allclose(cone.proximal(Q), [3, 0, 0, 1]) 
True
Parameters

quadratic : regreg.identity_quadratic.identity_quadratic

A quadratic added to the atom before minimizing.

prox_control : [None, dict]

This argument is ignored for seminorms, but otherwise is passed to regreg.algorithms.FISTA if the atom needs to be solved iteratively.

Returns

Z : np.ndarray(np.float)

The proximal map of the implied center of quadratic.

proximal_optimum(quadratic)
proximal_step(quadratic, prox_control=None)

Compute the proximal optimization

Parameters

prox_control: [None, dict]

If not None, then a dictionary of parameters for the prox procedure

property quadratic

Quadratic part of the object, instance of regreg.identity_quadratic.identity_quadratic.

set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

smooth_objective(x, mode='both', check_feasibility=False)

The zero function.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)
tol = 1e-05

operator_norm

class regreg.atoms.svd_norms.operator_norm(shape, lagrange=None, bound=None, offset=None, quadratic=None, initial=None)

Bases: regreg.atoms.svd_norms.svd_atom

The operator norm

__init__(shape, lagrange=None, bound=None, offset=None, quadratic=None, initial=None)

Initialize self. See help(type(self)) for accurate signature.

classmethod affine(linear_operator, offset, lagrange=None, diag=False, bound=None, quadratic=None)

This is the same as the linear class method but with offset as a positional argument

apply_offset(x)

If self.offset is not None, return x-self.offset, else return x.

property bound
bound_prox(X, bound=None)

Return unique minimizer

\[{B}^{\delta}(\theta) = \text{argmin}_{B \in \mathbb{R}^{{n \times p}}} \frac{1}{2} \|\theta-B\|^2_2 \ \text{s.t.} \ \|B\|_{\text{op}} \leq \delta\]

where \(\delta\) is the bound parameter and \(\theta\) is arg.

If the argument bound is None and the atom is in bound mode, self.bound is used as the bound parameter, else an exception is raised.

The class atom’s bound_prox just returns the appropriate bound parameter for use by the subclasses.

Parameters

arg : np.ndarray(np.float)

Argument of the proximal map.

bound : float (optional)

Bound for the constraint on the seminorm. Defaults to self.bound.

Returns

Z : np.ndarray(np.float)

The proximal map of arg.

static check_subgradient(atom, prox_center)

For a given seminorm, verify the KKT condition for the problem for the proximal problem

\[\text{minimize}_u \frac{1}{2} \|u-z\|^2_2 + h(z)\]

where \(z\) is the prox_center and \(h\) is atom which may be in Lagrange or bound form.

If the atom is in Lagrange form, this function should return two values equal to the seminorm of the minimizer. If it is bound form it should return two values equal to the dual seminorm of the residual, i.e. the prox_center minus the minimizer.

Parameters

atom : seminorm

prox_center : np.ndarray(np.float)

Center for the proximal map.

Returns

v1, v2 : float

Two values that should be equal if the proximal map is correct.

property conjugate
constraint(X, bound=None)

Verify \(\|B\|_{\text{op}} \leq \delta\), where \(\delta\) is bound.

If the result is True, returns 0, else returns np.inf.

The class seminorm’s constraint just returns the appropriate bound parameter for use by the subclasses.

property dual
get_bound()

Get method of the bound property.

>>> import regreg.api as rr
>>> constraint = rr.operator_norm((5,4), bound=2.3) 
>>> constraint.bound
2.3
get_conjugate()

Return the conjugate of an given atom.

>>> import regreg.api as rr
>>> penalty = rr.operator_norm((5,4), lagrange=3.4)
>>> penalty.get_conjugate() 
nuclear_norm(..., bound=3.4...)
get_dual()

Return the dual of an atom. This dual is formed by making introducing new variables \(v=Ax\) where \(A\) is self.linear_transform.

>>> import regreg.api as rr
>>> penalty = rr.operator_norm((5,4), lagrange=2.3)
>>> penalty 
operator_norm(..., lagrange=2.3...)
>>> penalty.dual 
(<regreg.affine.identity object at 0x...>, nuclear_norm(..., bound=2.3...))

If there is a linear part to the penalty, the linear_transform may not be identity. For example, the 1D fused LASSO penalty:

>>> D = (np.identity(4) + np.diag(-np.ones(3),1))[:-1]
>>> D
array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]])
>>> linear_atom = rr.l1norm.linear(D, lagrange=2.3)
>>> linear_atom 
affine_atom(l1norm((3,), lagrange=2.3...), array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]]))
>>> linear_atom.dual 
(<regreg.affine.linear_transform object at 0x...>, supnorm((3,), bound=2.3...))
get_lagrange()

Get method of the lagrange property.

>>> import regreg.api as rr
>>> penalty = rr.operator_norm((5,4), lagrange=3.4)
>>> penalty.lagrange
3.4
get_offset()
get_quadratic()

Get the quadratic part of the composite.

property lagrange
lagrange_prox(X, lipschitz=1, lagrange=None)

Return unique minimizer

\[{B}^{\lambda}(\theta) = \text{argmin}_{B \in \mathbb{R}^{{n \times p}}} \frac{L}{2} \|\theta-B\|^2_2 + \lambda \|B\|_{\text{op}} \]

Above, \(\lambda\) is the Lagrange parameter and \(L\) is the Lipschitz parameter and \(\theta\) is arg.

If the argument lagrange is None and the atom is in lagrange mode, self.lagrange is used as the lagrange parameter, else an exception is raised.

The class atom’s lagrange_prox just returns the appropriate lagrange parameter for use by the subclasses.

Parameters

arg : np.ndarray(np.float)

Argument of the proximal map.

lipschitz : float

Coefficient in front of the quadratic.

lagrange : float (optional)

Lagrange factor in front of the seminorm. Defaults to self.lagrange.

Returns

Z : np.ndarray(np.float)

The proximal map of arg.

latexify(var=None, idx='')

Return a LaTeX representation of an object.

>>> import regreg.api as rr
>>> penalty = rr.l1norm(10, lagrange=0.9)
>>> penalty.latexify(var=r'\gamma') 
'\\lambda_{} \\|\\gamma\\|_1'
Parameters

var : string

Argument of the functions

idx : string

Optional subscript index.

Returns

L : string

A LaTeX representation of the atom.

classmethod linear(linear_operator, lagrange=None, diag=False, bound=None, quadratic=None, offset=None)
property linear_transform

The linear transform applied before a penalty is computed. Defaults to regreg.affine.identity

>>> from regreg.api import l1norm
>>> penalty = l1norm(30, lagrange=3.4)
>>> type(penalty.linear_transform)
<class 'regreg.affine.identity'>
nonsmooth_objective(arg, check_feasibility=False)

The nonsmooth objective function of the atom. Includes self.quadratic.objective(arg).

>>> import regreg.api as rr
>>> penalty = rr.l1norm(4, lagrange=2)
>>> penalty.nonsmooth_objective([3, 4, 5, 9])
42.0
>>> 2 * sum([3, 4, 5, 9])
42
Parameters

arg : np.ndarray(np.float)

Argument of the seminorm.

check_feasibility : bool

If True, then return np.inf if appropriate.

Returns

value : np.float

The seminorm of arg.

objective(x, check_feasibility=False)
objective_template = '\\|%(var)s\\|_{\\text{op}}'
objective_vars = {'dualnormklass': 'nuclear_norm', 'initargs': '(5,4)', 'linear': 'D', 'normklass': 'operator_norm', 'offset': '\\alpha', 'shape': '{n \\times p}', 'var': 'B'}
property offset
prox_tol = 1e-10
proximal(quadratic, prox_control=None)

The proximal operator. If the atom is in Lagrange mode, this has the form

\[B^{\lambda}(\theta) = \text{argmin}_{B \in \mathbb{R}^{{n \times p}}} \frac{L}{2} \|\theta-B\|^2_2 + \lambda h(B-\alpha) + \langle B, \eta \rangle\]

where \(\alpha\) is self.offset, \(\eta\) is quadratic.linear_term, \(\theta\) is quadratic.center and

\[h(B) = \|B\|_{\text{op}}\]

If the atom is in bound mode, then this has the form

\[B^{\delta}(\theta) = \text{argmin}_{B \in \mathbb{R}^{{n \times p}}} \frac{L}{2} \|\theta-B\|^2_2 + \langle B, \eta \rangle \ \text{s.t.} \ h(B - \alpha) \leq \delta\]
>>> import regreg.api as rr
>>> penalty = rr.l1norm(4, lagrange=2)
>>> Q = rr.identity_quadratic(1.5, [3, -4, -1, 1], 0, 0)
>>> penalty.proximal(Q) 
array([ 1.6666..., -2.6666..., -0.        ,  0.        ])
Parameters

quadratic : regreg.identity_quadratic.identity_quadratic

A quadratic added to the atom before minimizing.

prox_control : [None, dict]

This argument is ignored for seminorms, but otherwise is passed to regreg.algorithms.FISTA if the atom needs to be solved iteratively.

Returns

Z : np.ndarray(np.float)

The proximal map of the implied center of quadratic.

proximal_optimum(quadratic)
proximal_step(quadratic, prox_control=None)

Compute the proximal optimization

Parameters

prox_control: [None, dict]

If not None, then a dictionary of parameters for the prox procedure

property quadratic

Quadratic part of the object, instance of regreg.identity_quadratic.identity_quadratic.

seminorm(X, lagrange=None, check_feasibility=False)

Return \(\lambda \cdot \|B\|_{\text{op}}\), where \(\lambda\) is lagrange. If check_feasibility is True, and seminorm is unbounded, will return np.inf if appropriate.

The class seminorm’s seminorm just returns the appropriate lagrange parameter for use by the subclasses.

set_bound(bound)

Set method of the bound property.

>>> import regreg.api as rr
>>> constraint = rr.operator_norm((5,4), bound=3.4) 
>>> constraint.bound
3.4
>>> constraint.bound = 2.3
>>> constraint.bound
2.3
>>> penalty = rr.operator_norm((5,4), lagrange=2.3)
>>> penalty.bound = 3.4 
Traceback (most recent call last):
...
AttributeError: atom is in lagrange mode
set_lagrange(lagrange)

Set method of the lagrange property.

>>> import regreg.api as rr
>>> penalty = rr.operator_norm((5,4), lagrange=3.4)
>>> penalty.lagrange
3.4
>>> penalty.lagrange = 2.3
>>> penalty.lagrange
2.3
>>> constraint = rr.operator_norm((5,4), bound=3.4)
>>> constraint.lagrange = 3.4 
Traceback (most recent call last):
...
AttributeError: atom is in bound mode
set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

classmethod shift(offset, lagrange=None, diag=False, bound=None, quadratic=None)
smooth_objective(x, mode='both', check_feasibility=False)

The zero function.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)
tol = 1e-05

operator_norm_epigraph

class regreg.atoms.svd_norms.operator_norm_epigraph(input_shape, offset=None, quadratic=None, initial=None)

Bases: regreg.atoms.svd_norms.svd_cone

__init__(input_shape, offset=None, quadratic=None, initial=None)

Initialize self. See help(type(self)) for accurate signature.

classmethod affine(linear_operator, offset, diag=False, quadratic=None)
apply_offset(x)

If self.offset is not None, return x-self.offset, else return x.

static check_subgradient(atom, prox_center)

For a given seminorm, verify the KKT condition for the problem for the proximal problem

\[\text{minimize}_u \frac{1}{2} \|u-z\|^2_2 + h(z)\]

where \(z\) is the prox_center and \(h\) is atom.

This should return two values that are 0, one is the inner product of the minimizer and the residual, the other is just 0.

Parameters

atom : cone

A cone instance with a proximal method.

prox_center : np.ndarray(np.float)

Center for the proximal map.

Returns

v1, v2 : float

Two values that should be equal if the proximal map is correct.

cone_prox(normX, lipschitz=1)

Return (unique) minimizer

\[B^{\lambda}(u) = \text{argmin}_{B \in \mathbb{R}^{n \times p + 1}} \frac{1}{2} \|B-u\|^2_2 + I^{\infty}(\|B[:-1]\|_{op} \leq B[-1])\]
property conjugate
constraint(normX)

The constraint

\[I^{\infty}(\|B[:-1]\|_{op} \leq B[-1])\]
property dual
get_conjugate()

Return the conjugate of an given atom.

>>> import regreg.api as rr
>>> penalty = rr.operator_norm_epigraph((5,4))
>>> penalty.get_conjugate() 
operator_norm_epigraph_polar((5,4), offset=None)
get_dual()

Return the dual of an atom. This dual is formed by making the substitution \(v=Ax\) where \(A\) is the self.linear_transform.

>>> import regreg.api as rr
>>> penalty = rr.operator_norm_epigraph((5,4))
>>> penalty 
operator_norm_epigraph((5,4), offset=None)
>>> penalty.dual 
(<regreg.affine.identity object at 0x...>, operator_norm_epigraph_polar((5,4), offset=None))

If there is a linear part to the penalty, the linear_transform may not be identity:

>>> D = (np.identity(4) + np.diag(-np.ones(3),1))[:-1]
>>> D
array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]])
>>> linear_atom = rr.nonnegative.linear(D)
>>> linear_atom 
affine_cone(nonnegative((3,), offset=None), array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]]))
>>> linear_atom.dual 
(<regreg.affine.linear_transform object at 0x...>, nonpositive((3,), offset=None))
get_offset()
get_quadratic()

Get the quadratic part of the composite.

latexify(var=None, idx='')
classmethod linear(linear_operator, diag=False, offset=None, quadratic=None)
property linear_transform

The linear transform applied before a penalty is computed. Defaults to regreg.affine.identity

>>> from regreg.api import l1norm
>>> penalty = l1norm(30, lagrange=3.4)
>>> type(penalty.linear_transform)
<class 'regreg.affine.identity'>
nonsmooth_objective(x, check_feasibility=False)
>>> import regreg.api as rr
>>> cone = rr.nonnegative(4)
>>> cone.nonsmooth_objective([3, 4, 5, 9])
0.0
objective(x, check_feasibility=False)
objective_template = 'I^{\\infty}(\\|%(var)s[:-1]\\|_{op} \\leq %(var)s[-1])'
objective_vars = {'coneklass': 'operator_norm_epigraph', 'dualconeklass': 'operator_norm_epigraph_polar', 'dualnormklass': 'operator_norm', 'initargs': '(5,4)', 'linear': 'D', 'normklass': 'nuclear_norm', 'offset': '\\alpha', 'shape': '{n \\times p + 1}', 'var': 'B'}
property offset
proximal(quadratic, prox_control=None)

The proximal operator.

\[v^{\lambda}(x) = \text{argmin}_{v \in \mathbb{R}^{{n \times p + 1}}} \frac{L}{2} \|x-\alpha - v\|^2_2 + I^{\infty}(\|B[:-1]\|_{op} \leq B[-1]) + \langle v, \eta \rangle\]

where \(\alpha\) is self.offset, \(\eta\) is quadratic.linear_term.

>>> import regreg.api as rr
>>> cone = rr.nonnegative((4,))
>>> Q = rr.identity_quadratic(1.5, [3, -4, -1, 1], 0, 0)
>>> np.allclose(cone.proximal(Q), [3, 0, 0, 1]) 
True
Parameters

quadratic : regreg.identity_quadratic.identity_quadratic

A quadratic added to the atom before minimizing.

prox_control : [None, dict]

This argument is ignored for seminorms, but otherwise is passed to regreg.algorithms.FISTA if the atom needs to be solved iteratively.

Returns

Z : np.ndarray(np.float)

The proximal map of the implied center of quadratic.

proximal_optimum(quadratic)
proximal_step(quadratic, prox_control=None)

Compute the proximal optimization

Parameters

prox_control: [None, dict]

If not None, then a dictionary of parameters for the prox procedure

property quadratic

Quadratic part of the object, instance of regreg.identity_quadratic.identity_quadratic.

set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

smooth_objective(x, mode='both', check_feasibility=False)

The zero function.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)
tol = 1e-05

operator_norm_epigraph_polar

class regreg.atoms.svd_norms.operator_norm_epigraph_polar(input_shape, offset=None, quadratic=None, initial=None)

Bases: regreg.atoms.svd_norms.svd_cone

__init__(input_shape, offset=None, quadratic=None, initial=None)

Initialize self. See help(type(self)) for accurate signature.

classmethod affine(linear_operator, offset, diag=False, quadratic=None)
apply_offset(x)

If self.offset is not None, return x-self.offset, else return x.

static check_subgradient(atom, prox_center)

For a given seminorm, verify the KKT condition for the problem for the proximal problem

\[\text{minimize}_u \frac{1}{2} \|u-z\|^2_2 + h(z)\]

where \(z\) is the prox_center and \(h\) is atom.

This should return two values that are 0, one is the inner product of the minimizer and the residual, the other is just 0.

Parameters

atom : cone

A cone instance with a proximal method.

prox_center : np.ndarray(np.float)

Center for the proximal map.

Returns

v1, v2 : float

Two values that should be equal if the proximal map is correct.

cone_prox(normX, lipschitz=1)

Return (unique) minimizer

\[B^{\lambda}(u) = \text{argmin}_{B \in \mathbb{R}^{n \times p + 1}} \frac{1}{2} \|B-u\|^2_2 + I^{\infty}(\|B[:-1]\|_{*} \leq -B[-1])\]
property conjugate
constraint(normX)

The constraint

\[I^{\infty}(\|B[:-1]\|_{*} \leq -B[-1])\]
property dual
get_conjugate()

Return the conjugate of an given atom.

>>> import regreg.api as rr
>>> penalty = rr.operator_norm_epigraph_polar((5,4))
>>> penalty.get_conjugate() 
operator_norm_epigraph((5,4), offset=None)
get_dual()

Return the dual of an atom. This dual is formed by making the substitution \(v=Ax\) where \(A\) is the self.linear_transform.

>>> import regreg.api as rr
>>> penalty = rr.operator_norm_epigraph_polar((5,4))
>>> penalty 
operator_norm_epigraph_polar((5,4), offset=None)
>>> penalty.dual 
(<regreg.affine.identity object at 0x...>, operator_norm_epigraph((5,4), offset=None))

If there is a linear part to the penalty, the linear_transform may not be identity:

>>> D = (np.identity(4) + np.diag(-np.ones(3),1))[:-1]
>>> D
array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]])
>>> linear_atom = rr.nonnegative.linear(D)
>>> linear_atom 
affine_cone(nonnegative((3,), offset=None), array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]]))
>>> linear_atom.dual 
(<regreg.affine.linear_transform object at 0x...>, nonpositive((3,), offset=None))
get_offset()
get_quadratic()

Get the quadratic part of the composite.

latexify(var=None, idx='')
classmethod linear(linear_operator, diag=False, offset=None, quadratic=None)
property linear_transform

The linear transform applied before a penalty is computed. Defaults to regreg.affine.identity

>>> from regreg.api import l1norm
>>> penalty = l1norm(30, lagrange=3.4)
>>> type(penalty.linear_transform)
<class 'regreg.affine.identity'>
nonsmooth_objective(x, check_feasibility=False)
>>> import regreg.api as rr
>>> cone = rr.nonnegative(4)
>>> cone.nonsmooth_objective([3, 4, 5, 9])
0.0
objective(x, check_feasibility=False)
objective_template = 'I^{\\infty}(\\|%(var)s[:-1]\\|_{*} \\leq -%(var)s[-1])'
objective_vars = {'coneklass': 'operator_norm_epigraph_polar', 'dualconeklass': 'operator_norm_epigraph', 'dualnormklass': 'operator_norm', 'initargs': '(5,4)', 'linear': 'D', 'normklass': 'nuclear_norm', 'offset': '\\alpha', 'shape': '{n \\times p + 1}', 'var': 'B'}
property offset
proximal(quadratic, prox_control=None)

The proximal operator.

\[v^{\lambda}(x) = \text{argmin}_{v \in \mathbb{R}^{{n \times p + 1}}} \frac{L}{2} \|x-\alpha - v\|^2_2 + I^{\infty}(\|B[:-1]\|_{*} \leq -B[-1]) + \langle v, \eta \rangle\]

where \(\alpha\) is self.offset, \(\eta\) is quadratic.linear_term.

>>> import regreg.api as rr
>>> cone = rr.nonnegative((4,))
>>> Q = rr.identity_quadratic(1.5, [3, -4, -1, 1], 0, 0)
>>> np.allclose(cone.proximal(Q), [3, 0, 0, 1]) 
True
Parameters

quadratic : regreg.identity_quadratic.identity_quadratic

A quadratic added to the atom before minimizing.

prox_control : [None, dict]

This argument is ignored for seminorms, but otherwise is passed to regreg.algorithms.FISTA if the atom needs to be solved iteratively.

Returns

Z : np.ndarray(np.float)

The proximal map of the implied center of quadratic.

proximal_optimum(quadratic)
proximal_step(quadratic, prox_control=None)

Compute the proximal optimization

Parameters

prox_control: [None, dict]

If not None, then a dictionary of parameters for the prox procedure

property quadratic

Quadratic part of the object, instance of regreg.identity_quadratic.identity_quadratic.

set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

smooth_objective(x, mode='both', check_feasibility=False)

The zero function.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)
tol = 1e-05

svd_atom

class regreg.atoms.svd_norms.svd_atom(shape, lagrange=None, bound=None, offset=None, quadratic=None, initial=None)

Bases: regreg.atoms.seminorms.seminorm

__init__(shape, lagrange=None, bound=None, offset=None, quadratic=None, initial=None)

Initialize self. See help(type(self)) for accurate signature.

classmethod affine(linear_operator, offset, lagrange=None, diag=False, bound=None, quadratic=None)

This is the same as the linear class method but with offset as a positional argument

apply_offset(x)

If self.offset is not None, return x-self.offset, else return x.

property bound
bound_prox(arg, bound=None)
static check_subgradient(atom, prox_center)

For a given seminorm, verify the KKT condition for the problem for the proximal problem

\[\text{minimize}_u \frac{1}{2} \|u-z\|^2_2 + h(z)\]

where \(z\) is the prox_center and \(h\) is atom which may be in Lagrange or bound form.

If the atom is in Lagrange form, this function should return two values equal to the seminorm of the minimizer. If it is bound form it should return two values equal to the dual seminorm of the residual, i.e. the prox_center minus the minimizer.

Parameters

atom : seminorm

prox_center : np.ndarray(np.float)

Center for the proximal map.

Returns

v1, v2 : float

Two values that should be equal if the proximal map is correct.

property conjugate
constraint(arg, bound=None)
property dual
get_bound()

Get method of the bound property.

>>> import regreg.api as rr
>>> constraint = rr.l1norm((30,), bound=2.3) 
>>> constraint.bound
2.3
get_conjugate()

Return the conjugate of an given atom.

>>> import regreg.api as rr
>>> penalty = rr.l1norm((30,), lagrange=3.4)
>>> penalty.get_conjugate() 
supnorm(..., bound=3.4...)
get_dual()

Return the dual of an atom. This dual is formed by making introducing new variables \(v=Ax\) where \(A\) is self.linear_transform.

>>> import regreg.api as rr
>>> penalty = rr.l1norm((30,), lagrange=2.3)
>>> penalty 
l1norm(..., lagrange=2.3...)
>>> penalty.dual 
(<regreg.affine.identity object at 0x...>, supnorm(..., bound=2.3...))

If there is a linear part to the penalty, the linear_transform may not be identity. For example, the 1D fused LASSO penalty:

>>> D = (np.identity(4) + np.diag(-np.ones(3),1))[:-1]
>>> D
array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]])
>>> linear_atom = rr.l1norm.linear(D, lagrange=2.3)
>>> linear_atom 
affine_atom(l1norm((3,), lagrange=2.3...), array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]]))
>>> linear_atom.dual 
(<regreg.affine.linear_transform object at 0x...>, supnorm((3,), bound=2.3...))
get_lagrange()

Get method of the lagrange property.

>>> import regreg.api as rr
>>> penalty = rr.l1norm((30,), lagrange=3.4)
>>> penalty.lagrange
3.4
get_offset()
get_quadratic()

Get the quadratic part of the composite.

property lagrange
lagrange_prox(arg, lipschitz=1, lagrange=None)
latexify(var=None, idx='')

Return a LaTeX representation of an object.

>>> import regreg.api as rr
>>> penalty = rr.l1norm(10, lagrange=0.9)
>>> penalty.latexify(var=r'\gamma') 
'\\lambda_{} \\|\\gamma\\|_1'
Parameters

var : string

Argument of the functions

idx : string

Optional subscript index.

Returns

L : string

A LaTeX representation of the atom.

classmethod linear(linear_operator, lagrange=None, diag=False, bound=None, quadratic=None, offset=None)
property linear_transform

The linear transform applied before a penalty is computed. Defaults to regreg.affine.identity

>>> from regreg.api import l1norm
>>> penalty = l1norm(30, lagrange=3.4)
>>> type(penalty.linear_transform)
<class 'regreg.affine.identity'>
nonsmooth_objective(arg, check_feasibility=False)

The nonsmooth objective function of the atom. Includes self.quadratic.objective(arg).

>>> import regreg.api as rr
>>> penalty = rr.l1norm(4, lagrange=2)
>>> penalty.nonsmooth_objective([3, 4, 5, 9])
42.0
>>> 2 * sum([3, 4, 5, 9])
42
Parameters

arg : np.ndarray(np.float)

Argument of the seminorm.

check_feasibility : bool

If True, then return np.inf if appropriate.

Returns

value : np.float

The seminorm of arg.

objective(x, check_feasibility=False)
objective_template = '\\|%(var)s\\|'
objective_vars = {'dualnormklass': 'operator_norm', 'initargs': '(5,4)', 'linear': 'D', 'normklass': 'nuclear_norm', 'offset': '\\alpha', 'shape': '{n \\times p}', 'var': 'B'}
property offset
proximal(quadratic, prox_control=None)

The proximal operator. If the atom is in Lagrange mode, this has the form

\[\beta^{\lambda}(\theta) = \text{argmin}_{\beta \in \mathbb{R}^{p}} \frac{L}{2} \|\theta-\beta\|^2_2 + \lambda h(\beta-\alpha) + \langle \beta, \eta \rangle\]

where \(\alpha\) is self.offset, \(\eta\) is quadratic.linear_term, \(\theta\) is quadratic.center and

\[h(\beta) = \|\beta\|\]

If the atom is in bound mode, then this has the form

\[\beta^{\delta}(\theta) = \text{argmin}_{\beta \in \mathbb{R}^{p}} \frac{L}{2} \|\theta-\beta\|^2_2 + \langle \beta, \eta \rangle \ \text{s.t.} \ h(\beta - \alpha) \leq \delta\]
>>> import regreg.api as rr
>>> penalty = rr.l1norm(4, lagrange=2)
>>> Q = rr.identity_quadratic(1.5, [3, -4, -1, 1], 0, 0)
>>> penalty.proximal(Q) 
array([ 1.6666..., -2.6666..., -0.        ,  0.        ])
Parameters

quadratic : regreg.identity_quadratic.identity_quadratic

A quadratic added to the atom before minimizing.

prox_control : [None, dict]

This argument is ignored for seminorms, but otherwise is passed to regreg.algorithms.FISTA if the atom needs to be solved iteratively.

Returns

Z : np.ndarray(np.float)

The proximal map of the implied center of quadratic.

proximal_optimum(quadratic)
proximal_step(quadratic, prox_control=None)

Compute the proximal optimization

Parameters

prox_control: [None, dict]

If not None, then a dictionary of parameters for the prox procedure

property quadratic

Quadratic part of the object, instance of regreg.identity_quadratic.identity_quadratic.

seminorm(arg, lagrange=None, check_feasibility=False)
set_bound(bound)

Set method of the bound property.

>>> import regreg.api as rr
>>> constraint = rr.l1norm((30,), bound=3.4) 
>>> constraint.bound
3.4
>>> constraint.bound = 2.3
>>> constraint.bound
2.3
>>> penalty = rr.l1norm((30,), lagrange=2.3)
>>> penalty.bound = 3.4 
Traceback (most recent call last):
...
AttributeError: atom is in lagrange mode
set_lagrange(lagrange)

Set method of the lagrange property.

>>> import regreg.api as rr
>>> penalty = rr.l1norm((30,), lagrange=3.4)
>>> penalty.lagrange
3.4
>>> penalty.lagrange = 2.3
>>> penalty.lagrange
2.3
>>> constraint = rr.l1norm((30,), bound=3.4)
>>> constraint.lagrange = 3.4 
Traceback (most recent call last):
...
AttributeError: atom is in bound mode
set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

classmethod shift(offset, lagrange=None, diag=False, bound=None, quadratic=None)
smooth_objective(x, mode='both', check_feasibility=False)

The zero function.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)
tol = 1e-05

svd_cone

class regreg.atoms.svd_norms.svd_cone(input_shape, offset=None, quadratic=None, initial=None)

Bases: regreg.atoms.cones.cone

__init__(input_shape, offset=None, quadratic=None, initial=None)

Initialize self. See help(type(self)) for accurate signature.

classmethod affine(linear_operator, offset, diag=False, quadratic=None)
apply_offset(x)

If self.offset is not None, return x-self.offset, else return x.

static check_subgradient(atom, prox_center)

For a given seminorm, verify the KKT condition for the problem for the proximal problem

\[\text{minimize}_u \frac{1}{2} \|u-z\|^2_2 + h(z)\]

where \(z\) is the prox_center and \(h\) is atom.

This should return two values that are 0, one is the inner product of the minimizer and the residual, the other is just 0.

Parameters

atom : cone

A cone instance with a proximal method.

prox_center : np.ndarray(np.float)

Center for the proximal map.

Returns

v1, v2 : float

Two values that should be equal if the proximal map is correct.

cone_prox(x)

Return (unique) minimizer

\[\beta^{\lambda}(u) = \text{argmin}_{\beta \in \mathbb{R}^p} \frac{1}{2} \|\beta-u\|^2_2 + \|\beta\|\]
property conjugate
constraint(x)

The constraint

\[\|\beta\|\]
property dual
get_conjugate()

Return the conjugate of an given atom.

>>> import regreg.api as rr
>>> penalty = rr.nuclear_norm_epigraph((5,4))
>>> penalty.get_conjugate() 
nuclear_norm_epigraph_polar((5,4), offset=None)
get_dual()

Return the dual of an atom. This dual is formed by making the substitution \(v=Ax\) where \(A\) is the self.linear_transform.

>>> import regreg.api as rr
>>> penalty = rr.nuclear_norm_epigraph((5,4))
>>> penalty 
nuclear_norm_epigraph((5,4), offset=None)
>>> penalty.dual 
(<regreg.affine.identity object at 0x...>, nuclear_norm_epigraph_polar((5,4), offset=None))

If there is a linear part to the penalty, the linear_transform may not be identity:

>>> D = (np.identity(4) + np.diag(-np.ones(3),1))[:-1]
>>> D
array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]])
>>> linear_atom = rr.nonnegative.linear(D)
>>> linear_atom 
affine_cone(nonnegative((3,), offset=None), array([[ 1., -1.,  0.,  0.],
       [ 0.,  1., -1.,  0.],
       [ 0.,  0.,  1., -1.]]))
>>> linear_atom.dual 
(<regreg.affine.linear_transform object at 0x...>, nonpositive((3,), offset=None))
get_offset()
get_quadratic()

Get the quadratic part of the composite.

latexify(var=None, idx='')
classmethod linear(linear_operator, diag=False, offset=None, quadratic=None)
property linear_transform

The linear transform applied before a penalty is computed. Defaults to regreg.affine.identity

>>> from regreg.api import l1norm
>>> penalty = l1norm(30, lagrange=3.4)
>>> type(penalty.linear_transform)
<class 'regreg.affine.identity'>
nonsmooth_objective(x, check_feasibility=False)
>>> import regreg.api as rr
>>> cone = rr.nonnegative(4)
>>> cone.nonsmooth_objective([3, 4, 5, 9])
0.0
objective(x, check_feasibility=False)
objective_template = '\\|%(var)s\\|'
objective_vars = {'coneklass': 'nuclear_norm_epigraph', 'dualconeklass': 'nuclear_norm_epigraph_polar', 'dualnormklass': 'operator_norm', 'initargs': '(5,4)', 'linear': 'D', 'normklass': 'nuclear_norm', 'offset': '\\alpha', 'shape': '{n \\times p + 1}', 'var': 'B'}
property offset
proximal(quadratic, prox_control=None)

The proximal operator.

\[v^{\lambda}(x) = \text{argmin}_{v \in \mathbb{R}^{{n \times p + 1}}} \frac{L}{2} \|x-\alpha - v\|^2_2 + \|B\| + \langle v, \eta \rangle\]

where \(\alpha\) is self.offset, \(\eta\) is quadratic.linear_term.

>>> import regreg.api as rr
>>> cone = rr.nonnegative((4,))
>>> Q = rr.identity_quadratic(1.5, [3, -4, -1, 1], 0, 0)
>>> np.allclose(cone.proximal(Q), [3, 0, 0, 1]) 
True
Parameters

quadratic : regreg.identity_quadratic.identity_quadratic

A quadratic added to the atom before minimizing.

prox_control : [None, dict]

This argument is ignored for seminorms, but otherwise is passed to regreg.algorithms.FISTA if the atom needs to be solved iteratively.

Returns

Z : np.ndarray(np.float)

The proximal map of the implied center of quadratic.

proximal_optimum(quadratic)
proximal_step(quadratic, prox_control=None)

Compute the proximal optimization

Parameters

prox_control: [None, dict]

If not None, then a dictionary of parameters for the prox procedure

property quadratic

Quadratic part of the object, instance of regreg.identity_quadratic.identity_quadratic.

set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

smooth_objective(x, mode='both', check_feasibility=False)

The zero function.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)
tol = 1e-05