This class implements a simple perceptron (i.e., a single layer neural network).
More...
|
| 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 Classification. More...
|
|
| Perceptron (const Perceptron<> &other, MatType &data, const arma::rowvec &D, const arma::Row< size_t > &labels) |
| Alternate constructor which copies parameters from an already initiated perceptron. More...
|
|
void | Classify (const MatType &test, arma::Row< size_t > &predictedLabels) |
| Classification function. More...
|
|
|
void | Train (const arma::rowvec &D) |
| Training Function. More...
|
|
template<typename LearnPolicy = SimpleWeightUpdate, typename WeightInitializationPolicy = ZeroInitialization, typename MatType = arma::mat>
class mlpack::perceptron::Perceptron< LearnPolicy, WeightInitializationPolicy, MatType >
This class implements a simple perceptron (i.e., a single layer neural network).
It converges if the supplied training dataset is linearly separable.
- Template Parameters
-
Definition at line 46 of file perceptron.hpp.
template<typename LearnPolicy = SimpleWeightUpdate, typename WeightInitializationPolicy = ZeroInitialization, typename MatType = arma::mat>
Constructor - constructs the perceptron by building the weightVectors matrix, which is later used in Classification.
It adds a bias input vector of 1 to the input data to take care of the bias weights.
- Parameters
-
data | Input, training data. |
labels | Labels of dataset. |
iterations | Maximum number of iterations for the perceptron learning algorithm. |
template<typename LearnPolicy = SimpleWeightUpdate, typename WeightInitializationPolicy = ZeroInitialization, typename MatType = arma::mat>
Alternate constructor which copies parameters from an already initiated perceptron.
- Parameters
-
other | The other initiated Perceptron object from which we copy the values from. |
data | The data on which to train this Perceptron object on. |
D | Weight vector to use while training. For boosting purposes. |
labels | The labels of data. |
template<typename LearnPolicy = SimpleWeightUpdate, typename WeightInitializationPolicy = ZeroInitialization, typename MatType = arma::mat>
void mlpack::perceptron::Perceptron< LearnPolicy, WeightInitializationPolicy, MatType >::Classify |
( |
const MatType & |
test, |
|
|
arma::Row< size_t > & |
predictedLabels |
|
) |
| |
Classification function.
After training, use the weightVectors matrix to classify test, and put the predicted classes in predictedLabels.
- Parameters
-
test | Testing data or data to classify. |
predictedLabels | Vector to store the predicted classes after classifying test. |
template<typename LearnPolicy = SimpleWeightUpdate, typename WeightInitializationPolicy = ZeroInitialization, typename MatType = arma::mat>
Training Function.
It trains on trainData using the cost matrix D
- Parameters
-
D | Cost matrix. Stores the cost of mispredicting instances |
template<typename LearnPolicy = SimpleWeightUpdate, typename WeightInitializationPolicy = ZeroInitialization, typename MatType = arma::mat>
Stores the class labels for the input data.
Definition at line 88 of file perceptron.hpp.
template<typename LearnPolicy = SimpleWeightUpdate, typename WeightInitializationPolicy = ZeroInitialization, typename MatType = arma::mat>
To store the number of iterations.
Definition at line 85 of file perceptron.hpp.
template<typename LearnPolicy = SimpleWeightUpdate, typename WeightInitializationPolicy = ZeroInitialization, typename MatType = arma::mat>
Stores the training data to be used later on in UpdateWeights.
Definition at line 94 of file perceptron.hpp.
template<typename LearnPolicy = SimpleWeightUpdate, typename WeightInitializationPolicy = ZeroInitialization, typename MatType = arma::mat>
Stores the weight vectors for each of the input class labels.
Definition at line 91 of file perceptron.hpp.
The documentation for this class was generated from the following file: