alphacsc.BatchCDL

class alphacsc.BatchCDL(n_atoms, n_times_atom, reg=0.1, n_iter=60, n_jobs=1, solver_z='lgcd', solver_z_kwargs={}, unbiased_z_hat=False, solver_d='alternate_adaptive', solver_d_kwargs={}, rank1=True, window=False, uv_constraint='separate', lmbd_max='scaled', eps=1e-10, D_init=None, D_init_params={}, verbose=10, random_state=None, sort_atoms=False)

Batch algorithm for convolutional dictionary learning

Parameters
Problem Specs
n_atomsint

The number of atoms to learn.

n_times_atomint

The support of the atom.

loss{ ‘l2’ | ‘dtw’ | ‘whitening’ }

Loss for the data-fit term. Either the norm l2 or the soft-DTW.

loss_paramsdict

Parameters of the loss.

rank1boolean

If set to True, learn rank 1 dictionary atoms.

windowboolean

If set to True, re-parametrizes the atoms with a temporal Tukey window.

uv_constraint{‘joint’ | ‘separate’}

The kind of norm constraint on the atoms:

  • 'joint': the constraint is ||[u, v]||_2 <= 1

  • 'separate': the constraint is ||u||_2 <= 1 and ||v||_2 <= 1

sort_atomsboolean

If True, the atoms are sorted by explained variances.

Global algorithm

Batch algorithm

n_iterint

The number of alternate steps to perform.

epsfloat

Stopping criterion. If the cost descent after a uv and a z update is smaller than eps, return.

regfloat

The regularization parameter.

lmbd_max‘fixed’ | ‘scaled’ | ‘per_atom’ | ‘shared’

If not fixed, adapt the regularization rate as a ratio of lambda_max:

  • 'scaled': the regularization parameter is fixed as a ratio of its maximal value at init i.e. \(lambda\) = reg * lmbd_max(uv_init).

  • 'shared': the regularization parameter is set at each iteration as a ratio of its maximal value for the current dictionary estimate i.e. \(lambda\) = reg * lmbd_max(uv_hat).

  • 'per_atom': the regularization parameter is set per atom and at each iteration as a ratio of its maximal value for this atom i.e. \(lambda[k]\) = reg * lmbd_max(uv_hat[k]).

Z-step parameters
solver_zstr

The solver to use for the z update. Options are {‘l_bfgs’ (default) | ‘lgcd’}.

solver_z_kwargsdict

Additional keyword arguments to pass to update_z_multi.

use_sparse_zboolean

Use sparse lil_matrices to store the activations.

unbiased_z_hatboolean

If set to True, the value of the non-zero coefficients in the returned z_hat are recomputed with reg=0 on the frozen support.

D-step parameters
solver_dstr

The solver to use for the d update. Options are ‘alternate’ | ‘alternate_adaptive’ (default) | ‘joint’

solver_d_kwargsdict

Additional keyword arguments to provide to update_d

D_initstr or array

The initial atoms with shape (n_atoms, n_channels + n_times_atoms) or (n_atoms, n_channels, n_times_atom) or an initialization scheme str in {‘kmeans’ | ‘ssa’ | ‘chunks’ | ‘random’}.

D_init_paramsdict

Dictionnary of parameters for the kmeans init method.

Technical parameters
n_jobsint

The number of parallel jobs.

verboseint

The verbosity level.

callbackfunc

A callback function called at the end of each loop of the coordinate descent.

random_stateint | None

State to seed the random number generator.

raise_on_increaseboolean

Raise an error if the objective function increase.

__init__(n_atoms, n_times_atom, reg=0.1, n_iter=60, n_jobs=1, solver_z='lgcd', solver_z_kwargs={}, unbiased_z_hat=False, solver_d='alternate_adaptive', solver_d_kwargs={}, rank1=True, window=False, uv_constraint='separate', lmbd_max='scaled', eps=1e-10, D_init=None, D_init_params={}, verbose=10, random_state=None, sort_atoms=False)

Methods

__init__(n_atoms, n_times_atom[, reg, ...])

fit(X[, y])

Learn a convolutional dictionary from the set of signals X.

fit_transform(X[, y])

Learn a convolutional dictionary and returns sparse codes.

transform(X)

Returns sparse codes associated to the signals X for the dictionary.

transform_inverse(z_hat)

Reconstruct the signals from the given sparse codes.

Attributes

D_hat_

array: dictionary in full rank mode.

pobj_

list: Objective function value at each step of the alternate minimization.

times_

list: Cumulative time for each iteration of the coordinate descent.

u_hat_

array: spatial map of the dictionary.

uv_hat_

array: dictionary in rank 1 mode.

v_hat_

array: temporal patterns of the dictionary.

z_hat_

array: Sparse code associated to the signals used to fit the model.