[mlpack-git] master: change namespace to boost and provide overload of serialize (95191cf)

gitdub at mlpack.org gitdub at mlpack.org
Wed Mar 2 00:10:17 EST 2016


Repository : https://github.com/mlpack/mlpack
On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/a2e57d617e952f1ea2fda8a23e1c6bd2f78beb6d...1bedf15126f6bd0bc93a3233914ac95486a3c0da

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

commit 95191cf4d68fb08325a3aac9a89557a2f9ab1640
Author: stereomatchingkiss <stereomatchingkiss at gmail.com>
Date:   Wed Mar 2 13:10:12 2016 +0800

    change namespace to boost and provide overload of serialize


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

95191cf4d68fb08325a3aac9a89557a2f9ab1640
 src/mlpack/core/util/tuple_serialize.hpp      | 14 ++++++++++----
 src/mlpack/methods/ann/layer/base_layer.hpp   |  4 ++--
 src/mlpack/methods/ann/layer/bias_layer.hpp   | 12 ++++++------
 src/mlpack/methods/ann/layer/linear_layer.hpp | 12 ++++++------
 4 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/src/mlpack/core/util/tuple_serialize.hpp b/src/mlpack/core/util/tuple_serialize.hpp
index 0c8c76f..8099768 100644
--- a/src/mlpack/core/util/tuple_serialize.hpp
+++ b/src/mlpack/core/util/tuple_serialize.hpp
@@ -5,7 +5,7 @@
 
 #include <string>
 
-namespace mlpack {
+namespace boost {
 namespace serialization {  
  
   template<
@@ -15,10 +15,10 @@ namespace serialization {
       typename... Args
   >
   typename std::enable_if<I < Max, void>::type
-  Serialize(Archive& ar, std::tuple<Args...>& t, const unsigned int /* version */)
+  serialize(Archive& ar, std::tuple<Args...>& t, const unsigned int /* version */)
   {
     ar & data::CreateNVP(std::get<I>(t), "tuple" + std::to_string(I));
-    Serialize<I+1, Max>(ar, t, 0);
+    serialize<I+1, Max>(ar, t, 0);
   }
   
   template<
@@ -28,9 +28,15 @@ namespace serialization {
       typename... Args
   >
   typename std::enable_if<I == Max, void>::type 
-  Serialize(Archive&, std::tuple<Args...>&, const unsigned int /* version */)
+  serialize(Archive&, std::tuple<Args...>&, const unsigned int /* version */)
   {    
   }
+
+  template<typename Archive, typename... Args>
+  void serialize(Archive& ar, std::tuple<Args...>& t, const unsigned int /* version */)
+  {
+    serialize<0, std::tuple_size<std::tuple<Args...>>::value-1>(ar, t, 0);
+  }
 }
 }
 #endif
diff --git a/src/mlpack/methods/ann/layer/base_layer.hpp b/src/mlpack/methods/ann/layer/base_layer.hpp
index 385e38c..1cbeaaf 100644
--- a/src/mlpack/methods/ann/layer/base_layer.hpp
+++ b/src/mlpack/methods/ann/layer/base_layer.hpp
@@ -120,12 +120,12 @@ class BaseLayer
   }
 
   //! Get the input parameter.
-  InputDataType& InputParameter() const { return inputParameter; }
+  InputDataType const& InputParameter() const { return inputParameter; }
   //! Modify the input parameter.
   InputDataType& InputParameter() { return inputParameter; }
 
   //! Get the output parameter.
-  OutputDataType& OutputParameter() const { return outputParameter; }
+  OutputDataType const& OutputParameter() const { return outputParameter; }
   //! Modify the output parameter.
   OutputDataType& OutputParameter() { return outputParameter; }
 
diff --git a/src/mlpack/methods/ann/layer/bias_layer.hpp b/src/mlpack/methods/ann/layer/bias_layer.hpp
index bb29deb..007fa54 100644
--- a/src/mlpack/methods/ann/layer/bias_layer.hpp
+++ b/src/mlpack/methods/ann/layer/bias_layer.hpp
@@ -123,27 +123,27 @@ class BiasLayer
   }
 
   //! Get the weights.
-  InputDataType& Weights() const { return weights; }
+  InputDataType const& Weights() const { return weights; }
   //! Modify the weights.
   InputDataType& Weights() { return weights; }
 
   //! Get the input parameter.
-  InputDataType& InputParameter() const { return inputParameter; }
+  InputDataType const& InputParameter() const { return inputParameter; }
   //! Modify the input parameter.
   InputDataType& InputParameter() { return inputParameter; }
 
   //! Get the output parameter.
-  OutputDataType& OutputParameter() const { return outputParameter; }
+  OutputDataType const& OutputParameter() const { return outputParameter; }
   //! Modify the output parameter.
   OutputDataType& OutputParameter() { return outputParameter; }
 
   //! Get the delta.
-  OutputDataType& Delta() const { return delta; }
+  OutputDataType const& Delta() const { return delta; }
   //! Modify the delta.
   OutputDataType& Delta() { return delta; }
 
   //! Get the gradient.
-  InputDataType& Gradient() const { return gradient; }
+  InputDataType const& Gradient() const { return gradient; }
   //! Modify the gradient.
   InputDataType& Gradient() { return gradient; }
   
@@ -153,7 +153,7 @@ class BiasLayer
   template<typename Archive>
   void Serialize(Archive& ar, const unsigned int /* version */)
   {    			
-	ar & data::CreateNVP(weights, "weights");
+    ar & data::CreateNVP(weights, "weights");
   }
 
  private:
diff --git a/src/mlpack/methods/ann/layer/linear_layer.hpp b/src/mlpack/methods/ann/layer/linear_layer.hpp
index 0e78525..70a00eb 100644
--- a/src/mlpack/methods/ann/layer/linear_layer.hpp
+++ b/src/mlpack/methods/ann/layer/linear_layer.hpp
@@ -111,27 +111,27 @@ class LinearLayer
   }
 
   //! Get the weights.
-  OutputDataType& Weights() const { return weights; }
+  OutputDataType const& Weights() const { return weights; }
   //! Modify the weights.
   OutputDataType& Weights() { return weights; }
 
   //! Get the input parameter.
-  InputDataType& InputParameter() const { return inputParameter; }
+  InputDataType const& InputParameter() const { return inputParameter; }
   //! Modify the input parameter.
   InputDataType& InputParameter() { return inputParameter; }
 
   //! Get the output parameter.
-  OutputDataType& OutputParameter() const { return outputParameter; }
+  OutputDataType const& OutputParameter() const { return outputParameter; }
   //! Modify the output parameter.
   OutputDataType& OutputParameter() { return outputParameter; }
 
   //! Get the delta.
-  OutputDataType& Delta() const { return delta; }
+  OutputDataType const& Delta() const { return delta; }
   //! Modify the delta.
   OutputDataType& Delta() { return delta; }
 
   //! Get the gradient.
-  OutputDataType& Gradient() const { return gradient; }
+  OutputDataType const& Gradient() const { return gradient; }
   //! Modify the gradient.
   OutputDataType& Gradient() { return gradient; }
   
@@ -141,7 +141,7 @@ class LinearLayer
   template<typename Archive>
   void Serialize(Archive& ar, const unsigned int /* version */)
   {    			
-	ar & data::CreateNVP(weights, "weights");
+    ar & data::CreateNVP(weights, "weights");
   }
 
  private:




More information about the mlpack-git mailing list