[mlpack-svn] master: Add implementation of the mean squared error performance function. (e17d89c)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Tue Jan 6 14:20:46 EST 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/6b14d78fc09cb205ffa7a297f5e6310b2ad83e25...9147fd3ee8072669c18422de4ea6fbe8f964b423
>---------------------------------------------------------------
commit e17d89c8a1e9b8c9f9dd499b5a21756785c8ea68
Author: Marcus Edel <marcus.edel at fu-berlin.de>
Date: Sat Jan 3 14:13:23 2015 +0100
Add implementation of the mean squared error performance function.
>---------------------------------------------------------------
e17d89c8a1e9b8c9f9dd499b5a21756785c8ea68
.../ann/performance_functions/mse_function.hpp | 42 ++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/src/mlpack/methods/ann/performance_functions/mse_function.hpp b/src/mlpack/methods/ann/performance_functions/mse_function.hpp
new file mode 100644
index 0000000..cd59c3d
--- /dev/null
+++ b/src/mlpack/methods/ann/performance_functions/mse_function.hpp
@@ -0,0 +1,42 @@
+/**
+ * @file mse_function.hpp
+ * @author Marcus Edel
+ *
+ * Definition and implementation of the mean squared error performance function.
+ */
+#ifndef __MLPACK_METHODS_ANN_PERFORMANCE_FUNCTIONS_MSE_FUNCTION_HPP
+#define __MLPACK_METHODS_ANN_PERFORMANCE_FUNCTIONS_MSE_FUNCTION_HPP
+
+#include <mlpack/core.hpp>
+
+namespace mlpack {
+namespace ann /** Artificial Neural Network. */ {
+
+/**
+ * The mean squared error performance function measures the network's
+ * performance according to the mean of squared errors.
+ *
+ * @tparam VecType Type of data (arma::colvec, arma::mat or arma::sp_mat).
+ */
+template<typename VecType = arma::colvec>
+class MeanSquaredErrorFunction
+{
+ public:
+ /**
+ * Computes the mean squared error function.
+ *
+ * @param input Input data.
+ * @param target Target data.
+ * @return mean of squared errors.
+ */
+ static double error(const VecType& input, const VecType& target)
+ {
+ return arma::mean(arma::square(target - input));
+ }
+
+}; // class MeanSquaredErrorFunction
+
+}; // namespace ann
+}; // namespace mlpack
+
+#endif
More information about the mlpack-git
mailing list