Go to the documentation of this file.
13 #ifndef MLPACK_METHODS_SPARSE_CODING_SPARSE_CODING_HPP
14 #define MLPACK_METHODS_SPARSE_CODING_SPARSE_CODING_HPP
25 namespace sparse_coding {
144 template<
typename DictionaryInitializer = DataDependentRandomInitializer>
147 const double lambda1,
148 const double lambda2 = 0,
149 const size_t maxIterations = 0,
150 const double objTolerance = 0.01,
151 const double newtonTolerance = 1e-6,
152 const DictionaryInitializer& initializer =
153 DictionaryInitializer());
172 const double lambda1 = 0,
173 const double lambda2 = 0,
174 const size_t maxIterations = 0,
175 const double objTolerance = 0.01,
176 const double newtonTolerance = 1e-6);
182 template<
typename DictionaryInitializer = DataDependentRandomInitializer>
183 double Train(
const arma::mat& data,
184 const DictionaryInitializer& initializer =
185 DictionaryInitializer());
194 void Encode(
const arma::mat& data, arma::mat& codes);
208 const arma::mat& codes,
209 const arma::uvec& adjacencies);
219 double Objective(
const arma::mat& data,
const arma::mat& codes)
const;
227 size_t Atoms()
const {
return atoms; }
257 template<
typename Archive>
258 void serialize(Archive& ar,
const unsigned int );
265 arma::mat dictionary;
273 size_t maxIterations;
277 double newtonTolerance;
284 #include "sparse_coding_impl.hpp"
size_t MaxIterations() const
Get the maximum number of iterations.
double & Lambda1()
Modify the L1 regularization term.
double Lambda2() const
Access the L2 regularization term.
SparseCoding(const arma::mat &data, const size_t atoms, const double lambda1, const double lambda2=0, const size_t maxIterations=0, const double objTolerance=0.01, const double newtonTolerance=1e-6, const DictionaryInitializer &initializer=DictionaryInitializer())
Set the parameters to SparseCoding.
size_t & MaxIterations()
Modify the maximum number of iterations.
size_t Atoms() const
Access the number of atoms.
double OptimizeDictionary(const arma::mat &data, const arma::mat &codes, const arma::uvec &adjacencies)
Learn dictionary via Newton method based on Lagrange dual.
double & Lambda2()
Modify the L2 regularization term.
double Lambda1() const
Access the L1 regularization term.
arma::mat & Dictionary()
Modify the dictionary.
void serialize(Archive &ar, const unsigned int)
Serialize the sparse coding model.
An implementation of Sparse Coding with Dictionary Learning that achieves sparsity via an l1-norm reg...
void Encode(const arma::mat &data, arma::mat &codes)
Sparse code each point in the given dataset via LARS, using the current dictionary and store the enco...
double NewtonTolerance() const
Get the tolerance for Newton's method (dictionary optimization step).
const arma::mat & Dictionary() const
Access the dictionary.
double & ObjTolerance()
Modify the objective tolerance.
double ObjTolerance() const
Get the objective tolerance.
void ProjectDictionary()
Project each atom of the dictionary back onto the unit ball, if necessary.
double Objective(const arma::mat &data, const arma::mat &codes) const
Compute the objective function.
double & NewtonTolerance()
Modify the tolerance for Newton's method (dictionary optimization step).
size_t & Atoms()
Modify the number of atoms.
double Train(const arma::mat &data, const DictionaryInitializer &initializer=DictionaryInitializer())
Train the sparse coding model on the given dataset.