smooth

Module: smooth

Inheritance diagram for regreg.smooth:

digraph inheritance257710e8f2 { rankdir=LR; size="8.0, 12.0"; "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.smooth" [URL="regreg.problems.composite.html#regreg.problems.composite.smooth",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 has 0 as "]; "problems.composite.composite" -> "problems.composite.smooth" [arrowsize=0.5,style="setlinewidth(0.5)"]; "regreg.smooth.affine_smooth" [URL="#regreg.smooth.affine_smooth",fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5)",target="_top",tooltip="Composition of a smooth objective with an affine transform."]; "regreg.smooth.smooth_atom" -> "regreg.smooth.affine_smooth" [arrowsize=0.5,style="setlinewidth(0.5)"]; "regreg.smooth.smooth_atom" [URL="#regreg.smooth.smooth_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 for representing a smooth function and its gradient"]; "problems.composite.smooth" -> "regreg.smooth.smooth_atom" [arrowsize=0.5,style="setlinewidth(0.5)"]; "regreg.smooth.sum" [URL="#regreg.smooth.sum",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 simple way to combine smooth objectives"]; "regreg.smooth.smooth_atom" -> "regreg.smooth.sum" [arrowsize=0.5,style="setlinewidth(0.5)"]; "regreg.smooth.zero" [URL="#regreg.smooth.zero",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 zero function."]; "regreg.smooth.smooth_atom" -> "regreg.smooth.zero" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Classes

affine_smooth

class regreg.smooth.affine_smooth(smooth_atom, atransform, store_grad=True, diag=False)

Bases: regreg.smooth.smooth_atom

Composition of a smooth objective with an affine transform.

__init__(smooth_atom, atransform, store_grad=True, diag=False)
Parameters

smooth_atom : regreg.smooth.smooth_atom

A smooth atom.

atransform : regreg.affine.affine_transform

An affine transformation, or cast to one using regreg.affine.linear_transform

store_grad : bool

If True, when computing the gradient, store a reference to the gradient of smooth_atom in the attribute grad.

diag : bool

Indicates if atransform acts diagonally, i.e. a rescaling. Passed to regreg.affine.linear_transform.

classmethod affine(linear_operator, offset, coef=1, diag=False, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

apply_offset(x)

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

property coef
property conjugate
property dual
force_reshape = True
get_conjugate()
get_lipschitz()
get_offset()
get_quadratic()

Get the quadratic part of the composite.

latexify(var=None, idx='')
classmethod linear(linear_operator, coef=1, diag=False, offset=None, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

property lipschitz
nonsmooth_objective(x, check_feasibility=False)
objective(x, check_feasibility=False)
objective_template = 'f(%(var)s)'
objective_vars = {'linear': 'X'}
property offset
proximal(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.

scale(obj, copy=False)
set_lipschitz(value)
set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

classmethod shift(offset, coef=1, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

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

Compute the smooth objective at the point self.transform.affine_map(arg).

Parameters

arg : ndarray

The current parameter values.

mode : str

One of [‘func’, ‘grad’, ‘both’].

check_feasibility : bool

If True, return np.inf when point is not feasible, i.e. when beta is not in the domain.

Returns

If mode is ‘func’ returns just the objective value

at self.transform(arg), else if mode is ‘grad’ returns the gradient

else returns both.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)

smooth_atom

class regreg.smooth.smooth_atom(shape, coef=1, offset=None, quadratic=None, initial=None)

Bases: regreg.problems.composite.smooth

A class for representing a smooth function and its gradient

Parameters

shape : tuple

Shape of argument to smooth_objective

coef : float (optional)

Scalar multiple to be applied (must be nonnegative)

offset : ndarray (optional)

Vector to be subtracted before evaluating smooth_objective.

quadratic : identity_quadratic (optional)

Instance of identity_quadratic to be added to overall objective.

initial : ndarray (optional)

Initial value for coefficients.

__init__(shape, coef=1, offset=None, quadratic=None, initial=None)

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

classmethod affine(linear_operator, offset, coef=1, diag=False, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

apply_offset(x)

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

property conjugate
get_conjugate()
get_lipschitz()
get_offset()
get_quadratic()

Get the quadratic part of the composite.

latexify(var=None, idx='')
classmethod linear(linear_operator, coef=1, diag=False, offset=None, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

property lipschitz
nonsmooth_objective(x, check_feasibility=False)
objective(x, check_feasibility=False)
objective_template = 'f(%(var)s)'
objective_vars = {'coef': 'C', 'offset': '\\alpha+', 'shape': 'p', 'var': '\\beta'}
property offset
proximal(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.

scale(obj, copy=False)
set_lipschitz(value)
set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

classmethod shift(offset, coef=1, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

smooth_objective(arg, mode='both', check_feasibility=False)
Parameters

arg : ndarray

The current parameter values.

mode : str

One of [‘func’, ‘grad’, ‘both’].

check_feasibility : bool

If True, return np.inf when point is not feasible, i.e. when beta is not in the domain.

Returns

If mode is ‘func’ returns just the objective value

at beta, else if mode is ‘grad’ returns the gradient

else returns both.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)

sum

class regreg.smooth.sum(atoms, weights=None)

Bases: regreg.smooth.smooth_atom

A simple way to combine smooth objectives

__init__(atoms, weights=None)
Parameters

atoms : sequence

A sequence of regreg.smooth.smooth_atom that will be summed to make a new atom.

weights : ndarray (optional)

If provided, these weights will appear as coefficients in front of each atom.

classmethod affine(linear_operator, offset, coef=1, diag=False, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

apply_offset(x)

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

property conjugate
get_conjugate()
get_lipschitz()
get_offset()
get_quadratic()

Get the quadratic part of the composite.

latexify(var=None, idx='')
classmethod linear(linear_operator, coef=1, diag=False, offset=None, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

property lipschitz
nonsmooth_objective(x, check_feasibility=False)
objective(x, check_feasibility=False)
objective_template = 'f(%(var)s)'
objective_vars = {'coef': 'C', 'offset': '\\alpha+', 'shape': 'p', 'var': '\\beta'}
property offset
proximal(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.

scale(obj, copy=False)
set_lipschitz(value)
set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

classmethod shift(offset, coef=1, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

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

Compute the smooth objective at the point self.transform.affine_map(arg), which is the sum of each atom’s objective with its respective weight.

Parameters

arg : ndarray

The current parameter values.

mode : str

One of [‘func’, ‘grad’, ‘both’].

check_feasibility : bool

If True, return np.inf when point is not feasible, i.e. when beta is not in the domain.

Returns

If mode is ‘func’ returns just the objective value

at self.transform(arg), else if mode is ‘grad’ returns the gradient

else returns both.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)

zero

class regreg.smooth.zero(shape, coef=1, offset=None, quadratic=None, initial=None)

Bases: regreg.smooth.smooth_atom

The zero function.

__init__(shape, coef=1, offset=None, quadratic=None, initial=None)

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

classmethod affine(linear_operator, offset, coef=1, diag=False, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

apply_offset(x)

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

property conjugate
get_conjugate()
get_lipschitz()
get_offset()
get_quadratic()

Get the quadratic part of the composite.

latexify(var=None, idx='')
classmethod linear(linear_operator, coef=1, diag=False, offset=None, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

property lipschitz
nonsmooth_objective(x, check_feasibility=False)
objective(x, check_feasibility=False)
objective_template = 'f(%(var)s)'
objective_vars = {'coef': 'C', 'offset': '\\alpha+', 'shape': 'p', 'var': '\\beta'}
property offset
proximal(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.

scale(obj, copy=False)
set_lipschitz(value)
set_offset(value)
set_quadratic(quadratic)

Set the quadratic part of the composite.

classmethod shift(offset, coef=1, quadratic=None, **kws)

Keywords given in kws are passed to cls constructor along with other arguments

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

arg : ndarray

The current parameter values.

mode : str

One of [‘func’, ‘grad’, ‘both’].

check_feasibility : bool

If True, return np.inf when point is not feasible, i.e. when beta is not in the domain.

Returns

If mode is ‘func’ returns just the objective value

at beta, else if mode is ‘grad’ returns the gradient

else returns both.

smoothed(smoothing_quadratic)

Add quadratic smoothing term

solve(quadratic=None, return_optimum=False, **fit_args)

Function

regreg.smooth.acceptable_init_args(cls, proposed_keywords)

Check that the keywords in the dictionary proposed_keywords are arguments to __init__ of class cls

Returns True/False