MLPACK  1.0.8
nca.hpp
Go to the documentation of this file.
1 
22 #ifndef __MLPACK_METHODS_NCA_NCA_HPP
23 #define __MLPACK_METHODS_NCA_NCA_HPP
24 
25 #include <mlpack/core.hpp>
28 
30 
31 namespace mlpack {
32 namespace nca {
33 
57 template<typename MetricType = metric::SquaredEuclideanDistance,
58  template<typename> class OptimizerType = optimization::SGD>
59 class NCA
60 {
61  public:
75  NCA(const arma::mat& dataset,
76  const arma::Col<size_t>& labels,
77  MetricType metric = MetricType());
78 
88  void LearnDistance(arma::mat& outputMatrix);
89 
91  const arma::mat& Dataset() const { return dataset; }
93  const arma::Col<size_t>& Labels() const { return labels; }
94 
96  const OptimizerType<SoftmaxErrorFunction<MetricType> >& Optimizer() const
97  { return optimizer; }
98  OptimizerType<SoftmaxErrorFunction<MetricType> >& Optimizer()
99  { return optimizer; }
100 
101  private:
103  const arma::mat& dataset;
105  const arma::Col<size_t>& labels;
106 
108  MetricType metric;
109 
112 
114  OptimizerType<SoftmaxErrorFunction<MetricType> > optimizer;
115 };
116 
117 }; // namespace nca
118 }; // namespace mlpack
119 
120 // Include the implementation.
121 #include "nca_impl.hpp"
122 
123 #endif