[mlpack-git] master: Add implementation of the orthogonal initialization method. (5454079)

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


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

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

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

commit 5454079e637b34de4f0d688571ecd79fc947286c
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.


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

5454079e637b34de4f0d688571ecd79fc947286c
 .../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