[mlpack-git] [mlpack/mlpack] Modeling LSH For Performance Tuning (#749)
Ryan Curtin
notifications at github.com
Sat Aug 13 12:19:14 EDT 2016
> + sampleSet = arma::shuffle(sampleSet);
> + const size_t numSamples = sampleSet.n_cols; // Points in sampled set.
> +
> + Log::Info << "Training model with " << numSamples << " points in sample set."
> + << std::endl;
> +
> + // Step 2. Compute all-vs-all distances of points in the sample.
> + // The distance matrix is symmetric, so we only compute elements above the
> + // diagonal. There are (N * (N - 1)) / 2 such elements.
> + Timer::Start("pairwise_distances");
> + arma::vec distances(numSamples * (numSamples - 1) / 2);
> + size_t d = 0; // Index of where to store next.
> + for (size_t i = 0; i < numSamples; ++i)
> + for (size_t j = i + 1; j < numSamples; ++j)
> + distances(d++) = metric::EuclideanDistance::Evaluate(
> + sampleSet.unsafe_col(i), sampleSet.unsafe_col(j));
Nice, I like the optimization to only compute less than half the elements in the distance matrix here.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/749/files/cdcb575826bfb3bd0ef4cafacf465435b3d6d144#r74688842
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160813/a2fc01c6/attachment.html>
More information about the mlpack-git
mailing list