[mlpack-git] master: Add performance function test. (ed24d0e)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Mar 5 22:10:45 EST 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/904762495c039e345beba14c1142fd719b3bd50e...f94823c800ad6f7266995c700b1b630d5ffdcf40

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

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

    Add performance function test.


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

ed24d0eb547b048c0709216bebe9e2a7c77a72a1
 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