sparse_coding.hpp

Go to the documentation of this file.
00001 
00023 #ifndef __MLPACK_METHODS_SPARSE_CODING_SPARSE_CODING_HPP
00024 #define __MLPACK_METHODS_SPARSE_CODING_SPARSE_CODING_HPP
00025 
00026 #include <mlpack/core.hpp>
00027 #include <mlpack/methods/lars/lars.hpp>
00028 
00029 // Include our three simple dictionary initializers.
00030 #include "nothing_initializer.hpp"
00031 #include "data_dependent_random_initializer.hpp"
00032 #include "random_initializer.hpp"
00033 
00034 namespace mlpack {
00035 namespace sparse_coding {
00036 
00118 template<typename DictionaryInitializer = DataDependentRandomInitializer>
00119 class SparseCoding
00120 {
00121  public:
00130   SparseCoding(const arma::mat& data,
00131                const size_t atoms,
00132                const double lambda1,
00133                const double lambda2 = 0);
00134 
00146   void Encode(const size_t maxIterations = 0,
00147               const double objTolerance = 0.01,
00148               const double newtonTolerance = 1e-6);
00149 
00153   void OptimizeCode();
00154 
00165   double OptimizeDictionary(const arma::uvec& adjacencies,
00166                             const double newtonTolerance = 1e-6);
00167 
00171   void ProjectDictionary();
00172 
00176   double Objective() const;
00177 
00179   const arma::mat& Data() const { return data; }
00180 
00182   const arma::mat& Dictionary() const { return dictionary; }
00184   arma::mat& Dictionary() { return dictionary; }
00185 
00187   const arma::mat& Codes() const { return codes; }
00189   arma::mat& Codes() { return codes; }
00190 
00191  private:
00193   size_t atoms;
00194 
00196   const arma::mat& data;
00197 
00199   arma::mat dictionary;
00200 
00202   arma::mat codes;
00203 
00205   double lambda1;
00206 
00208   double lambda2;
00209 };
00210 
00211 }; // namespace sparse_coding
00212 }; // namespace mlpack
00213 
00214 // Include implementation.
00215 #include "sparse_coding_impl.hpp"
00216 
00217 #endif

Generated on 29 Sep 2016 for MLPACK by  doxygen 1.6.1