nca_softmax_error_function.hpp
Go to the documentation of this file.00001
00023 #ifndef __MLPACK_METHODS_NCA_NCA_SOFTMAX_ERROR_FUNCTION_HPP
00024 #define __MLPACK_METHODS_NCA_NCA_SOFTMAX_ERROR_FUNCTION_HPP
00025
00026 #include <mlpack/core.hpp>
00027
00028 namespace mlpack {
00029 namespace nca {
00030
00051 template<typename MetricType = metric::SquaredEuclideanDistance>
00052 class SoftmaxErrorFunction
00053 {
00054 public:
00065 SoftmaxErrorFunction(const arma::mat& dataset,
00066 const arma::Col<size_t>& labels,
00067 MetricType metric = MetricType());
00068
00076 double Evaluate(const arma::mat& covariance);
00077
00088 double Evaluate(const arma::mat& covariance, const size_t i);
00089
00098 void Gradient(const arma::mat& covariance, arma::mat& gradient);
00099
00111 void Gradient(const arma::mat& covariance,
00112 const size_t i,
00113 arma::mat& gradient);
00114
00118 const arma::mat GetInitialPoint() const;
00119
00124 size_t NumFunctions() const { return dataset.n_cols; }
00125
00126 private:
00128 const arma::mat& dataset;
00130 const arma::Col<size_t>& labels;
00131
00133 MetricType metric;
00134
00136 arma::mat lastCoordinates;
00138 arma::mat stretchedDataset;
00140 arma::vec p;
00143 arma::vec denominators;
00144
00146 bool precalculated;
00147
00161 void Precalculate(const arma::mat& coordinates);
00162 };
00163
00164 };
00165 };
00166
00167
00168 #include "nca_softmax_error_function_impl.hpp"
00169
00170 #endif