12 #ifndef MLPACK_METHODS_LMNN_LMNN_HPP 13 #define MLPACK_METHODS_LMNN_LMNN_HPP 17 #include <ensmallen.hpp> 54 typename OptimizerType = ens::AMSGrad>
68 LMNN(
const arma::mat& dataset,
69 const arma::Row<size_t>& labels,
71 const MetricType metric = MetricType());
85 template<
typename... CallbackTypes>
86 void LearnDistance(arma::mat& outputMatrix, CallbackTypes&&... callbacks);
90 const arma::mat&
Dataset()
const {
return dataset; }
93 const arma::Row<size_t>&
Labels()
const {
return labels; }
101 const size_t&
Range()
const {
return range; }
106 const size_t&
K()
const {
return k; }
108 size_t K() {
return k; }
111 const OptimizerType&
Optimizer()
const {
return optimizer; }
116 const arma::mat& dataset;
119 const arma::Row<size_t>& labels;
125 double regularization;
134 OptimizerType optimizer;
141 #include "lmnn_impl.hpp" const size_t & Range() const
Access the range value.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t K()
Modify the value of k.
void LearnDistance(arma::mat &outputMatrix, CallbackTypes &&... callbacks)
Perform Large Margin Nearest Neighbors metric learning.
size_t & Range()
Modify the range value.
An implementation of Large Margin nearest neighbor metric learning technique.
LMetric< 2, false > SquaredEuclideanDistance
The squared Euclidean (L2) distance.
OptimizerType & Optimizer()
const OptimizerType & Optimizer() const
Get the optimizer.
const double & Regularization() const
Access the regularization value.
const arma::Row< size_t > & Labels() const
Get the labels reference.
const size_t & K() const
Access the value of k.
const arma::mat & Dataset() const
Get the dataset reference.
LMNN(const arma::mat &dataset, const arma::Row< size_t > &labels, const size_t k, const MetricType metric=MetricType())
Initialize the LMNN object, passing a dataset (distance metric is learned using this dataset) and lab...
double & Regularization()
Modify the regularization value.