problems.separable¶
Module: problems.separable
¶
Inheritance diagram for regreg.problems.separable
:
This module implements the notion of a separable support function / constraint regularizer or penalty.
The penalty is specified by a primal shape, a sequence of atoms and a sequence of slicing objects.
Classes¶
separable
¶
-
class
regreg.problems.separable.
separable
(shape, atoms, groups, test_for_overlap=False, initial=None)¶ Bases:
regreg.atoms.atom
-
__init__
(shape, atoms, groups, test_for_overlap=False, initial=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
apply_offset
(x)¶ If self.offset is not None, return x-self.offset, else return x.
-
property
conjugate
¶ The conjugate of an atom.
-
constraint
(x, bound=None)¶
-
property
dual
¶
-
get_conjugate
()¶
-
get_dual
()¶
-
get_offset
()¶
-
get_quadratic
()¶ Get the quadratic part of the composite.
-
latexify
(var=None, idx='')¶
-
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)¶
-
objective
(x, check_feasibility=False)¶
-
objective_template
= 'f(%(var)s)'¶
-
objective_vars
= {'dualklass': 'dualnorm', 'klass': 'norm', 'offset': '\\alpha', 'shape': 'p', 'var': '\\beta'}¶
-
property
offset
¶
-
proximal
(proxq, prox_control=None)¶
-
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.
-
property
selectors
¶
-
seminorm
(x, lagrange=None, check_feasibility=False)¶
-
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¶
-
separable_problem
¶
-
class
regreg.problems.separable.
separable_problem
(smooth_atom, shape, atoms, groups, test_for_overlap=False)¶ Bases:
regreg.problems.simple.simple_problem
-
__init__
(smooth_atom, shape, atoms, groups, test_for_overlap=False)¶ Initialize self. See help(type(self)) for accurate signature.
-
apply_offset
(x)¶ If self.offset is not None, return x-self.offset, else return x.
-
static
fromatom
(separable_atom, smooth_f)¶
-
get_offset
()¶
-
get_quadratic
()¶ Get the quadratic part of the composite.
-
latexify
(var=None)¶
-
static
nonsmooth
(proximal_atom)¶ A problem with no nonsmooth part except possibly the quadratic of smooth_atom.
The proximal function is (almost) a nullop.
-
nonsmooth_objective
(x, check_feasibility=False)¶
-
objective
(x, check_feasibility=False)¶
-
objective_template
= 'f(%(var)s)'¶
-
objective_vars
= {'offset': '\\alpha', 'shape': 'p', 'var': '\\beta'}¶
-
property
offset
¶
-
proximal
(proxq)¶
-
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.
-
property
selectors
¶
-
set_offset
(value)¶
-
set_quadratic
(quadratic)¶ Set the quadratic part of the composite.
-
static
singleton
(atom, smooth_f)¶
-
static
smooth
(smooth_atom)¶ A problem with no nonsmooth part except possibly the quadratic of smooth_atom.
The proximal function is (almost) a nullop.
-
smooth_objective
(x, mode='both', check_feasibility=False)¶ This class explicitly assumes that the proximal_atom has 0 for smooth_objective.
-
smoothed
(smoothing_quadratic)¶ Add quadratic smoothing term
-
solve
(quadratic=None, return_optimum=False, **fit_args)¶
-
Function¶
-
regreg.problems.separable.
has_overlap
(shape, groups)¶ Determine whether the groups, viewed as slices of an array with given shape, have any overlap.
- Parameters
shape : tuple
A tuple of integers representing a shape for an array.
groups : sequence
A sequence of objects that can be viewed as slices of an ndarray with shape==shape.
- Returns
res : boolean
True if the slices overlap, else False.
Examples
>>> from regreg.problems.separable import has_overlap >>> has_overlap((4,5), [slice(2,3), slice(4,5)]) False >>> has_overlap((4,5), [slice(2,3), [Ellipsis, slice(4,5)]]) True