[mlpack-git] master: Add Serialize() (unimplemented) to the perceptron. (80feca5)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Fri Sep 4 11:50:39 EDT 2015


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

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/f5893d5d190d5f5b4b6dc94e2593f50c56d406e4...424383cb02dcf2d73728e1c3c4b582bdb7cba627

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

commit 80feca52c77ad9ae7444f333d0bfca6abe9195d9
Author: Ryan Curtin <ryan at ratml.org>
Date:   Wed Sep 2 22:23:37 2015 +0000

    Add Serialize() (unimplemented) to the perceptron.


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

80feca52c77ad9ae7444f333d0bfca6abe9195d9
 src/mlpack/methods/perceptron/perceptron.hpp      | 29 ++++++++++++++++-------
 src/mlpack/methods/perceptron/perceptron_impl.hpp | 12 ++++++++++
 2 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/src/mlpack/methods/perceptron/perceptron.hpp b/src/mlpack/methods/perceptron/perceptron.hpp
index 04a9a6b..b58d538 100644
--- a/src/mlpack/methods/perceptron/perceptron.hpp
+++ b/src/mlpack/methods/perceptron/perceptron.hpp
@@ -41,7 +41,9 @@ class Perceptron
    * @param iterations Maximum number of iterations for the perceptron learning
    *     algorithm.
    */
-  Perceptron(const MatType& data, const arma::Row<size_t>& labels, int iterations);
+  Perceptron(const MatType& data,
+             const arma::Row<size_t>& labels,
+             int iterations);
 
   /**
    * Classification function. After training, use the weightVectors matrix to
@@ -54,16 +56,25 @@ class Perceptron
   void Classify(const MatType& test, arma::Row<size_t>& predictedLabels);
 
   /**
-   *  Alternate constructor which copies parameters from an already initiated
-   *  perceptron.
+   * Alternate constructor which copies parameters from an already initiated
+   * perceptron.
    *
-   *  @param other The other initiated Perceptron object from which we copy the
-   *               values from.
-   *  @param data The data on which to train this Perceptron object on.
-   *  @param D Weight vector to use while training. For boosting purposes.
-   *  @param labels The labels of data.
+   * @param other The other initiated Perceptron object from which we copy the
+   *       values from.
+   * @param data The data on which to train this Perceptron object on.
+   * @param D Weight vector to use while training. For boosting purposes.
+   * @param labels The labels of data.
    */
-  Perceptron(const Perceptron<>& other, MatType& data, const arma::rowvec& D, const arma::Row<size_t>& labels);
+  Perceptron(const Perceptron<>& other,
+             MatType& data,
+             const arma::rowvec& D,
+             const arma::Row<size_t>& labels);
+
+  /**
+   * Serialize the perceptron.
+   */
+  template<typename Archive>
+  void Serialize(Archive& ar, const unsigned int /* version */);
 
 private:
   //! To store the number of iterations
diff --git a/src/mlpack/methods/perceptron/perceptron_impl.hpp b/src/mlpack/methods/perceptron/perceptron_impl.hpp
index 3bc23ce..01a105f 100644
--- a/src/mlpack/methods/perceptron/perceptron_impl.hpp
+++ b/src/mlpack/methods/perceptron/perceptron_impl.hpp
@@ -110,6 +110,18 @@ Perceptron<LearnPolicy, WeightInitializationPolicy, MatType>::Perceptron(
   Train(D);
 }
 
+//! Serialize the perceptron.
+template<typename LearnPolicy,
+         typename WeightInitializationPolicy,
+         typename MatType>
+template<typename Archive>
+void Perceptron<LearnPolicy, WeightInitializationPolicy, MatType>::Serialize(
+    Archive& ar,
+    const unsigned int /* version */)
+{
+  // For now, do nothing.
+}
+
 /**
  *  Training Function. It trains on trainData using the cost matrix D
  *



More information about the mlpack-git mailing list