mlpack
|
#include <mlpack/prereqs.hpp>
#include <mlpack/core/util/io.hpp>
#include <mlpack/core/util/mlpack_main.hpp>
#include "sparse_coding.hpp"
Functions | |
BINDING_NAME ("Sparse Coding") | |
BINDING_SHORT_DESC ("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; a dictionary can be reused for future sparse coding of new " "points.") | |
BINDING_LONG_DESC ("An implementation of Sparse Coding with Dictionary Learning, which " "achieves sparsity via an l1-norm regularizer on the codes (LASSO) or an " "(l1+l2)-norm regularizer on the codes (the Elastic Net). Given a dense " "data matrix X with d dimensions and n points, sparse coding seeks to find " "a dense dictionary matrix D with k atoms in d dimensions, and a sparse " "coding matrix Z with n points in k dimensions." "\" "The original data matrix X can then be reconstructed as Z * D. Therefore," " this program finds a representation of each point in X as a sparse linear" " combination of atoms in the dictionary D." "\" "The sparse coding is found with an algorithm which alternates between a " "dictionary step, which updates the dictionary D, and a sparse coding step," " which updates the sparse coding matrix." "\" "Once a dictionary D is found, the sparse coding model may be used to " "encode other matrices, and saved for future usage." "\" "To run this program, either an input matrix or an already-saved sparse " "coding model must be specified. An input matrix may be specified with the" " "+PRINT_PARAM_STRING("training")+" option, along with the number of " "atoms in the dictionary (specified with the "+PRINT_PARAM_STRING("atoms")+" parameter). It is also possible to specify" " an initial dictionary for the optimization, with the "+PRINT_PARAM_STRING("initial_dictionary")+" parameter. An input model may" " be specified with the "+PRINT_PARAM_STRING("input_model")+" parameter.") | |
BINDING_EXAMPLE ("As an example, to build a sparse coding model on the dataset "+PRINT_DATASET("data")+" using 200 atoms and an l1-regularization " "parameter of 0.1, saving the model into "+PRINT_MODEL("model")+", use " "\"+PRINT_CALL("sparse_coding", "training", "data", "atoms", 200, "lambda1", 0.1, "output_model", "model")+"\" "Then, this model could be used to encode a new matrix, "+PRINT_DATASET("otherdata")+", and save the output codes to "+PRINT_DATASET("codes")+": " "\"+PRINT_CALL("sparse_coding", "input_model", "model", "test", "otherdata", "codes", "codes")) | |
BINDING_SEE_ALSO ("@local_coordinate_coding", "#local_coordinate_coding") | |
BINDING_SEE_ALSO ("Sparse dictionary learning on Wikipedia", "https://en.wikipedia.org/wiki/Sparse_dictionary_learning") | |
BINDING_SEE_ALSO ("Efficient sparse coding algorithms (pdf)", "http://papers.nips.cc/paper/2979-efficient-sparse-coding-" "algorithms.pdf") | |
BINDING_SEE_ALSO ("Regularization and variable selection via the elastic net", "http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.124.4696&" "rep=rep1&type=pdf") | |
BINDING_SEE_ALSO ("mlpack::sparse_coding::SparseCoding C++ class documentation", "@doxygen/classmlpack_1_1sparse__coding_1_1SparseCoding.html") | |
PARAM_MATRIX_IN ("training", "Matrix of training data (X).", "t") | |
PARAM_INT_IN ("atoms", "Number of atoms in the dictionary.", "k", 15) | |
PARAM_DOUBLE_IN ("lambda1", "Sparse coding l1-norm regularization parameter.", "l", 0) | |
PARAM_DOUBLE_IN ("lambda2", "Sparse coding l2-norm regularization parameter.", "L", 0) | |
PARAM_INT_IN ("max_iterations", "Maximum number of iterations for sparse coding " "(0 indicates no limit).", "n", 0) | |
PARAM_MATRIX_IN ("initial_dictionary", "Optional initial dictionary matrix.", "i") | |
PARAM_FLAG ("normalize", "If set, the input data matrix will be normalized " "before coding.", "N") | |
PARAM_INT_IN ("seed", "Random seed. If 0, 'std::time(NULL)' is used.", "s", 0) | |
PARAM_DOUBLE_IN ("objective_tolerance", "Tolerance for convergence of the " "objective function.", "o", 0.01) | |
PARAM_DOUBLE_IN ("newton_tolerance", "Tolerance for convergence of Newton " "method.", "w", 1e-6) | |
PARAM_MODEL_IN (SparseCoding, "input_model", "File containing input sparse " "coding model.", "m") | |
PARAM_MODEL_OUT (SparseCoding, "output_model", "File to save trained sparse " "coding model to.", "M") | |
PARAM_MATRIX_OUT ("dictionary", "Matrix to save the output dictionary to.", "d") | |
PARAM_MATRIX_OUT ("codes", "Matrix to save the output sparse codes of the test " "matrix (--test_file) to.", "c") | |
PARAM_MATRIX_IN ("test", "Optional matrix to be encoded by trained model.", "T") | |
Executable for Sparse Coding.
mlpack is free software; you may redistribute it and/or modify it under the terms of the 3-clause BSD license. You should have received a copy of the 3-clause BSD license along with mlpack. If not, see http://www.opensource.org/licenses/BSD-3-Clause for more information.