[mlpack-git] master: Initialize the weights when loading (serialization). (c75652b)

gitdub at mlpack.org gitdub at mlpack.org
Wed Mar 9 11:53:50 EST 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/74593cef56f85a31b8cbfc777c7e0bf73d230c2a...c75652ba2e49a284f2b932b66e28491f64103bc2

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

commit c75652ba2e49a284f2b932b66e28491f64103bc2
Author: marcus <marcus.edel at fu-berlin.de>
Date:   Wed Mar 9 17:53:38 2016 +0100

    Initialize the weights when loading (serialization).


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

c75652ba2e49a284f2b932b66e28491f64103bc2
 src/mlpack/methods/ann/cnn_impl.hpp | 6 ++++++
 src/mlpack/methods/ann/ffn_impl.hpp | 6 ++++++
 src/mlpack/methods/ann/rnn_impl.hpp | 6 ++++++
 3 files changed, 18 insertions(+)

diff --git a/src/mlpack/methods/ann/cnn_impl.hpp b/src/mlpack/methods/ann/cnn_impl.hpp
index a4e7733..5950fda 100644
--- a/src/mlpack/methods/ann/cnn_impl.hpp
+++ b/src/mlpack/methods/ann/cnn_impl.hpp
@@ -265,6 +265,12 @@ LayerTypes, OutputLayerType, InitializationRuleType, PerformanceFunction
 >::Serialize(Archive& ar, const unsigned int /* version */)
 {
   ar & data::CreateNVP(parameter, "parameter");
+
+  // If we are loading, we need to initialize the weights.
+  if (Archive::is_loading::value)
+  {
+    NetworkWeights(parameter, network);
+  }
 }
 
 } // namespace ann
diff --git a/src/mlpack/methods/ann/ffn_impl.hpp b/src/mlpack/methods/ann/ffn_impl.hpp
index 0c4bd8d..a057f6b 100644
--- a/src/mlpack/methods/ann/ffn_impl.hpp
+++ b/src/mlpack/methods/ann/ffn_impl.hpp
@@ -269,6 +269,12 @@ LayerTypes, OutputLayerType, InitializationRuleType, PerformanceFunction
 >::Serialize(Archive& ar, const unsigned int /* version */)
 {
   ar & data::CreateNVP(parameter, "parameter");
+
+  // If we are loading, we need to initialize the weights.
+  if (Archive::is_loading::value)
+  {
+    NetworkWeights(parameter, network);
+  }
 }
 
 } // namespace ann
diff --git a/src/mlpack/methods/ann/rnn_impl.hpp b/src/mlpack/methods/ann/rnn_impl.hpp
index 279e86a..a01a3ab 100644
--- a/src/mlpack/methods/ann/rnn_impl.hpp
+++ b/src/mlpack/methods/ann/rnn_impl.hpp
@@ -328,6 +328,12 @@ LayerTypes, OutputLayerType, InitializationRuleType, PerformanceFunction
 >::Serialize(Archive& ar, const unsigned int /* version */)
 {
   ar & data::CreateNVP(parameter, "parameter");
+
+  // If we are loading, we need to initialize the weights.
+  if (Archive::is_loading::value)
+  {
+    NetworkWeights(parameter, network);
+  }
 }
 
 } // namespace ann




More information about the mlpack-git mailing list