[mlpack-git] master: Add weight zero initialization rule. (a7a6856)
gitdub at big.cc.gt.atl.ga.us
gitdub at big.cc.gt.atl.ga.us
Sat Jun 27 08:47:22 EDT 2015
Repository : https://github.com/mlpack/mlpack
On branch : master
Link : https://github.com/mlpack/mlpack/compare/9f0d3b30c469a3a535d3672b70c88aacbb2753c1...cf08dc96724f70468c8e31ced1761ed000b55b18
>---------------------------------------------------------------
commit a7a68562c8aa85f0b8369895645c007c0fcc2575
Author: Marcus Edel <marcus.edel at fu-berlin.de>
Date: Fri Jun 26 11:07:33 2015 +0200
Add weight zero initialization rule.
>---------------------------------------------------------------
a7a68562c8aa85f0b8369895645c007c0fcc2575
src/mlpack/methods/ann/init_rules/zero_init.hpp | 60 +++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/src/mlpack/methods/ann/init_rules/zero_init.hpp b/src/mlpack/methods/ann/init_rules/zero_init.hpp
new file mode 100644
index 0000000..a33e2fc
--- /dev/null
+++ b/src/mlpack/methods/ann/init_rules/zero_init.hpp
@@ -0,0 +1,60 @@
+/**
+ * @file zero_init.hpp
+ * @author Marcus Edel
+ *
+ * Intialization rule for the neural networks. This simple initialization is
+ * performed by assigning a zero matrix to the weight matrix.
+ */
+#ifndef __MLPACK_METHODS_ANN_INIT_RULES_ZERO_INIT_HPP
+#define __MLPACK_METHODS_ANN_INIT_RULES_ZERO_INIT_HPP
+
+#include <mlpack/core.hpp>
+
+namespace mlpack {
+namespace ann /** Artificial Neural Network. */ {
+
+/**
+ * This class is used to initialize randomly the weight matrix.
+ */
+class ZeroInitialization
+{
+ public:
+ /**
+ * Create the ZeroInitialization object.
+ */
+ ZeroInitialization() { /* Nothing to do here */ }
+
+ /**
+ * Initialize the elements of the specified weight matrix.
+ *
+ * @param W Weight matrix to initialize.
+ * @param rows Number of rows.
+ * @param cols Number of columns.
+ */
+ template<typename eT>
+ void Initialize(arma::Mat<eT>& W, const size_t rows, const size_t cols)
+ {
+ W = arma::zeros<arma::Mat<eT> >(rows, cols);
+ }
+
+ /**
+ * Initialize the elements of the specified weight (3rd order tensor).
+ *
+ * @param W Weight matrix to initialize.
+ * @param rows Number of rows.
+ * @param cols Number of columns.
+ */
+ template<typename eT>
+ void Initialize(arma::Cube<eT>& W,
+ const size_t rows,
+ const size_t cols,
+ const size_t slices)
+ {
+ W = arma::zeros<arma::Cube<eT> >(rows, cols, slices);
+ }
+}; // class ZeroInitialization
+
+}; // namespace ann
+}; // namespace mlpack
+
+#endif
More information about the mlpack-git
mailing list