[mlpack-git] master: Remove unnecessary parameters. (d37d1cd)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Wed Dec 16 14:12:30 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/cd5986e141b41781fdc13a9c89443f9be33b56bd...31c10fef76ac1d85c6415c92d2ccd429c430105f
>---------------------------------------------------------------
commit d37d1cd47c8620c30e32a943466dad654bcbd57a
Author: Ryan Curtin <ryan at ratml.org>
Date: Mon Dec 14 18:09:21 2015 +0000
Remove unnecessary parameters.
>---------------------------------------------------------------
d37d1cd47c8620c30e32a943466dad654bcbd57a
src/mlpack/methods/sparse_coding/sparse_coding.cpp | 4 +---
src/mlpack/methods/sparse_coding/sparse_coding.hpp | 9 +++------
src/mlpack/methods/sparse_coding/sparse_coding_impl.hpp | 2 +-
src/mlpack/tests/sparse_coding_test.cpp | 4 ++--
4 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/src/mlpack/methods/sparse_coding/sparse_coding.cpp b/src/mlpack/methods/sparse_coding/sparse_coding.cpp
index aef67b8..1e944fe 100644
--- a/src/mlpack/methods/sparse_coding/sparse_coding.cpp
+++ b/src/mlpack/methods/sparse_coding/sparse_coding.cpp
@@ -54,9 +54,7 @@ void SparseCoding::Encode(const arma::mat& data, arma::mat& codes)
// Dictionary step for optimization.
double SparseCoding::OptimizeDictionary(const arma::mat& data,
const arma::mat& codes,
- const arma::uvec& adjacencies,
- const double newtonTolerance,
- const size_t maxIterations)
+ const arma::uvec& adjacencies)
{
// Count the number of atomic neighbors for each point x^i.
arma::uvec neighborCounts = arma::zeros<arma::uvec>(data.n_cols, 1);
diff --git a/src/mlpack/methods/sparse_coding/sparse_coding.hpp b/src/mlpack/methods/sparse_coding/sparse_coding.hpp
index 439d2e0..ccd3545 100644
--- a/src/mlpack/methods/sparse_coding/sparse_coding.hpp
+++ b/src/mlpack/methods/sparse_coding/sparse_coding.hpp
@@ -190,20 +190,17 @@ class SparseCoding
/**
* Learn dictionary via Newton method based on Lagrange dual.
*
+ * @param data Data matrix.
+ * @param codes Matrix of codes.
* @param adjacencies Indices of entries (unrolled column by column) of
* 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::mat& data,
const arma::mat& codes,
- const arma::uvec& adjacencies,
- const double newtonTolerance = 1e-6,
- const size_t maxIterations = 50);
+ const arma::uvec& adjacencies);
/**
* Project each atom of the dictionary back onto the unit ball, if necessary.
diff --git a/src/mlpack/methods/sparse_coding/sparse_coding_impl.hpp b/src/mlpack/methods/sparse_coding/sparse_coding_impl.hpp
index 1f09ec3..ae19913 100644
--- a/src/mlpack/methods/sparse_coding/sparse_coding_impl.hpp
+++ b/src/mlpack/methods/sparse_coding/sparse_coding_impl.hpp
@@ -71,7 +71,7 @@ void SparseCoding::Train(
// First step: optimize the dictionary.
Log::Info << "Performing dictionary step... " << std::endl;
- OptimizeDictionary(data, codes, adjacencies, newtonTolerance);
+ OptimizeDictionary(data, codes, adjacencies);
Log::Info << " Objective value: " << Objective(data, codes) << "."
<< std::endl;
diff --git a/src/mlpack/tests/sparse_coding_test.cpp b/src/mlpack/tests/sparse_coding_test.cpp
index 5129430..ef91c58 100644
--- a/src/mlpack/tests/sparse_coding_test.cpp
+++ b/src/mlpack/tests/sparse_coding_test.cpp
@@ -119,7 +119,7 @@ BOOST_AUTO_TEST_CASE(SparseCodingTestDictionaryStep)
for (uword i = 0; i < nPoints; ++i)
X.col(i) /= norm(X.col(i), 2);
- SparseCoding sc(nAtoms, lambda1);
+ SparseCoding sc(nAtoms, lambda1, 0.0, 0, 0.01, 1e-15);
mat Z;
DataDependentRandomInitializer::Initialize(X, 25, sc.Dictionary());
sc.Encode(X, Z);
@@ -127,7 +127,7 @@ BOOST_AUTO_TEST_CASE(SparseCodingTestDictionaryStep)
mat D = sc.Dictionary();
uvec adjacencies = find(Z);
- double normGradient = sc.OptimizeDictionary(X, Z, adjacencies, 1e-15);
+ double normGradient = sc.OptimizeDictionary(X, Z, adjacencies);
BOOST_REQUIRE_SMALL(normGradient, tol);
}
More information about the mlpack-git
mailing list