[mlpack-svn] master: Add implementation of the orthogonal initialization method. (818347e)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Fri Jan 2 06:00:49 EST 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/10d90d03c8e6bfa272429f22ce051267a65ef3da...818347e1556f54d5d0c54974758755b53f1608e0

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

commit 818347e1556f54d5d0c54974758755b53f1608e0
Author: Marcus Edel <marcus.edel at fu-berlin.de>
Date:   Fri Jan 2 12:00:27 2015 +0100

    Add implementation of the orthogonal initialization method.


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

818347e1556f54d5d0c54974758755b53f1608e0
 .../methods/ann/init_rules/orthogonal_init.hpp     | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/src/mlpack/methods/ann/init_rules/orthogonal_init.hpp b/src/mlpack/methods/ann/init_rules/orthogonal_init.hpp
new file mode 100644
index 0000000..8764664
--- /dev/null
+++ b/src/mlpack/methods/ann/init_rules/orthogonal_init.hpp
@@ -0,0 +1,59 @@
+/**
+ * @file orthogonal_init.hpp
+ * @author Marcus Edel
+ *
+ * Definition and implementation of the orthogonal matrix initialization method.
+ */
+#ifndef __MLPACK_METHOS_ANN_INIT_RULES_ORTHOGONAL_INIT_HPP
+#define __MLPACK_METHOS_ANN_INIT_RULES_ORTHOGONAL_INIT_HPP
+
+#include <mlpack/core.hpp>
+
+namespace mlpack {
+namespace ann /** Artificial Neural Network. */ {
+
+/**
+ * This class is used to initialize the weight matrix with the orthogonal
+ * matrix initialization
+ *
+ * @tparam MatType Type of matrix (should be arma::mat or arma::spmat).
+ * @tparam VecType Type of vector (arma::colvec, arma::mat or arma::sp_mat).
+ */
+template<typename MatType = arma::mat, typename VecType = arma::colvec>
+class OrthogonalInitialization
+{
+ public:
+  /**
+   * Initialize the orthogonal matrix initialization rule with the given gain.
+   *
+   * @param gain The gain value.
+   */
+  OrthogonalInitialization(const double gain = 1.0) : gain(gain) { }
+
+  /**
+   * Initialize the elements of the specified weight matrix with the
+   * orthogonal matrix initialization method.
+   *
+   * @param W Weight matrix to initialize.
+   * @param n_rows Number of rows.
+   * @return n_cols Number of columns.
+   */
+  void Initialize(MatType& W, const size_t n_rows, const size_t n_cols)
+  {
+    MatType V;
+    VecType s;
+
+    arma::svd_econ(W, s, V, arma::randu<MatType>(n_rows, n_cols));
+    W *= gain;
+  }
+
+ private:
+  //! The number used as lower bound.
+  const double gain;
+}; // class OrthogonalInitialization
+
+
+}; // namespace ann
+}; // namespace mlpack
+
+#endif




More information about the mlpack-git mailing list