[mlpack-git] master: Add comments, and minor cleanup. (de78ad8)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Thu Apr 23 17:41:34 EDT 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/5d820f8a54290f22e79831ff2f08d5ace0409343...97f2c927256ad6fb6206f3f5446a433ef84574c9

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

commit de78ad818b3f0a6c1e052ecb21451ee06af6fa5b
Author: Marcus Edel <marcus.edel at fu-berlin.de>
Date:   Thu Apr 23 23:40:36 2015 +0200

    Add comments, and minor cleanup.


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

de78ad818b3f0a6c1e052ecb21451ee06af6fa5b
 .../methods/ann/pooling_rules/max_pooling.hpp      | 31 +++++++++++++++-------
 .../methods/ann/pooling_rules/mean_pooling.hpp     | 27 ++++++++++++++-----
 2 files changed, 43 insertions(+), 15 deletions(-)

diff --git a/src/mlpack/methods/ann/pooling_rules/max_pooling.hpp b/src/mlpack/methods/ann/pooling_rules/max_pooling.hpp
index 1e95aa7..f088235 100644
--- a/src/mlpack/methods/ann/pooling_rules/max_pooling.hpp
+++ b/src/mlpack/methods/ann/pooling_rules/max_pooling.hpp
@@ -4,34 +4,47 @@
  *
  * Definition of the MaxPooling class, which implements max pooling.
  */
-#ifndef __MLPACK_METHODS_ANN_POOLING_MAX_POOLING_HPP
-#define __MLPACK_METHODS_ANN_POOLING_MAX_POOLING_HPP
+#ifndef __MLPACK_METHODS_ANN_POOLING_RULES_MAX_POOLING_HPP
+#define __MLPACK_METHODS_ANN_POOLING_RULES_MAX_POOLING_HPP
 
 #include <mlpack/core.hpp>
 
 namespace mlpack {
 namespace ann /** Artificial Neural Network. */ {
 
+/*
+ * The max pooling rule for convolution neural networks. Take the maximum value
+ * within the receptive block.
+ */
 class MaxPooling
 {
  public:
+  /*
+   * Return the maximum value within the receptive block.
+   *
+   * @param input Input used to perform the pooling operation.
+   */
   template<typename MatType>
-  static void pooling(const MatType& input, double& output)
+  double Pooling(const MatType& input)
   {
-    output = input.max();
+    return input.max();
   }
 
+  /*
+   * Set the maximum value within the receptive block.
+   *
+   * @param input Input used to perform the pooling operation.
+   * @param value The unpooled value.
+   * @param output The unpooled output data.
+   */
   template<typename MatType>
-  static void unpooling(const MatType& input, const double& value,
-                        MatType& output)
+  void Unpooling(const MatType& input, const double value, MatType& output)
   {
-    arma::uword row = 0;
-    arma::uword col = 0;
+    arma::uword row, col;
     output = arma::zeros<MatType>(input.n_rows, input.n_cols);
     input.max(row, col);
     output(row, col) = value;
   }
-  
 };
 
 }; // namespace ann
diff --git a/src/mlpack/methods/ann/pooling_rules/mean_pooling.hpp b/src/mlpack/methods/ann/pooling_rules/mean_pooling.hpp
index 0844565..1e25265 100644
--- a/src/mlpack/methods/ann/pooling_rules/mean_pooling.hpp
+++ b/src/mlpack/methods/ann/pooling_rules/mean_pooling.hpp
@@ -4,26 +4,41 @@
  *
  * Definition of the MeanPooling class, which implements mean pooling.
  */
-#ifndef __MLPACK_METHODS_ANN_POOLING_MEAN_POOLING_HPP
-#define __MLPACK_METHODS_ANN_POOLING_MEAN_POOLING_HPP
+#ifndef __MLPACK_METHODS_ANN_POOLING_RULES_MEAN_POOLING_HPP
+#define __MLPACK_METHODS_ANN_POOLING_RULES_MEAN_POOLING_HPP
 
 #include <mlpack/core.hpp>
 
 namespace mlpack {
 namespace ann /** Artificial Neural Network. */ {
 
+/*
+ * The mean pooling rule for convolution neural networks. Average all values
+ * within the receptive block.
+ */
 class MeanPooling
 {
  public:
+  /*
+   * Return the average value within the receptive block.
+   *
+   * @param input Input used to perform the pooling operation.
+   */
   template<typename MatType>
-  static void pooling(const MatType& input, double& output)
+  double Pooling(const MatType& input)
   {
-    output = arma::mean(arma::mean(input));
+    return arma::mean(arma::mean(input));
   }
 
+  /*
+   * Set the average value within the receptive block.
+   *
+   * @param input Input used to perform the pooling operation.
+   * @param value The unpooled value.
+   * @param output The unpooled output data.
+   */
   template<typename MatType>
-  static void unpooling(const MatType& input, const double& value,
-                        MatType& output)
+  void Unpooling(const MatType& input, const double value, MatType& output)
   {
     output = MatType(input.n_rows, input.n_cols);
     output.fill(value / input.n_elem);



More information about the mlpack-git mailing list