GestureRecognitionToolkit  Version: 1.0 Revision: 04-03-15
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
GRT::MLP Class Reference
Inheritance diagram for GRT::MLP:
GRT::Regressifier GRT::MLBase GRT::GRTBase GRT::Observer< TrainingResult > GRT::Observer< TestInstanceResult >

Public Types

enum  TrainingModes { ONLINE_GRADIENT_DESCENT }
 
- Public Types inherited from GRT::Regressifier
typedef std::map< string, Regressifier *(*)() > StringRegressifierMap
 
- Public Types inherited from GRT::MLBase
enum  BaseTypes { BASE_TYPE_NOT_SET =0, CLASSIFIER, REGRESSIFIER, CLUSTERER }
 

Public Member Functions

 MLP ()
 
 MLP (const MLP &rhs)
 
virtual ~MLP ()
 
MLPoperator= (const MLP &rhs)
 
virtual bool deepCopyFrom (const Regressifier *regressifier)
 
virtual bool train_ (ClassificationData &trainingData)
 
virtual bool train_ (RegressionData &trainingData)
 
virtual bool predict_ (VectorDouble &inputVector)
 
virtual bool clear ()
 
virtual bool print () const
 
virtual bool saveModelToFile (fstream &file) const
 
virtual bool loadModelFromFile (fstream &file)
 
UINT getNumClasses () const
 
bool init (const UINT numInputNeurons, const UINT numHiddenNeurons, const UINT numOutputNeurons)
 
bool init (const UINT numInputNeurons, const UINT numHiddenNeurons, const UINT numOutputNeurons, const UINT inputLayerActivationFunction, const UINT hiddenLayerActivationFunction, const UINT outputLayerActivationFunction)
 
void printNetwork () const
 
bool checkForNAN () const
 
string activationFunctionToString (const UINT activationFunction) const
 
UINT activationFunctionFromString (const string activationName) const
 
bool validateActivationFunction (const UINT avactivationFunction) const
 
UINT getNumInputNeurons () const
 
UINT getNumHiddenNeurons () const
 
UINT getNumOutputNeurons () const
 
UINT getInputLayerActivationFunction () const
 
UINT getHiddenLayerActivationFunction () const
 
UINT getOutputLayerActivationFunction () const
 
UINT getNumRandomTrainingIterations () const
 
double getTrainingRate () const
 
double getMomentum () const
 
double getGamma () const
 
double getTrainingError () const
 
bool getClassificationModeActive () const
 
bool getRegressionModeActive () const
 
vector< NeurongetInputLayer () const
 
vector< NeurongetHiddenLayer () const
 
vector< NeurongetOutputLayer () const
 
vector< VectorDouble > getTrainingLog () const
 
bool getNullRejectionEnabled () const
 
double getNullRejectionCoeff () const
 
double getNullRejectionThreshold () const
 
double getMaximumLikelihood () const
 
VectorDouble getClassLikelihoods () const
 
VectorDouble getClassDistances () const
 
UINT getPredictedClassLabel () const
 
bool setInputLayerActivationFunction (const UINT activationFunction)
 
bool setHiddenLayerActivationFunction (const UINT activationFunction)
 
bool setOutputLayerActivationFunction (const UINT activationFunction)
 
bool setTrainingRate (const double trainingRate)
 
bool setMomentum (const double momentum)
 
bool setGamma (const double gamma)
 
bool setNumRandomTrainingIterations (const UINT numRandomTrainingIterations)
 
bool setNullRejection (const bool useNullRejection)
 
bool setNullRejectionCoeff (const double nullRejectionCoeff)
 
- Public Member Functions inherited from GRT::Regressifier
 Regressifier (void)
 
virtual ~Regressifier (void)
 
bool copyBaseVariables (const Regressifier *regressifier)
 
virtual bool reset ()
 
string getRegressifierType () const
 
VectorDouble getRegressionData () const
 
vector< MinMaxgetInputRanges () const
 
vector< MinMaxgetOutputRanges () const
 
RegressifiercreateNewInstance () const
 
RegressifierdeepCopy () const
 
const RegressifiergetBaseRegressifier () const
 
- Public Member Functions inherited from GRT::MLBase
 MLBase (void)
 
virtual ~MLBase (void)
 
bool copyMLBaseVariables (const MLBase *mlBase)
 
virtual bool train (ClassificationData trainingData)
 
virtual bool train (RegressionData trainingData)
 
virtual bool train (TimeSeriesClassificationData trainingData)
 
virtual bool train_ (TimeSeriesClassificationData &trainingData)
 
virtual bool train (TimeSeriesClassificationDataStream trainingData)
 
virtual bool train_ (TimeSeriesClassificationDataStream &trainingData)
 
virtual bool train (UnlabelledData trainingData)
 
virtual bool train_ (UnlabelledData &trainingData)
 
virtual bool train (MatrixDouble data)
 
virtual bool train_ (MatrixDouble &data)
 
virtual bool predict (VectorDouble inputVector)
 
virtual bool predict (MatrixDouble inputMatrix)
 
virtual bool predict_ (MatrixDouble &inputMatrix)
 
virtual bool map (VectorDouble inputVector)
 
virtual bool map_ (VectorDouble &inputVector)
 
virtual bool save (const string filename) const
 
virtual bool load (const string filename)
 
virtual bool saveModelToFile (string filename) const
 
virtual bool loadModelFromFile (string filename)
 
virtual bool getModel (ostream &stream) const
 
double scale (const double &x, const double &minSource, const double &maxSource, const double &minTarget, const double &maxTarget, const bool constrain=false)
 
virtual string getModelAsString () const
 
UINT getBaseType () const
 
UINT getNumInputFeatures () const
 
UINT getNumInputDimensions () const
 
UINT getNumOutputDimensions () const
 
UINT getMinNumEpochs () const
 
UINT getMaxNumEpochs () const
 
UINT getValidationSetSize () const
 
UINT getNumTrainingIterationsToConverge () const
 
double getMinChange () const
 
double getLearningRate () const
 
double getRootMeanSquaredTrainingError () const
 
double getTotalSquaredTrainingError () const
 
bool getUseValidationSet () const
 
bool getRandomiseTrainingOrder () const
 
bool getTrained () const
 
bool getModelTrained () const
 
bool getScalingEnabled () const
 
bool getIsBaseTypeClassifier () const
 
bool getIsBaseTypeRegressifier () const
 
bool getIsBaseTypeClusterer () const
 
bool enableScaling (bool useScaling)
 
bool setMaxNumEpochs (const UINT maxNumEpochs)
 
bool setMinNumEpochs (const UINT minNumEpochs)
 
bool setMinChange (const double minChange)
 
bool setLearningRate (double learningRate)
 
bool setUseValidationSet (const bool useValidationSet)
 
bool setValidationSetSize (const UINT validationSetSize)
 
bool setRandomiseTrainingOrder (const bool randomiseTrainingOrder)
 
bool registerTrainingResultsObserver (Observer< TrainingResult > &observer)
 
bool registerTestResultsObserver (Observer< TestInstanceResult > &observer)
 
bool removeTrainingResultsObserver (const Observer< TrainingResult > &observer)
 
bool removeTestResultsObserver (const Observer< TestInstanceResult > &observer)
 
bool removeAllTrainingObservers ()
 
bool removeAllTestObservers ()
 
bool notifyTrainingResultsObservers (const TrainingResult &data)
 
bool notifyTestResultsObservers (const TestInstanceResult &data)
 
MLBasegetMLBasePointer ()
 
const MLBasegetMLBasePointer () const
 
vector< TrainingResultgetTrainingResults () const
 
- Public Member Functions inherited from GRT::GRTBase
 GRTBase (void)
 
virtual ~GRTBase (void)
 
bool copyGRTBaseVariables (const GRTBase *GRTBase)
 
string getClassType () const
 
string getLastWarningMessage () const
 
string getLastErrorMessage () const
 
string getLastInfoMessage () const
 
GRTBasegetGRTBasePointer ()
 
const GRTBasegetGRTBasePointer () const
 
- Public Member Functions inherited from GRT::Observer< TrainingResult >
virtual void notify (const TrainingResult &data)
 
- Public Member Functions inherited from GRT::Observer< TestInstanceResult >
virtual void notify (const TestInstanceResult &data)
 

Protected Member Functions

bool isNAN (const double v) const
 
bool trainModel (RegressionData &trainingData)
 
bool trainOnlineGradientDescentClassification (const RegressionData &trainingData, const RegressionData &validationData)
 
bool trainOnlineGradientDescentRegression (const RegressionData &trainingData, const RegressionData &validationData)
 
bool loadLegacyModelFromFile (fstream &file)
 
double back_prop (const VectorDouble &trainingExample, const VectorDouble &targetVector, const double alpha, const double beta)
 
VectorDouble feedforward (VectorDouble trainingExample)
 
void feedforward (const VectorDouble &trainingExample, VectorDouble &inputNeuronsOuput, VectorDouble &hiddenNeuronsOutput, VectorDouble &outputNeuronsOutput)
 
- Protected Member Functions inherited from GRT::Regressifier
bool saveBaseSettingsToFile (fstream &file) const
 
bool loadBaseSettingsFromFile (fstream &file)
 
- Protected Member Functions inherited from GRT::MLBase
bool saveBaseSettingsToFile (fstream &file) const
 
bool loadBaseSettingsFromFile (fstream &file)
 
- Protected Member Functions inherited from GRT::GRTBase
double SQR (const double &x) const
 

Protected Attributes

UINT numInputNeurons
 
UINT numHiddenNeurons
 
UINT numOutputNeurons
 
UINT inputLayerActivationFunction
 
UINT hiddenLayerActivationFunction
 
UINT outputLayerActivationFunction
 
UINT numRandomTrainingIterations
 
UINT trainingMode
 
double momentum
 
double gamma
 
double trainingError
 
bool initialized
 
Random random
 
vector< NeuroninputLayer
 
vector< NeuronhiddenLayer
 
vector< NeuronoutputLayer
 
vector< VectorDouble > trainingErrorLog
 
bool classificationModeActive
 
bool useNullRejection
 
UINT predictedClassLabel
 
double nullRejectionThreshold
 
double nullRejectionCoeff
 
double maxLikelihood
 
VectorDouble classLikelihoods
 
VectorDouble inputNeuronsOuput
 
VectorDouble hiddenNeuronsOutput
 
VectorDouble outputNeuronsOutput
 
VectorDouble deltaO
 
VectorDouble deltaH
 
- Protected Attributes inherited from GRT::Regressifier
string regressifierType
 
VectorDouble regressionData
 
vector< MinMaxinputVectorRanges
 
vector< MinMaxtargetVectorRanges
 
- Protected Attributes inherited from GRT::MLBase
bool trained
 
bool useScaling
 
UINT baseType
 
UINT numInputDimensions
 
UINT numOutputDimensions
 
UINT numTrainingIterationsToConverge
 
UINT minNumEpochs
 
UINT maxNumEpochs
 
UINT validationSetSize
 
double learningRate
 
double minChange
 
double rootMeanSquaredTrainingError
 
double totalSquaredTrainingError
 
bool useValidationSet
 
bool randomiseTrainingOrder
 
Random random
 
vector< TrainingResulttrainingResults
 
TrainingResultsObserverManager trainingResultsObserverManager
 
TestResultsObserverManager testResultsObserverManager
 
- Protected Attributes inherited from GRT::GRTBase
string classType
 
DebugLog debugLog
 
ErrorLog errorLog
 
InfoLog infoLog
 
TrainingLog trainingLog
 
TestingLog testingLog
 
WarningLog warningLog
 

Static Protected Attributes

static RegisterRegressifierModule< MLPregisterModule
 

Additional Inherited Members

- Static Public Member Functions inherited from GRT::Regressifier
static RegressifiercreateInstanceFromString (string const &regressifierType)
 
static vector< string > getRegisteredRegressifiers ()
 
- Static Public Member Functions inherited from GRT::GRTBase
static string getGRTVersion (bool returnRevision=true)
 
static string getGRTRevison ()
 
- Static Protected Member Functions inherited from GRT::Regressifier
static StringRegressifierMapgetMap ()
 

Detailed Description

Definition at line 41 of file MLP.h.

Constructor & Destructor Documentation

GRT::MLP::MLP ( )

Default Constructor

Definition at line 28 of file MLP.cpp.

GRT::MLP::MLP ( const MLP rhs)

Copy Constructor

Definition at line 57 of file MLP.cpp.

GRT::MLP::~MLP ( )
virtual

Default Destructor

Definition at line 68 of file MLP.cpp.

Member Function Documentation

UINT GRT::MLP::activationFunctionFromString ( const string  activationName) const

Gets the activation function value from a string.

Parameters
stringactivationName: the activation function as a string
Returns
returns an UINT activation function

Definition at line 1594 of file MLP.cpp.

string GRT::MLP::activationFunctionToString ( const UINT  activationFunction) const

Gets a string representation of the activation function

Parameters
UINTactivationFunction: the activation function you want to convert to a string
Returns
returns a string representation of the activation function, returns UNKNOWN if the activation function is invalid

Definition at line 1573 of file MLP.cpp.

double GRT::MLP::back_prop ( const VectorDouble &  trainingExample,
const VectorDouble &  targetVector,
const double  alpha,
const double  beta 
)
protected

Performs one round of back propagation, using the training example and target vector

Parameters
constVectorDouble &trainingExample: the input vector to use for back propagation
constVectorDouble &targetVector: the target vector to use for back propagation
constdouble alpha: the training rate
constdouble beta: the momentum
Returns
returns the squared error for the current training example

Definition at line 837 of file MLP.cpp.

bool GRT::MLP::checkForNAN ( ) const

Checks if there are any NAN values in any of the layers.

Returns
returns true if there are any NAN values in any of the layers, false otherwise

Definition at line 1018 of file MLP.cpp.

bool GRT::MLP::clear ( )
virtual

Clears any previous model or settings.

Returns
returns true if the MLP was cleared, false otherwise

Reimplemented from GRT::Regressifier.

Definition at line 291 of file MLP.cpp.

bool GRT::MLP::deepCopyFrom ( const Regressifier regressifier)
virtual

This is required for the Gesture Recognition Pipeline for when the pipeline.setRegressifier(...) method is called. It clones the data from the Base Class Regressifier pointer (which should be pointing to an MLP instance) into this instance

Parameters
Regressifier*regressifier: a pointer to the Regressifier Base Class, this should be pointing to another MLP instance
Returns
returns true if the clone was successfull, false otherwise

Reimplemented from GRT::Regressifier.

Definition at line 108 of file MLP.cpp.

VectorDouble GRT::MLP::feedforward ( VectorDouble  trainingExample)
protected

Performs the feedforward step using the current model and the input training example.

Parameters
VectorDoubletrainingExample: the input vector to use for the feedforward
Returns
returns a new vector of the results from the feedforward step

Definition at line 920 of file MLP.cpp.

void GRT::MLP::feedforward ( const VectorDouble &  trainingExample,
VectorDouble &  inputNeuronsOuput,
VectorDouble &  hiddenNeuronsOutput,
VectorDouble &  outputNeuronsOutput 
)
protected

Performs the feedforward step for back propagation, using the input data

Parameters
constVectorDouble &trainingExample: the input vector to use for the feedforward
VectorDouble&inputNeuronsOuput: the results of the input layer
VectorDouble&hiddenNeuronsOutput: the results of the hidden layer
VectorDouble&outputNeuronsOutput: the results of the output layer

Definition at line 961 of file MLP.cpp.

VectorDouble GRT::MLP::getClassDistances ( ) const

Gets a vector of the class distances from the last prediction, this will be an N-dimensional vector, where N is the number of classes in the model.

Returns
returns a vector of the class distances from the last prediction, an empty vector will be returned if the model has not been trained

Definition at line 1562 of file MLP.cpp.

bool GRT::MLP::getClassificationModeActive ( ) const

Returns true if the MLP is in classification mode.

Returns
returns true if the MLP is in classification mode, false otherwise

Definition at line 1516 of file MLP.cpp.

VectorDouble GRT::MLP::getClassLikelihoods ( ) const

Gets a vector of the class likelihoods from the last prediction, this will be an N-dimensional vector, where N is the number of classes in the model.

Returns
returns a vector of the class likelihoods from the last prediction, an empty vector will be returned if the model has not been trained

Definition at line 1557 of file MLP.cpp.

double GRT::MLP::getGamma ( ) const

Gets the gamma value. This controls the gamma parameter for the neurons.

Returns
returns the gamma value for the neurons

Definition at line 1508 of file MLP.cpp.

vector< Neuron > GRT::MLP::getHiddenLayer ( ) const

Returns the neurons for the hidden layer.

Returns
returns a vector of neurons for the hidden layer

Definition at line 1528 of file MLP.cpp.

UINT GRT::MLP::getHiddenLayerActivationFunction ( ) const

Gets the hidden layer activation function.

Returns
returns the hidden layer activation function

Definition at line 1488 of file MLP.cpp.

vector< Neuron > GRT::MLP::getInputLayer ( ) const

Returns the neurons for the input layer.

Returns
returns a vector of neurons for the input layer

Definition at line 1524 of file MLP.cpp.

UINT GRT::MLP::getInputLayerActivationFunction ( ) const

Gets the input layer activation function.

Returns
returns the input layer activation function

Definition at line 1484 of file MLP.cpp.

double GRT::MLP::getMaximumLikelihood ( ) const

Returns the current maximumLikelihood value. The maximumLikelihood value is computed during the prediction phase and is the likelihood of the most likely model. This is only relevant if the MLP is in classification mode. This value will return 0 if a prediction has not been made.

Returns
returns the current maximumLikelihood value

Definition at line 1552 of file MLP.cpp.

double GRT::MLP::getMomentum ( ) const

Gets the momentum rate. This should be a value between [0 1]

Returns
returns the momentum

Definition at line 1504 of file MLP.cpp.

double GRT::MLP::getNullRejectionCoeff ( ) const

Returns the current null rejection coefficient value. The null rejection coefficient is a multipler controlling the null rejection threshold for each class. This is only relevant if the MLP is in classification mode.

Returns
returns the current null rejection coefficient

Definition at line 1544 of file MLP.cpp.

bool GRT::MLP::getNullRejectionEnabled ( ) const

Returns true if the MLP should use null rejection during classification. This is only relevant if the MLP is in classification mode.

Returns
returns true if the null rejection is enabled, false otherwise

Definition at line 1540 of file MLP.cpp.

double GRT::MLP::getNullRejectionThreshold ( ) const

Returns the current null rejection threshold value. The null rejection threshold is value controlling if a classification result should be rejected or accepted. This is only relevant if the MLP is in classification mode.

Returns
returns the current null rejection threshold

Definition at line 1548 of file MLP.cpp.

UINT GRT::MLP::getNumClasses ( ) const

Returns the number of classes in the MLP model if the MLP is in classification mode. The number of classes in the model is the same as the number of output neurons. If the MLP is in regression mode then it will return 0.

Returns
returns the number of classes in the MLP model if the MLP is in classification mode

Definition at line 1466 of file MLP.cpp.

UINT GRT::MLP::getNumHiddenNeurons ( ) const

Gets the number of hidden neurons.

Returns
returns the number of hidden neurons

Definition at line 1476 of file MLP.cpp.

UINT GRT::MLP::getNumInputNeurons ( ) const

Gets the number of input neurons.

Returns
returns the number of input neurons

Definition at line 1472 of file MLP.cpp.

UINT GRT::MLP::getNumOutputNeurons ( ) const

Gets the number of output neurons.

Returns
returns the number of output neurons

Definition at line 1480 of file MLP.cpp.

UINT GRT::MLP::getNumRandomTrainingIterations ( ) const

Gets the number of random training iterations that should be performed during the training phase. The MLP back propagation algorithm starts with random values, and the accuracy of a trained model can depend on which random values the algorithm started with. The GRT MLP algorithm therefore trains a number of models and picks the best one. This value therefore represents the number of random training iterations that should be used.

Returns
returns the number of random training iterations that should be performed during the training phase

Definition at line 1496 of file MLP.cpp.

vector< Neuron > GRT::MLP::getOutputLayer ( ) const

Returns the neurons for the output layer.

Returns
returns a vector of neurons for the output layer

Definition at line 1532 of file MLP.cpp.

UINT GRT::MLP::getOutputLayerActivationFunction ( ) const

Gets the output layer activation function.

Returns
returns the output layer activation function

Definition at line 1492 of file MLP.cpp.

UINT GRT::MLP::getPredictedClassLabel ( ) const

Gets the predicted class label from the last prediction. This is only relevant if the MLP is in classification mode.

Returns
returns the label of the last predicted class, a value of 0 will be returned if the model has not been trained

Definition at line 1568 of file MLP.cpp.

bool GRT::MLP::getRegressionModeActive ( ) const

Returns true if the MLP is in regression mode.

Returns
returns true if the MLP is in regression mode, false otherwise

Definition at line 1520 of file MLP.cpp.

double GRT::MLP::getTrainingError ( ) const

Gets training error from the last round of training. If the MLP is in classification mode, the training error will be the classification accuracy. If the MLP is in regression mode then the training error will be the RMS error.

Returns
returns the training error from the last round of training

Definition at line 1512 of file MLP.cpp.

vector< vector< double > > GRT::MLP::getTrainingLog ( ) const

Returns a vector of VectorDouble representing the training log for each random round of training. The outer vector represents each round and the inner vector represents each epoch in that round.

Returns
returns a vector of MinMax values representing the ranges of the output layer

Definition at line 1536 of file MLP.cpp.

double GRT::MLP::getTrainingRate ( ) const

Gets the training rate. This should be a value between [0 1]

Returns
returns the training rate

Definition at line 1500 of file MLP.cpp.

bool GRT::MLP::init ( const UINT  numInputNeurons,
const UINT  numHiddenNeurons,
const UINT  numOutputNeurons 
)

Initializes the MLP for training. This should be called before the MLP is trained. The number of input neurons should match the number of input dimensions in your training data. The number of output neurons should match the number of target dimensions in your training data. The number of hidden units should be chosen by the user, a common rule of thumb is to set this as a value somewhere between the number of input neurons and the number of output neurons. Initializaling the MLP will clear any previous model or settings.

This function calls the other init function below, passing in the layer activation functions.

Parameters
constUINT numInputNeurons: the number of input neurons (should match the number of input dimensions in your training data)
constUINT numHiddenNeurons: the number of hidden neurons
constUINT numOutputNeurons: the number of output neurons (should match the number of target dimensions in your training data)
Returns
returns true if the MLP was initialized, false otherwise

Definition at line 219 of file MLP.cpp.

bool GRT::MLP::init ( const UINT  numInputNeurons,
const UINT  numHiddenNeurons,
const UINT  numOutputNeurons,
const UINT  inputLayerActivationFunction,
const UINT  hiddenLayerActivationFunction,
const UINT  outputLayerActivationFunction 
)

Initializes the MLP for training. This should be called before the MLP is trained. The number of input neurons should match the number of input dimensions in your training data. The number of output neurons should match the number of target dimensions in your training data. The number of hidden units should be chosen by the user, a common rule of thumb is to set this as a value somewhere between the number of input neurons and the number of output neurons. The activation functions should be one of the Neuron ActivationFunctions enums. Initializaling the MLP will clear any previous model or settings.

Parameters
constUINT numInputNeurons: the number of input neurons (should match the number of input dimensions in your training data)
constUINT numHiddenNeurons: the number of hidden neurons
constUINT numOutputNeurons: the number of output neurons (should match the number of target dimensions in your training data)
constUINT inputLayerActivationFunction: the activation function to use for the input layer
constUINT hiddenLayerActivationFunction: the activation function to use for the input layer
constUINT outputLayerActivationFunction: the activation function to use for the input layer
Returns
returns true if the MLP was initialized, false otherwise

Definition at line 223 of file MLP.cpp.

bool GRT::MLP::loadModelFromFile ( fstream &  file)
virtual

This loads a trained MLP model from a file. This overrides the loadModelFromFile function in the ML base class.

Parameters
fstream&file: a reference to the file the MLP model will be loaded from
Returns
returns true if the model was loaded successfully, false otherwise

Reimplemented from GRT::MLBase.

Definition at line 1123 of file MLP.cpp.

MLP & GRT::MLP::operator= ( const MLP rhs)

Defines how the data from the rhs MLP should be copied to this MLP

Parameters
constMLP &rhs: another instance of a MLP
Returns
returns a reference to this instance of the MLP

Definition at line 72 of file MLP.cpp.

bool GRT::MLP::predict_ ( VectorDouble &  inputVector)
virtual

This function either predicts the class of the input vector (if the MLP is in Classification Mode), or it performs regression using the MLP model.

Parameters
VectorDouble&inputVector: the input vector to classify or perform regression on
Returns
returns true if the prediction/regression was performed, false otherwise

Reimplemented from GRT::MLBase.

Definition at line 160 of file MLP.cpp.

bool GRT::MLP::print ( ) const
virtual

This function will print the model and settings to the display log.

Returns
returns true if the model was printed succesfully, false otherwise

Reimplemented from GRT::MLBase.

Definition at line 307 of file MLP.cpp.

void GRT::MLP::printNetwork ( ) const

Prints the current MLP weights and coefficents to std out. This function is depreciated, you should now use print() instead.

Definition at line 986 of file MLP.cpp.

bool GRT::MLP::saveModelToFile ( fstream &  file) const
virtual

This saves the trained MLP model to a file. This overrides the saveModelToFile function in the ML base class.

Parameters
fstream&file: a reference to the file the MLP model will be saved to
Returns
returns true if the model was saved successfully, false otherwise

Reimplemented from GRT::MLBase.

Definition at line 1049 of file MLP.cpp.

bool GRT::MLP::setGamma ( const double  gamma)

Sets the gamma parameter for the Neurons. Gamma must be greater than zero. If the MLP instance has been initialized then this function will also call the init function to reinitialize the instance.

Parameters
constdouble gamma: the gamma value for each Neuron, gamma must be greater than zero
Returns
returns true if the value was updated successfully, false otherwise

Definition at line 1676 of file MLP.cpp.

bool GRT::MLP::setHiddenLayerActivationFunction ( const UINT  activationFunction)

This function sets the activation function for all the Neurons in the hidden layer. If the MLP instance has been initialized then this function will also call the init function to reinitialize the instance.

Parameters
constUINT activationFunction: the activation function for the hidden layer, this should be one of the Neuron ActivationFunctions enums
Returns
returns true if the hidden layer activation function was set successfully, false otherwise

Definition at line 1633 of file MLP.cpp.

bool GRT::MLP::setInputLayerActivationFunction ( const UINT  activationFunction)

This function sets the activation function for all the Neurons in the input layer. If the MLP instance has been initialized then this function will also call the init function to reinitialize the instance.

Parameters
constUINT activationFunction: the activation function for the input layer, this should be one of the Neuron ActivationFunctions enums
Returns
returns true if the input layer activation function was set successfully, false otherwise

Definition at line 1617 of file MLP.cpp.

bool GRT::MLP::setMomentum ( const double  momentum)

Sets the momentum parameter. This is used to update the weights at each step of the stochastic gradient descent. The momentum parameter is normally set between [0.1 0.9], with 0.5 being a common value.

Parameters
constdouble momentum: the momentum value used during the training phase, must be greater than zero
Returns
returns true if the value was updated successfully, false otherwise

Definition at line 1668 of file MLP.cpp.

bool GRT::MLP::setNullRejection ( const bool  useNullRejection)

Sets if null rejection should be used for the real-time prediction. This is only used if the MLP is in classificationMode.

Parameters
constbool useNullRejection: if true then null rejection will be used
Returns
returns true if the value was updated successfully, false otherwise

Definition at line 1699 of file MLP.cpp.

bool GRT::MLP::setNullRejectionCoeff ( const double  nullRejectionCoeff)

This function lets you manually control the null rejection threshold. Any class with a prediction value less than the null rejection threshold will be rejected, setting the predicted class label to 0.

This is only used if the MLP is in classificationMode.

Parameters
constdouble nullRejectionCoeff: the new null rejection threshold
Returns
returns true if the value was updated successfully, false otherwise

Definition at line 1704 of file MLP.cpp.

bool GRT::MLP::setNumRandomTrainingIterations ( const UINT  numRandomTrainingIterations)

Sets number of times the MLP model should be trained to find the best model. This value must be greater than zero.

Setting this value to a high number (i.e. 100) will most likely give you a better model, however it will take much longer to train the overall model. Setting this value to a low number (i.e. 5) will make the training process much faster, but you might not get the best model.

Parameters
constUINT numRandomTrainingIterations: the number of times you want to randomly train the MLP model to search for the best results
Returns
returns true if the value was updated successfully, false otherwise

Definition at line 1691 of file MLP.cpp.

bool GRT::MLP::setOutputLayerActivationFunction ( const UINT  activationFunction)

This function sets the activation function for all the Neurons in the output layer. If the MLP instance has been initialized then this function will also call the init function to reinitialize the instance.

Parameters
constUINT activationFunction: the activation function for the output layer, this should be one of the Neuron ActivationFunctions enums
Returns
returns true if the output layer activation function was set successfully, false otherwise

Definition at line 1649 of file MLP.cpp.

bool GRT::MLP::setTrainingRate ( const double  trainingRate)

Sets the training rate, which controls the learning rate parameter. This is used to update the weights at each step of the stochastic gradient descent. The learningRate value must be greater than zero, a value of 0.1 normally works well. If you find the MLP fails to train with this value then try setting the learning rate to a smaller value (for example 0.01).

Parameters
constdouble trainingRate: the learningRate value used during the training phase, must be greater than zero
Returns
returns true if the value was updated successfully, false otherwise

Definition at line 1664 of file MLP.cpp.

bool GRT::MLP::train_ ( ClassificationData trainingData)
virtual

This trains the MLP model, using the labelled classification data. Calling this function sets the MLP into Classification Model.

Parameters
ClassificationData&trainingData: the training data that will be used to train the classification model
Returns
returns true if the MLP model was trained, false otherwise

Reimplemented from GRT::MLBase.

Definition at line 126 of file MLP.cpp.

bool GRT::MLP::train_ ( RegressionData trainingData)
virtual

This trains the MLP model, using the labelled regression data. Calling this function sets the MLP into Regression Model.

Parameters
RegressionDatatrainingData: the training data that will be used to train the regression model
Returns
returns true if the MLP model was trained, false otherwise

Reimplemented from GRT::MLBase.

Definition at line 151 of file MLP.cpp.

bool GRT::MLP::validateActivationFunction ( const UINT  avactivationFunction) const

Validates if the activationFunction is valid.

Parameters
UINTactivationFunction: the activation function you want to valid
Returns
returns true if the activation function is valid, false otherwise

Definition at line 1612 of file MLP.cpp.


The documentation for this class was generated from the following files: