sporco.dictlrn.dictlrn¶
Dictionary learning based on ADMM sparse coding and dictionary updates
Classes
|
Configuration object for general dictionary learning algorithm iteration statistics. |
|
Metaclass for DictLearn class that handles intialisation of the object initialisation timer and stopping this timer at the end of initialisation. |
|
General dictionary learning class that supports alternation between user-specified sparse coding and dictionary update steps, each of which is based on an ADMM algorithm. |
Class Descriptions¶
- class sporco.dictlrn.dictlrn.IterStatsConfig(isfld, isxmap, isdmap, evlmap, hdrtxt, hdrmap, fmtmap=None)[source]¶
Bases:
object
Configuration object for general dictionary learning algorithm iteration statistics.
- Parameters
- isfldlist
List of field names for iteration statistics namedtuple
- isxmapdict
Dictionary mapping iteration statistics namedtuple field names to field names in corresponding X step object iteration statistics namedtuple
- isdmapdict
Dictionary mapping iteration statistics namedtuple field names to field names in corresponding D step object iteration statistics namedtuple
- evlmapdict
Dictionary mapping iteration statistics namedtuple field names to labels in the dict returned by
DictLearn.evaluate
- hdrtxtlist
List of column header titles for verbose iteration statistics display
- hdrmapdict
Dictionary mapping column header titles to IterationStats entries
- fmtmapdict, optional (default None)
A dict providing a mapping from field header strings to print format strings, providing a mechanism for fields with print formats that depart from the standard format
- fwiter = 4¶
Field width for iteration count display column
- fpothr = 2¶
Field precision for other display columns
- iterstats(j, t, isx, isd, evl)[source]¶
Construct IterationStats namedtuple from X step and D step IterationStats namedtuples.
- Parameters
- jint
Iteration number
- tfloat
Iteration time
- isxnamedtuple
IterationStats namedtuple from X step object
- isdnamedtuple
IterationStats namedtuple from D step object
- evldict
Dict associating result labels with values computed by
DictLearn.evaluate
- class sporco.dictlrn.dictlrn._DictLearn_Meta(*args)[source]¶
Bases:
type
Metaclass for DictLearn class that handles intialisation of the object initialisation timer and stopping this timer at the end of initialisation.
- class sporco.dictlrn.dictlrn.DictLearn(*args, **kwargs)[source]¶
Bases:
object
General dictionary learning class that supports alternation between user-specified sparse coding and dictionary update steps, each of which is based on an ADMM algorithm.
- Parameters
- xstepbpdn (or similar interface) object
Object handling X update step
- dstepcmod (or similar interface) object
Object handling D update step
- opt
DictLearn.Options
objectAlgorithm options
- isc
IterStatsConfig
objectIteration statistics and header display configuration
- class Options(opt=None)[source]¶
Bases:
sporco.cdict.ConstrainedDict
General 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.
MaxMainIter
: Maximum main iterations.
Callback
: Callback function to be called at the end of every iteration.
- Parameters
- optdict or None, optional (default None)
DictLearn algorithm options
- solve()[source]¶
Start (or re-start) optimisation. This method implements the framework for the alternation between X and D updates in a dictionary learning algorithm. There is sufficient flexibility in specifying the two updates that it calls that it is usually not necessary to override this method in derived clases.
If option
Verbose
isTrue
, the progress of the optimisation is displayed at every iteration. At termination of this method, attributeitstat
is a list of tuples representing statistics of each iteration.Attribute
timer
is an instance ofutil.Timer
that provides the following labelled timers:
init
: Time taken for object initialisation by__init__
solve
: Total time taken by call(s) tosolve
solve_wo_func
: Total time taken by call(s) tosolve
, excluding time taken to compute functional value and related iteration statistics
solve_wo_rsdl
: Total time taken by call(s) tosolve
, excluding time taken to compute functional value and related iteration statistics as well as time take to compute residuals and implementedAutoRho
mechanism