nca.hpp

Go to the documentation of this file.
00001 
00022 #ifndef __MLPACK_METHODS_NCA_NCA_HPP
00023 #define __MLPACK_METHODS_NCA_NCA_HPP
00024 
00025 #include <mlpack/core.hpp>
00026 #include <mlpack/core/metrics/lmetric.hpp>
00027 #include <mlpack/core/optimizers/sgd/sgd.hpp>
00028 
00029 #include "nca_softmax_error_function.hpp"
00030 
00031 namespace mlpack {
00032 namespace nca  {
00033 
00057 template<typename MetricType = metric::SquaredEuclideanDistance,
00058          template<typename> class OptimizerType = optimization::SGD>
00059 class NCA
00060 {
00061  public:
00075   NCA(const arma::mat& dataset,
00076       const arma::Col<size_t>& labels,
00077       MetricType metric = MetricType());
00078 
00088   void LearnDistance(arma::mat& outputMatrix);
00089 
00091   const arma::mat& Dataset() const { return dataset; }
00093   const arma::Col<size_t>& Labels() const { return labels; }
00094 
00096   const OptimizerType<SoftmaxErrorFunction<MetricType> >& Optimizer() const
00097   { return optimizer; }
00098   OptimizerType<SoftmaxErrorFunction<MetricType> >& Optimizer()
00099   { return optimizer; }
00100 
00101  private:
00103   const arma::mat& dataset;
00105   const arma::Col<size_t>& labels;
00106 
00108   MetricType metric;
00109 
00111   SoftmaxErrorFunction<MetricType> errorFunction;
00112 
00114   OptimizerType<SoftmaxErrorFunction<MetricType> > optimizer;
00115 };
00116 
00117 }; // namespace nca
00118 }; // namespace mlpack
00119 
00120 // Include the implementation.
00121 #include "nca_impl.hpp"
00122 
00123 #endif

Generated on 29 Sep 2016 for MLPACK by  doxygen 1.6.1