Sparse Coding
An implementation of Sparse Coding with Dictionary Learning. Given a dataset, this will decompose the dataset into a sparse combination of a few dictionary elements, where the dictionary is learned during computation.
Available Predicates
initModelWithTrain/9
Initializes sparse_coding model and trains it.
%% part of the predicate definition
initModelWithTrain( +pointer(float_array), +integer, +integer,
+integer, +float32, +float32, +integer, +float32, +float32).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | Matrix of training data. | - |
atoms | +integer | Number of atoms in the dictionary. | 15 |
lambda1 | +float | Sparse coding l1-norm regularization parameter. | 0.0 |
lambda2 | +float | Sparse coding l2-norm regularization parameter. | 0.0 |
maxIterations | +integer | Maximum number of iterations for sparse coding (0 indicates no limit). | 0 |
objTolerance | +float | Tolerance for convergence of the objective function. | 0.01 |
newtonTolerance | +float | Tolerance for convergence of Newton method. | 1e-6 |
initModelNoTrain/6
Initializes sparse_coding model but will not train the model, and a subsequent call to Train will be required before the model can encode points with Encode.
%% part of the predicate definition
initModelNoTrain(+integer, +float32, +float32, +integer, +float32, +float32).
Parameters
Name | Type | Description | Default |
---|---|---|---|
atoms | +integer | Number of atoms in the dictionary. | 15 |
lambda1 | +float | Sparse coding l1-norm regularization parameter. | 0.0 |
lambda2 | +float | Sparse coding l2-norm regularization parameter. | 0.0 |
maxIterations | +integer | Maximum number of iterations for sparse coding (0 indicates no limit). | 0 |
objTolerance | +float | Tolerance for convergence of the objective function. | 0.01 |
newtonTolerance | +float | Tolerance for convergence of Newton method. | 1e-6 |
encode/6
Sparse code each point in the given dataset via LARS, using the current dictionary and store the encoded data in the codes matrix.
%% part of the predicate definition
encode( +pointer(float_array), +integer, +integer,
-pointer(float_array), -integer, -integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | Input data matrix to be encoded. | - |
codes | -matrix | Output codes matrix. | - |
train/4
Train the sparse coding model on the given dataset.
%% part of the predicate definition
train( +pointer(float_array), +integer, +integer,
[-float32]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | Matrix of training data. | - |
objValue | -float | The final objective value. | - |
Connected Links/Resources
If you want a more detailed explanation, then go to the python documentation. There is most of the time a good explanation on how the methods work and what the parameters do.
added some of the links from the python documentation