[mlpack-svn] r17473 - in mlpack/tags/mlpack-1.0.11: . src/mlpack/methods/sparse_coding src/mlpack/tests
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Sun Dec 7 14:48:08 EST 2014
Author: rcurtin
Date: Sun Dec 7 14:48:08 2014
New Revision: 17473
Log:
Backport r17442:17443.
Modified:
mlpack/tags/mlpack-1.0.11/ (props changed)
mlpack/tags/mlpack-1.0.11/src/mlpack/methods/sparse_coding/sparse_coding.hpp
mlpack/tags/mlpack-1.0.11/src/mlpack/methods/sparse_coding/sparse_coding_impl.hpp
mlpack/tags/mlpack-1.0.11/src/mlpack/tests/sa_test.cpp
mlpack/tags/mlpack-1.0.11/src/mlpack/tests/svd_batch_test.cpp
Modified: mlpack/tags/mlpack-1.0.11/src/mlpack/methods/sparse_coding/sparse_coding.hpp
==============================================================================
--- mlpack/tags/mlpack-1.0.11/src/mlpack/methods/sparse_coding/sparse_coding.hpp (original)
+++ mlpack/tags/mlpack-1.0.11/src/mlpack/methods/sparse_coding/sparse_coding.hpp Sun Dec 7 14:48:08 2014
@@ -159,11 +159,14 @@
* the coding matrix Z that are non-zero (the adjacency matrix for the
* bipartite graph of points and atoms).
* @param newtonTolerance Tolerance of the Newton's method optimizer.
+ * @param maxIterations Maximum number of iterations to run the Newton's method.
+ * If 0, the method will run until convergence (or forever).
* @return the norm of the gradient of the Lagrange dual with respect to
* the dual variables
*/
double OptimizeDictionary(const arma::uvec& adjacencies,
- const double newtonTolerance = 1e-6);
+ const double newtonTolerance = 1e-6,
+ const size_t maxIterations = 50);
/**
* Project each atom of the dictionary back onto the unit ball, if necessary.
Modified: mlpack/tags/mlpack-1.0.11/src/mlpack/methods/sparse_coding/sparse_coding_impl.hpp
==============================================================================
--- mlpack/tags/mlpack-1.0.11/src/mlpack/methods/sparse_coding/sparse_coding_impl.hpp (original)
+++ mlpack/tags/mlpack-1.0.11/src/mlpack/methods/sparse_coding/sparse_coding_impl.hpp Sun Dec 7 14:48:08 2014
@@ -134,7 +134,8 @@
template<typename DictionaryInitializer>
double SparseCoding<DictionaryInitializer>::OptimizeDictionary(
const arma::uvec& adjacencies,
- const double newtonTolerance)
+ const double newtonTolerance,
+ const size_t maxIterations)
{
// Count the number of atomic neighbors for each point x^i.
arma::uvec neighborCounts = arma::zeros<arma::uvec>(data.n_cols, 1);
@@ -222,7 +223,7 @@
}
double normGradient;
- double improvement;
+ double improvement = 0;
for (size_t t = 1; !converged; ++t)
{
arma::mat A = codesZT + diagmat(dualVars);
@@ -243,7 +244,7 @@
const double rho = 0.9;
double sufficientDecrease = c * dot(gradient, searchDirection);
- while (true)
+ for (size_t t = 1; t != maxIterations; ++t)
{
// Calculate objective.
double sumDualVars = sum(dualVars);
Modified: mlpack/tags/mlpack-1.0.11/src/mlpack/tests/sa_test.cpp
==============================================================================
--- mlpack/tags/mlpack-1.0.11/src/mlpack/tests/sa_test.cpp (original)
+++ mlpack/tags/mlpack-1.0.11/src/mlpack/tests/sa_test.cpp Sun Dec 7 14:48:08 2014
@@ -42,7 +42,7 @@
BOOST_AUTO_TEST_CASE(GeneralizedRosenbrockTest)
{
- math::RandomSeed(std::time(NULL));
+ mlpack::math::RandomSeed(std::time(NULL));
size_t dim = 50;
GeneralizedRosenbrockFunction f(dim);
Modified: mlpack/tags/mlpack-1.0.11/src/mlpack/tests/svd_batch_test.cpp
==============================================================================
--- mlpack/tags/mlpack-1.0.11/src/mlpack/tests/svd_batch_test.cpp (original)
+++ mlpack/tags/mlpack-1.0.11/src/mlpack/tests/svd_batch_test.cpp Sun Dec 7 14:48:08 2014
@@ -157,7 +157,7 @@
*/
BOOST_AUTO_TEST_CASE(SVDBatchNegativeElementTest)
{
- math::RandomSeed(std::time(NULL));
+ mlpack::math::RandomSeed(std::time(NULL));
// Create two 5x3 matrices that we should be able to recover.
mat testLeft;
testLeft.randu(5, 3);
More information about the mlpack-svn
mailing list