small update
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#define MLPACK_METHODS_LMNN_FUNCTION_IMPL_HPP
|
||||
|
||||
#include "lmnn_function.hpp"
|
||||
#include "constraints.hpp"
|
||||
|
||||
#include <mlpack/core/math/make_alias.hpp>
|
||||
#include <mlpack/core/optimizers/function.hpp>
|
||||
@@ -32,8 +33,7 @@ LMNNFunction<MetricType>::LMNNFunction(const arma::mat& dataset,
|
||||
metric(metric),
|
||||
regularization(regularization),
|
||||
iteration(0),
|
||||
range(1),
|
||||
constraint(dataset, labels, k)
|
||||
range(1)
|
||||
{
|
||||
// Initialize the initial learning point.
|
||||
initialPoint.eye(dataset.n_rows, dataset.n_rows);
|
||||
@@ -44,7 +44,7 @@ LMNNFunction<MetricType>::LMNNFunction(const arma::mat& dataset,
|
||||
targetNeighbors = arma::Mat<size_t>(k, dataset.n_cols, arma::fill::zeros);
|
||||
impostors = arma::Mat<size_t>(k, dataset.n_cols, arma::fill::zeros);
|
||||
distance = arma::mat(k, dataset.n_cols, arma::fill::zeros);
|
||||
|
||||
Constraints<MetricType> constraint(dataset, labels, k);
|
||||
constraint.TargetNeighbors(targetNeighbors);
|
||||
constraint.Impostors(impostors);
|
||||
|
||||
@@ -68,7 +68,7 @@ void LMNNFunction<MetricType>::Shuffle()
|
||||
labels = std::move(newLabels);
|
||||
|
||||
// Re-calculate target neighbors as indices changed.
|
||||
constraint.Dataset() = dataset;
|
||||
Constraints<MetricType> constraint(dataset, labels, k);
|
||||
constraint.TargetNeighbors(targetNeighbors);
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ double LMNNFunction<MetricType>::Evaluate(const arma::mat& transformation)
|
||||
if (iteration % range == 0)
|
||||
{
|
||||
// Re-calculate impostors on transformed dataset.
|
||||
constraint.Dataset() = transformedDataset;
|
||||
Constraints<MetricType> constraint(transformedDataset, labels, k);
|
||||
constraint.Impostors(impostors, distance);
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ double LMNNFunction<MetricType>::Evaluate(const arma::mat& transformation,
|
||||
if (iteration % range == 0)
|
||||
{
|
||||
// Re-calculate impostors on transformed dataset.
|
||||
constraint.Dataset() = transformedDataset;
|
||||
Constraints<MetricType> constraint(transformedDataset, labels, k);
|
||||
constraint.Impostors(impostors, distance, begin, batchSize);
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ double LMNNFunction<MetricType>::EvaluateWithGradient(
|
||||
if (iteration % range == 0)
|
||||
{
|
||||
// Re-calculate impostors on transformed dataset.
|
||||
constraint.Dataset() = transformedDataset;
|
||||
Constraints<MetricType> constraint(transformedDataset, labels, k);
|
||||
constraint.Impostors(impostors, distance);
|
||||
}
|
||||
|
||||
@@ -409,7 +409,7 @@ double LMNNFunction<MetricType>::EvaluateWithGradient(
|
||||
if (iteration % range == 0)
|
||||
{
|
||||
// Re-calculate impostors on transformed dataset.
|
||||
constraint.Dataset() = transformedDataset;
|
||||
Constraints<MetricType> constraint(transformedDataset, labels, k);
|
||||
constraint.Impostors(impostors, distance, begin, batchSize);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user