12 #ifndef MLPACK_METHODS_FASTMKS_FASTMKS_MODEL_IMPL_HPP 13 #define MLPACK_METHODS_FASTMKS_FASTMKS_MODEL_IMPL_HPP 21 template<
typename KernelType>
24 arma::mat&& referenceData,
30 throw std::invalid_argument(
"base must be greater than 1");
35 f.
Train(std::move(referenceData), k);
52 template<
typename KernelType,
59 throw std::invalid_argument(
"FastMKSModel::BuildModel(): given kernel type is" 60 " not equal to kernel type of the model!");
63 template<
typename TKernelType>
66 const bool singleMode,
102 case POLYNOMIAL_KERNEL:
107 case COSINE_DISTANCE:
112 case GAUSSIAN_KERNEL:
117 case EPANECHNIKOV_KERNEL:
122 case TRIANGULAR_KERNEL:
134 template<
typename Archive>
137 ar(CEREAL_NVP(kernelType));
139 if (cereal::is_loading<Archive>())
173 case POLYNOMIAL_KERNEL:
177 case COSINE_DISTANCE:
181 case GAUSSIAN_KERNEL:
185 case EPANECHNIKOV_KERNEL:
189 case TRIANGULAR_KERNEL:
199 template<
typename FastMKSType>
201 const arma::mat& querySet,
203 arma::Mat<size_t>& indices,
207 if (f.Naive() || f.SingleMode())
209 f.Search(querySet, k, indices, kernels);
214 typename FastMKSType::Tree queryTree(querySet, base);
217 f.Search(&queryTree, k, indices, kernels);
static void Start(const std::string &name)
Start the given timer.
Definition: timers.cpp:28
void Train(const MatType &referenceSet)
"Train" the FastMKS model on the given reference set (this will just build a tree, if the current search mode is not naive mode).
Definition: fastmks_impl.hpp:301
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
void Search(const arma::mat &querySet, const size_t k, arma::Mat< size_t > &indices, arma::mat &kernels, const double base)
Search with a different query set.
Definition: fastmks_model.cpp:250
void BuildModel(arma::mat &&referenceData, TKernelType &kernel, const bool singleMode, const bool naive, const double base)
Build the model on the given reference set.
Definition: fastmks_model_impl.hpp:64
The inner product metric, IPMetric, takes a given Mercer kernel (KernelType), and when Evaluate() is ...
Definition: ip_metric.hpp:32
void BuildFastMKSModel(FastMKS< KernelType > &f, KernelType &k, arma::mat &&referenceData, const double base)
This is called when the KernelType is the same as the model.
Definition: fastmks_model_impl.hpp:22
static void Stop(const std::string &name)
Stop the given timer.
Definition: timers.cpp:36
#define CEREAL_POINTER(T)
Cereal does not support the serialization of raw pointer.
Definition: pointer_wrapper.hpp:96
TreeType< metric::IPMetric< KernelType >, FastMKSStat, MatType > Tree
Convenience typedef.
Definition: fastmks.hpp:67
bool Naive() const
Get whether or not brute-force (naive) search is used.
Definition: fastmks.hpp:301
An implementation of fast exact max-kernel search.
Definition: fastmks.hpp:63
void serialize(Archive &ar, const uint32_t)
Serialize the model.
Definition: fastmks_model_impl.hpp:135
A cover tree is a tree specifically designed to speed up nearest-neighbor computation in high-dimensi...
Definition: cover_tree.hpp:99