sporco.dictlrn.onlinecdl

Online dictionary learning based on CBPDN sparse coding

Classes

OnlineConvBPDNDictLearn(D0[, lmbda, opt, …]) Stochastic gradient descent (SGD) based online convolutional dictionary learning, as proposed in [21].
OnlineConvBPDNMaskDictLearn(D0[, lmbda, …]) Stochastic gradient descent (SGD) based online convolutional dictionary learning with a spatial mask, as proposed in [21].

Class Descriptions

class sporco.dictlrn.onlinecdl.OnlineConvBPDNDictLearn(D0, lmbda=None, opt=None, dimK=None, dimN=2)[source]

Bases: sporco.common.IterativeSolver

Stochastic gradient descent (SGD) based online convolutional dictionary learning, as proposed in [21].


Inheritance diagram of OnlineConvBPDNDictLearn


Parameters:
D0 : array_like

Initial dictionary array

lmbda : float

Regularisation parameter

opt : OnlineConvBPDNDictLearn.Options object

Algorithm options

dimK : 0, 1, or None, optional (default None)

Number of signal dimensions in signal array passed to solve. If there will only be a single input signal (e.g. if S is a 2D array representing a single image) dimK must be set to 0.

dimN : int, optional (default 2)

Number of spatial/temporal dimensions

class Options(opt=None)[source]

Bases: sporco.dictlrn.dictlrn.Options

Online CBPDN dictionary learning algorithm options.

Options:

Verbose : Flag determining whether iteration status is displayed.

StatusHeader : Flag determining whether status header and separator are displayed.

IterTimer : Label of the timer to use for iteration times.

DictSize : Dictionary size vector.

DataType : Specify data type for solution variables, e.g. np.float32.

ZeroMean : Flag indicating whether the solution dictionary \(\{\mathbf{d}_m\}\) should have zero-mean components.

eta_a, eta_b : Constants \(a\) and \(b\) used in setting the SGD step size, \(\eta\), which is set to \(a / (b + i)\) where \(i\) is the iteration index. See Sec. 3 (pg. 9) of [21].

CUDA_CBPDN : Flag indicating whether to use CUDA solver for CBPDN problem (see sporco.cuda package)

CBPDN : Options admm.cbpdn.ConvBPDN.Options.

Parameters:
opt : dict or None, optional (default None)

OnlineConvBPDNDictLearn algorithm options

fwiter = 4

Field width for iteration count display column

fpothr = 2

Field precision for other display columns

itstat_fields_objfn = ('ObjFun', 'DFid', 'RegL1')

Fields in IterationStats associated with the objective function

itstat_fields_alg = ('PrimalRsdl', 'DualRsdl', 'Rho', 'Cnstr', 'DeltaD', 'Eta')

Fields in IterationStats associated with the specific solver algorithm

itstat_fields_extra = ()

Non-standard fields in IterationStats; see itstat_extra

solve(S, dimK=None)[source]

Compute sparse coding and dictionary update for training data S.

init_vars(S, dimK)[source]

Initalise variables required for sparse coding and dictionary update for training data S.

xstep(S, lmbda, dimK)[source]

Solve CSC problem for training data S.

setcoef(Z)[source]

Set coefficient array.

dstep()[source]

Compute dictionary update for training data of preceding xstep.

manage_itstat()[source]

Compute, record, and display iteration statistics.

getdict()[source]

Get final dictionary.

itstat_extra()[source]

Non-standard entries for the iteration stats record tuple.

classmethod hdrtxt()[source]

Construct tuple of status display column title.

classmethod hdrval()[source]

Construct dictionary mapping display column title to IterationStats entries.

iteration_stats()[source]

Construct iteration stats record tuple.

getitstat()[source]

Get iteration stats as named tuple of arrays instead of array of named tuples.

display_config()[source]

Set up status display if option selected. NB: this method assumes that the first entry is the iteration count and the last is the rho value.

display_start()[source]

Start status display if option selected.

display_status(fmtstr, itst)[source]

Display current iteration status as selection of fields from iteration stats tuple.

display_end()[source]

Terminate status display if option selected.

class sporco.dictlrn.onlinecdl.OnlineConvBPDNMaskDictLearn(D0, lmbda=None, opt=None, dimK=None, dimN=2)[source]

Bases: sporco.dictlrn.onlinecdl.OnlineConvBPDNDictLearn

Stochastic gradient descent (SGD) based online convolutional dictionary learning with a spatial mask, as proposed in [21].


Inheritance diagram of OnlineConvBPDNMaskDictLearn


Parameters:
D0 : array_like

Initial dictionary array

lmbda : float

Regularisation parameter

opt : OnlineConvBPDNDictLearn.Options object

Algorithm options

dimK : 0, 1, or None, optional (default None)

Number of signal dimensions in signal array passed to solve. If there will only be a single input signal (e.g. if S is a 2D array representing a single image) dimK must be set to 0.

dimN : int, optional (default 2)

Number of spatial/temporal dimensions

class Options(opt=None)[source]

Bases: sporco.dictlrn.onlinecdl.Options

Online masked CBPDN dictionary learning algorithm options.

Options are the same as those of OnlineConvBPDNDictLearn.Options, except for

Parameters:
opt : dict or None, optional (default None)

OnlineConvBPDNMaskDictLearn algorithm options

solve(S, W=None, dimK=None)[source]

Compute sparse coding and dictionary update for training data S.

xstep(S, W, lmbda, dimK)[source]

Solve CSC problem for training data S.

dstep(W)[source]

Compute dictionary update for training data of preceding xstep.