[mlpack-svn] master: Add performance function test. (6b14d78)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Tue Jan 6 14:21:11 EST 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/6b14d78fc09cb205ffa7a297f5e6310b2ad83e25...9147fd3ee8072669c18422de4ea6fbe8f964b423

>---------------------------------------------------------------

commit 6b14d78fc09cb205ffa7a297f5e6310b2ad83e25
Author: Marcus Edel <marcus.edel at fu-berlin.de>
Date:   Tue Jan 6 11:36:38 2015 +0100

    Add performance function test.


>---------------------------------------------------------------

6b14d78fc09cb205ffa7a297f5e6310b2ad83e25
 src/mlpack/tests/performance_functions_test.cpp | 50 +++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/src/mlpack/tests/performance_functions_test.cpp b/src/mlpack/tests/performance_functions_test.cpp
new file mode 100644
index 0000000..df425c3
--- /dev/null
+++ b/src/mlpack/tests/performance_functions_test.cpp
@@ -0,0 +1,50 @@
+/**
+ * @file performance_functions_test.cpp
+ * @author Marcus Edel
+ *
+ *  Tests for the various performance functions.
+ */
+#include <mlpack/core.hpp>
+
+#include <mlpack/methods/ann/performance_functions/mse_function.hpp>
+#include <mlpack/methods/ann/performance_functions/cee_function.hpp>
+#include <mlpack/methods/ann/performance_functions/sse_function.hpp>
+
+#include <boost/test/unit_test.hpp>
+#include "old_boost_test_definitions.hpp"
+
+using namespace mlpack;
+using namespace mlpack::ann;
+
+BOOST_AUTO_TEST_SUITE(PerformanceFunctionsTest);
+
+// Test the mean squared error performance function.
+BOOST_AUTO_TEST_CASE(MeanSquaredErrorTest)
+{
+  arma::colvec input("1.0 0.0 1.0 0.0 -1.0 0.0 -1.0 0.0");
+  arma::colvec target = arma::zeros<arma::colvec>(8);
+
+  BOOST_REQUIRE_EQUAL(MeanSquaredErrorFunction<>::error(input, target), 0.5);
+}
+
+// Test the cross entropy performance function.
+BOOST_AUTO_TEST_CASE(CrossEntropyErrorTest)
+{
+  arma::colvec input;
+  input << std::exp(-2.0) << std::exp(-1.0);
+  arma::colvec target = arma::ones<arma::colvec>(2);
+
+  BOOST_REQUIRE_EQUAL(CrossEntropyErrorFunction<>::error(input, target), 3);
+}
+
+// Test the sum squared error performance function.
+BOOST_AUTO_TEST_CASE(SumSquaredErrorTest)
+{
+  arma::colvec input("1.0 0.0 1.0 0.0 -1.0 0.0 -1.0 0.0");
+  arma::colvec target = arma::zeros<arma::colvec>(8);
+
+  BOOST_REQUIRE_EQUAL(SumSquaredErrorFunction<>::error(input, target), 4);
+}
+
+BOOST_AUTO_TEST_SUITE_END();
+




More information about the mlpack-git mailing list