[mlpack-git] master: Build the adam optimizer test. (b864df8)
gitdub at mlpack.org
gitdub at mlpack.org
Mon Mar 14 18:12:23 EDT 2016
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/c0886a18f63c9335a0c39dcc34c27b8925dcb91b...b864df8cf10592b3874b079302774dbe7a4c1dbc
>---------------------------------------------------------------
commit b864df8cf10592b3874b079302774dbe7a4c1dbc
Author: marcus <marcus.edel at fu-berlin.de>
Date: Mon Mar 14 23:11:58 2016 +0100
Build the adam optimizer test.
>---------------------------------------------------------------
b864df8cf10592b3874b079302774dbe7a4c1dbc
src/mlpack/tests/CMakeLists.txt | 1 +
src/mlpack/tests/adam_test.cpp | 57 +----------------------------------------
2 files changed, 2 insertions(+), 56 deletions(-)
diff --git a/src/mlpack/tests/CMakeLists.txt b/src/mlpack/tests/CMakeLists.txt
index fff69ea..6539f2a 100644
--- a/src/mlpack/tests/CMakeLists.txt
+++ b/src/mlpack/tests/CMakeLists.txt
@@ -3,6 +3,7 @@ add_executable(mlpack_test
mlpack_test.cpp
activation_functions_test.cpp
adaboost_test.cpp
+ adam_test.cpp
allkfn_test.cpp
allknn_test.cpp
allkrann_search_test.cpp
diff --git a/src/mlpack/tests/adam_test.cpp b/src/mlpack/tests/adam_test.cpp
index eeb2719..df36980 100644
--- a/src/mlpack/tests/adam_test.cpp
+++ b/src/mlpack/tests/adam_test.cpp
@@ -1,25 +1,15 @@
/**
* @file adam_test.cpp
- * @author Marcus Edel
+ * @author Vasanth Kalingeri
*
* Tests the Adam optimizer.
*/
#include <mlpack/core.hpp>
-
#include <mlpack/core/optimizers/adam/adam.hpp>
#include <mlpack/core/optimizers/sgd/test_function.hpp>
-
#include <mlpack/methods/logistic_regression/logistic_regression.hpp>
-#include <mlpack/methods/ann/ffn.hpp>
-#include <mlpack/methods/ann/init_rules/random_init.hpp>
-#include <mlpack/methods/ann/performance_functions/mse_function.hpp>
-#include <mlpack/methods/ann/layer/binary_classification_layer.hpp>
-#include <mlpack/methods/ann/layer/bias_layer.hpp>
-#include <mlpack/methods/ann/layer/linear_layer.hpp>
-#include <mlpack/methods/ann/layer/base_layer.hpp>
-
#include <boost/test/unit_test.hpp>
#include "old_boost_test_definitions.hpp"
@@ -31,7 +21,6 @@ using namespace mlpack::distribution;
using namespace mlpack::regression;
using namespace mlpack;
-using namespace mlpack::ann;
BOOST_AUTO_TEST_SUITE(AdamTest);
@@ -112,48 +101,4 @@ BOOST_AUTO_TEST_CASE(LogisticRegressionTest)
BOOST_REQUIRE_CLOSE(testAcc, 100.0, 0.6); // 0.6% error tolerance.
}
-/**
- * Run Adam on a feedforward neural network and make sure the results are
- * acceptable.
- */
-BOOST_AUTO_TEST_CASE(FeedforwardTest)
-{
- // Test on a non-linearly separable dataset (XOR).
- arma::mat input, labels;
- input << 0 << 1 << 1 << 0 << arma::endr
- << 1 << 0 << 1 << 0 << arma::endr;
- labels << 1 << 1 << 0 << 0;
-
- // Instantiate the first layer.
- LinearLayer<> inputLayer(input.n_rows, 8);
- BiasLayer<> biasLayer(8);
- TanHLayer<> hiddenLayer0;
-
- // Instantiate the second layer.
- LinearLayer<> hiddenLayer1(8, labels.n_rows);
- TanHLayer<> outputLayer;
-
- // Instantiate the output layer.
- BinaryClassificationLayer classOutputLayer;
-
- // Instantiate the feedforward network.
- auto modules = std::tie(inputLayer, biasLayer, hiddenLayer0, hiddenLayer1,
- outputLayer);
- FFN<decltype(modules), decltype(classOutputLayer), RandomInitialization,
- MeanSquaredErrorFunction> net(modules, classOutputLayer);
-
- Adam<decltype(net)> opt(net, 0.03, 0.9, 0.999, 1e-8, 300 * input.n_cols, -10);
-
- net.Train(input, labels, opt);
-
- arma::mat prediction;
- net.Predict(input, prediction);
-
- BOOST_REQUIRE_EQUAL(prediction(0), 1);
- BOOST_REQUIRE_EQUAL(prediction(1), 1);
- BOOST_REQUIRE_EQUAL(prediction(2), 0);
- BOOST_REQUIRE_EQUAL(prediction(3), 0);
-}
-
BOOST_AUTO_TEST_SUITE_END();
-
More information about the mlpack-git
mailing list