mlpack  1.0.12
perceptron.hpp
Go to the documentation of this file.
1 
14 #ifndef __MLPACK_METHODS_PERCEPTRON_PERCEPTRON_HPP
15 #define __MLPACK_METHODS_PERCEPTRON_PERCEPTRON_HPP
16 
17 #include <mlpack/core.hpp>
18 
22 
23 namespace mlpack {
24 namespace perceptron {
25 
35 template<typename LearnPolicy = SimpleWeightUpdate,
36  typename WeightInitializationPolicy = ZeroInitialization,
37  typename MatType = arma::mat>
39 {
40  public:
51  Perceptron(const MatType& data, const arma::Row<size_t>& labels, int iterations);
52 
61  void Classify(const MatType& test, arma::Row<size_t>& predictedLabels);
62 
73  Perceptron(const Perceptron<>& other, MatType& data, const arma::rowvec& D, const arma::Row<size_t>& labels);
74 
75 private:
77  size_t iter;
78 
80  arma::Row<size_t> classLabels;
81 
83  arma::mat weightVectors;
84 
86  arma::mat trainData;
87 
93  void Train(const arma::rowvec& D);
94 };
95 
96 } // namespace perceptron
97 } // namespace mlpack
98 
99 #include "perceptron_impl.hpp"
100 
101 #endif
void Train(const arma::rowvec &D)
Training Function.
arma::mat weightVectors
Stores the weight vectors for each of the input class labels.
Definition: perceptron.hpp:83
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:23
Perceptron(const MatType &data, const arma::Row< size_t > &labels, int iterations)
Constructor - constructs the perceptron by building the weightVectors matrix, which is later used in ...
arma::Row< size_t > classLabels
Stores the class labels for the input data.
Definition: perceptron.hpp:80
void Classify(const MatType &test, arma::Row< size_t > &predictedLabels)
Classification function.
arma::mat trainData
Stores the training data to be used later on in UpdateWeights.
Definition: perceptron.hpp:86
size_t iter
To store the number of iterations.
Definition: perceptron.hpp:77
This class implements a simple perceptron (i.e., a single layer neural network).
Definition: perceptron.hpp:38