MLPACK  1.0.4
lcc.hpp
Go to the documentation of this file.
00001 
00023 #ifndef __MLPACK_METHODS_LOCAL_COORDINATE_CODING_LCC_HPP
00024 #define __MLPACK_METHODS_LOCAL_COORDINATE_CODING_LCC_HPP
00025 
00026 #include <mlpack/core.hpp>
00027 #include <mlpack/methods/lars/lars.hpp>
00028 
00029 // Include three simple dictionary initializers from sparse coding.
00030 #include "../sparse_coding/nothing_initializer.hpp"
00031 #include "../sparse_coding/data_dependent_random_initializer.hpp"
00032 #include "../sparse_coding/random_initializer.hpp"
00033 
00034 namespace mlpack {
00035 namespace lcc {
00036 
00089 template<typename DictionaryInitializer =
00090     sparse_coding::DataDependentRandomInitializer>
00091 class LocalCoordinateCoding
00092 {
00093  public:
00101   LocalCoordinateCoding(const arma::mat& data,
00102                         const size_t atoms,
00103                         const double lambda);
00104 
00113   void Encode(const size_t maxIterations = 0,
00114               const double objTolerance = 0.01);
00115 
00119   void OptimizeCode();
00120 
00128   void OptimizeDictionary(arma::uvec adjacencies);
00129 
00133   double Objective(arma::uvec adjacencies) const;
00134 
00136   const arma::mat& Data() const { return data; }
00137 
00139   const arma::mat& Dictionary() const { return dictionary; }
00141   arma::mat& Dictionary() { return dictionary; }
00142 
00144   const arma::mat& Codes() const { return codes; }
00146   arma::mat& Codes() { return codes; }
00147 
00148  private:
00150   size_t atoms;
00151 
00153   const arma::mat& data;
00154 
00156   arma::mat dictionary;
00157 
00159   arma::mat codes;
00160 
00162   double lambda;
00163 };
00164 
00165 }; // namespace lcc
00166 }; // namespace mlpack
00167 
00168 // Include implementation.
00169 #include "lcc_impl.hpp"
00170 
00171 #endif