12 #ifndef MLPACK_METHODS_PERCEPTRON_PERCEPTRON_HPP
13 #define MLPACK_METHODS_PERCEPTRON_PERCEPTRON_HPP
22 namespace perceptron {
33 template<
typename LearnPolicy = SimpleWeightUpdate,
34 typename WeightInitializationPolicy = ZeroInitialization,
35 typename MatType = arma::mat>
50 const size_t dimensionality = 0,
51 const size_t maxIterations = 1000);
67 const arma::Row<size_t>& labels,
68 const size_t numClasses,
69 const size_t maxIterations = 1000);
83 const arma::Row<size_t>& labels,
84 const arma::rowvec& instanceWeights);
101 void Train(
const MatType& data,
102 const arma::Row<size_t>& labels,
103 const arma::rowvec& instanceWeights = arma::rowvec());
113 void Classify(
const MatType& test, arma::Row<size_t>& predictedLabels);
118 template<
typename Archive>
119 void Serialize(Archive& ar,
const unsigned int );
130 const arma::mat&
Weights()
const {
return weights; }
135 const arma::vec&
Biases()
const {
return biases; }
141 size_t maxIterations;
158 #include "perceptron_impl.hpp"
arma::vec & Biases()
Modify the biases. You had better know what you are doing!
void Train(const MatType &data, const arma::Row< size_t > &labels, const arma::rowvec &instanceWeights=arma::rowvec())
Train the perceptron on the given data for up to the maximum number of iterations (specified in the c...
size_t NumClasses() const
Get the number of classes this perceptron has been trained for.
The core includes that mlpack expects; standard C++ includes and Armadillo.
const arma::mat & Weights() const
Get the weight matrix.
size_t MaxIterations() const
Get the maximum number of iterations.
Perceptron(const size_t numClasses=0, const size_t dimensionality=0, const size_t maxIterations=1000)
Constructor: create the perceptron with the given number of classes and initialize the weight matrix...
size_t & MaxIterations()
Modify the maximum number of iterations.
const arma::vec & Biases() const
Get the biases.
void Classify(const MatType &test, arma::Row< size_t > &predictedLabels)
Classification function.
arma::mat & Weights()
Modify the weight matrix. You had better know what you are doing!
void Serialize(Archive &ar, const unsigned int)
Serialize the perceptron.
This class implements a simple perceptron (i.e., a single layer neural network).