sporco.dictlrn.cbpdndlmd¶
Dictionary learning based on CBPDN sparse coding with a spatial mask in the data fidelity term
Functions
|
Get a ConvBPDNMask class from a label string. |
|
Get defaults dict for the ConvBPDNMask class specified by the |
|
A wrapper function that dynamically defines a class derived from the Options class associated with one of the implementations of the Convolutional BPDN problem, and returns an object instantiated with the provided parameters. |
|
A wrapper function that dynamically defines a class derived from one of the implementations of the Convolutional Constrained MOD problems, and returns an object instantiated with the provided parameters. |
|
Get a ConvCnstrMODMask class from a label string. |
|
Get defaults dict for the ConvCnstrMODMask class specified by the |
|
A wrapper function that dynamically defines a class derived from the Options class associated with one of the implementations of the Convolutional Constrained MOD problem, and returns an object instantiated with the provided parameters. |
|
A wrapper function that dynamically defines a class derived from one of the implementations of the Convolutional Constrained MOD problems, and returns an object instantiated with the provided parameters. |
Classes
|
Dictionary learning by alternating between sparse coding and dictionary update stages. |
Function Descriptions¶
- sporco.dictlrn.cbpdndlmd.cbpdnmsk_class_label_lookup(label)[source]¶
Get a ConvBPDNMask class from a label string.
- sporco.dictlrn.cbpdndlmd.ConvBPDNMaskOptionsDefaults(method='admm')[source]¶
Get defaults dict for the ConvBPDNMask class specified by the
method
parameter.
- sporco.dictlrn.cbpdndlmd.ConvBPDNMaskOptions(opt=None, method='admm')[source]¶
A wrapper function that dynamically defines a class derived from the Options class associated with one of the implementations of the Convolutional BPDN problem, and returns an object instantiated with the provided parameters. The wrapper is designed to allow the appropriate object to be created by calling this function using the same syntax as would be used if it were a class. The specific implementation is selected by use of an additional keyword argument ‘method’. Valid values are as specified in the documentation for
ConvBPDN
.
- sporco.dictlrn.cbpdndlmd.ConvBPDNMask(*args, **kwargs)[source]¶
A wrapper function that dynamically defines a class derived from one of the implementations of the Convolutional Constrained MOD problems, and returns an object instantiated with the provided parameters. The wrapper is designed to allow the appropriate object to be created by calling this function using the same syntax as would be used if it were a class. The specific implementation is selected by use of an additional keyword argument ‘method’. Valid values are:
'admm'
: Use the implementation defined inadmm.cbpdn.ConvBPDNMaskDcpl
.
'pgm'
: Use the implementation defined inpgm.cbpdn.ConvBPDNMask
.The default value is
'admm'
.
- sporco.dictlrn.cbpdndlmd.ccmodmsk_class_label_lookup(label)[source]¶
Get a ConvCnstrMODMask class from a label string.
- sporco.dictlrn.cbpdndlmd.ConvCnstrMODMaskOptionsDefaults(method='pgm')[source]¶
Get defaults dict for the ConvCnstrMODMask class specified by the
method
parameter.
- sporco.dictlrn.cbpdndlmd.ConvCnstrMODMaskOptions(opt=None, method='pgm')[source]¶
A wrapper function that dynamically defines a class derived from the Options class associated with one of the implementations of the Convolutional Constrained MOD problem, and returns an object instantiated with the provided parameters. The wrapper is designed to allow the appropriate object to be created by calling this function using the same syntax as would be used if it were a class. The specific implementation is selected by use of an additional keyword argument ‘method’. Valid values are as specified in the documentation for
ConvCnstrMODMask
.
- sporco.dictlrn.cbpdndlmd.ConvCnstrMODMask(*args, **kwargs)[source]¶
A wrapper function that dynamically defines a class derived from one of the implementations of the Convolutional Constrained MOD problems, and returns an object instantiated with the provided parameters. The wrapper is designed to allow the appropriate object to be created by calling this function using the same syntax as would be used if it were a class. The specific implementation is selected by use of an additional keyword argument ‘method’. Valid values are:
'ism'
: Use the implementation defined inConvCnstrMODMaskDcpl_IterSM
. This method works well for a small number of training images, but is very slow for larger training sets.
'cg'
: Use the implementation defined inConvCnstrMODMaskDcpl_CG
. This method is slower than'ism'
for small training sets, but has better run time scaling as the training set grows.
'cns'
: Use the implementation defined inConvCnstrMODMaskDcpl_Consensus
. This method is a good choice for large training sets.
'pgm'
: Use the implementation defined inpgm.ccmod.ConvCnstrMODMask
. This method is the best choice for large training sets.The default value is
'pgm'
.
Class Descriptions¶
- class sporco.dictlrn.cbpdndlmd.ConvBPDNMaskDictLearn(*args, **kwargs)[source]¶
Bases:
sporco.dictlrn.dictlrn.DictLearn
Dictionary learning by alternating between sparse coding and dictionary update stages.
The sparse coding is performed using
admm.cbpdn.ConvBPDNMaskDcpl
(see [28]) orpgm.cbpdn.ConvBPDNMask
(see [13] and [53]), and the dictionary update is computed usingpgm.ccmod.ConvCnstrMODMask
(see [26]) or one of the solver classes inadmm.ccmodmd
(see [53] and [26]). The coupling between sparse coding and dictionary update stages is as in [24].Solve the optimisation problem
\[\mathrm{argmin}_{\mathbf{d}, \mathbf{x}} \; (1/2) \sum_k \left \| W (\sum_m \mathbf{d}_m * \mathbf{x}_{k,m} - \mathbf{s}_k ) \right \|_2^2 + \lambda \sum_k \sum_m \| \mathbf{x}_{k,m} \|_1 \quad \text{such that} \quad \mathbf{d}_m \in C \;\; \forall m \;,\]where \(C\) is the feasible set consisting of filters with unit norm and constrained support, via interleaved alternation between the ADMM steps of the
ConvBPDNMaskDcpl
andConvCnstrMODMaskDcpl
problems. The multi-channel variants [51] supported byConvBPDNMaskDcpl
andConvCnstrMODMaskDcpl
are also supported.After termination of the
solve
method, attributeitstat
is a list of tuples representing statistics of each iteration. The fields of the named tupleIterationStats
are:
Iter
: Iteration number
ObjFun
: Objective function value
DFid
: Value of data fidelity term \((1/2) \sum_k \| W (\sum_m \mathbf{d}_m * \mathbf{x}_{k,m} - \mathbf{s}_k) \|_2^2\)
RegL1
: Value of regularisation term \(\sum_k \sum_m \| \mathbf{x}_{k,m} \|_1\)
Cnstr
: Constraint violation measureIf the ADMM solver is selected for sparse coding:
XPrRsdl
: Norm of X primal residual
XDlRsdl
: Norm of X dual residual
XRho
: X penalty parameterIf the PGM solver is selected for sparse coding:
X_F_Btrack
: Value of objective function for CSC problem
X_Q_Btrack
: Value of quadratic approximation for CSC problem
X_ItBt
: Number of iterations in backtracking for CSC problem
X_L
: Inverse of gradient step parameter for CSC problemIf an ADMM solver is selected for the dictionary update:
DPrRsdl
: Norm of D primal residual
DDlRsdl
: Norm of D dual residual
DRho
: D penalty parameterIf the PGM solver is selected for the dictionary update:
D_F_Btrack
: Value of objective function for CDU problem
D_Q_Btrack
: Value of wuadratic approximation for CDU problem
D_ItBt
: Number of iterations in backtracking for CDU problem
D_L
: Inverse of gradient step parameter for CDU problem
Time
: Cumulative run timeCall graph
- Parameters
- D0array_like
Initial dictionary array
- Sarray_like
Signal array
- lmbdafloat
Regularisation parameter
- Warray_like
Mask array. The array shape must be such that the array is compatible for multiplication with the internal shape of input array S (see
cnvrep.CDU_ConvRepIndexing
for a discussion of the distinction between external and internal data layouts) after reshaping to the shape determined bycnvrep.mskWshape
.- opt
ConvBPDNMaskDictLearn.Options
objectAlgorithm options
- xmethodstring, optional (default ‘admm’)
String selecting sparse coding solver. Valid values are documented in function
ConvBPDNMask
.- dmethodstring, optional (default ‘pgm’)
String selecting dictionary update solver. Valid values are documented in function
ConvCnstrMODMask
.- dimKint, optional (default 1)
Number of signal dimensions. If there is only a single input signal (e.g. if S is a 2D array representing a single image) dimK must be set to 0.
- dimNint, optional (default 2)
Number of spatial/temporal dimensions
- class Options(opt=None, xmethod=None, dmethod=None)[source]¶
Bases:
sporco.dictlrn.dictlrn.DictLearn.Options
CBPDN dictionary learning algorithm options.
Options include all of those defined in
dictlrn.DictLearn.Options
, together with additional options:
AccurateDFid
: Flag determining whether data fidelity term is estimated from the value computed in the X update (False
) or is computed after every outer iteration over an X update and a D update (True
), which is slower but more accurate.
DictSize
: Dictionary size vector.
CBPDN
: An options class appropriate for the selected sparse coding solver class
CCMOD
: An options class appropriate for the selected dictionary update solver classValid values for parameters
xmethod
anddmethod
are documented in functionsConvBPDNMask
andConvCnstrMODMask
respectively.
- getdict(crop=True)[source]¶
Get final dictionary. If
crop
isTrue
, applycnvrep.bcrop
to returned array.
- solve()¶
Call graph