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

Public Types

enum  TrainingAlgorithm { ONLINE_GRADIENT_DESCENT =0 }
 
- Public Types inherited from Regressifier
typedef std::map< std::string, Regressifier *(*)() > StringRegressifierMap
 
- Public Types inherited from MLBase
enum  BaseType {
  BASE_TYPE_NOT_SET =0, CLASSIFIER, REGRESSIFIER, CLUSTERER,
  PRE_PROCSSING, POST_PROCESSING, FEATURE_EXTRACTION, CONTEXT
}
 

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_ (VectorFloat &inputVector)
 
virtual bool clear ()
 
virtual bool print () const
 
virtual bool save (std::fstream &file) const
 
virtual bool load (std::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 Neuron::Type inputLayerActivationFunction, const Neuron::Type hiddenLayerActivationFunction, const Neuron::Type outputLayerActivationFunction)
 
void printNetwork () const
 
bool checkForNAN () const
 
std::string activationFunctionToString (const Neuron::Type activationFunction) const
 
Neuron::Type activationFunctionFromString (const std::string activationName) const
 
bool validateActivationFunction (const Neuron::Type avactivationFunction) const
 
UINT getNumInputNeurons () const
 
UINT getNumHiddenNeurons () const
 
UINT getNumOutputNeurons () const
 
UINT getNumRandomTrainingIterations () const
 
Neuron::Type getInputLayerActivationFunction () const
 
Neuron::Type getHiddenLayerActivationFunction () const
 
Neuron::Type getOutputLayerActivationFunction () const
 
Float getTrainingRate () const
 
Float getMomentum () const
 
Float getGamma () const
 
Float getTrainingError () const
 
bool getClassificationModeActive () const
 
bool getRegressionModeActive () const
 
Vector< NeurongetInputLayer () const
 
Vector< NeurongetHiddenLayer () const
 
Vector< NeurongetOutputLayer () const
 
Vector< VectorFloatgetTrainingLog () const
 
bool getNullRejectionEnabled () const
 
Float getNullRejectionCoeff () const
 
Float getNullRejectionThreshold () const
 
Float getMaximumLikelihood () const
 
VectorFloat getClassLikelihoods () const
 
VectorFloat getClassDistances () const
 
UINT getPredictedClassLabel () const
 
bool setInputLayerActivationFunction (const Neuron::Type activationFunction)
 
bool setHiddenLayerActivationFunction (const Neuron::Type activationFunction)
 
bool setOutputLayerActivationFunction (const Neuron::Type activationFunction)
 
bool setTrainingRate (const Float trainingRate)
 
bool setMomentum (const Float momentum)
 
bool setGamma (const Float gamma)
 
 GRT_DEPRECATED_MSG ("setNumRandomTrainingIterations() is deprecated, use setNumRestarts() instead", bool setNumRandomTrainingIterations(const UINT numRandomTrainingIterations))
 
bool setNullRejection (const bool useNullRejection)
 
bool setNullRejectionCoeff (const Float nullRejectionCoeff)
 
- Public Member Functions inherited from Regressifier
 Regressifier (const std::string &id="")
 
virtual ~Regressifier (void)
 
bool copyBaseVariables (const Regressifier *regressifier)
 
virtual bool reset () override
 
VectorFloat getRegressionData () const
 
Vector< MinMaxgetInputRanges () const
 
Vector< MinMaxgetOutputRanges () const
 
RegressifierdeepCopy () const
 
const RegressifiergetBaseRegressifier () const
 
Regressifiercreate () const
 
 GRT_DEPRECATED_MSG ("createNewInstance is deprecated, use create() instead.", Regressifier *createNewInstance() const )
 
 GRT_DEPRECATED_MSG ("createInstanceFromString(id) is deprecated, use create(id) instead.", static Regressifier *createInstanceFromString(const std::string &id))
 
 GRT_DEPRECATED_MSG ("getRegressifierType is deprecated, use getId() instead", std::string getRegressifierType() const )
 
- Public Member Functions inherited from MLBase
 MLBase (const std::string &id="", const BaseType type=BASE_TYPE_NOT_SET)
 
virtual ~MLBase (void)
 
bool copyMLBaseVariables (const MLBase *mlBase)
 
virtual bool train (ClassificationData trainingData)
 
virtual bool train (RegressionData trainingData)
 
virtual bool train (RegressionData trainingData, RegressionData validationData)
 
virtual bool train_ (RegressionData &trainingData, RegressionData &validationData)
 
virtual bool train (TimeSeriesClassificationData trainingData)
 
virtual bool train_ (TimeSeriesClassificationData &trainingData)
 
virtual bool train (ClassificationDataStream trainingData)
 
virtual bool train_ (ClassificationDataStream &trainingData)
 
virtual bool train (UnlabelledData trainingData)
 
virtual bool train_ (UnlabelledData &trainingData)
 
virtual bool train (MatrixFloat data)
 
virtual bool train_ (MatrixFloat &data)
 
virtual bool predict (VectorFloat inputVector)
 
virtual bool predict (MatrixFloat inputMatrix)
 
virtual bool predict_ (MatrixFloat &inputMatrix)
 
virtual bool map (VectorFloat inputVector)
 
virtual bool map_ (VectorFloat &inputVector)
 
virtual bool save (const std::string &filename) const
 
virtual bool load (const std::string &filename)
 
 GRT_DEPRECATED_MSG ("saveModelToFile(std::string filename) is deprecated, use save(const std::string &filename) instead", virtual bool saveModelToFile(const std::string &filename) const )
 
 GRT_DEPRECATED_MSG ("saveModelToFile(std::fstream &file) is deprecated, use save(std::fstream &file) instead", virtual bool saveModelToFile(std::fstream &file) const )
 
 GRT_DEPRECATED_MSG ("loadModelFromFile(std::string filename) is deprecated, use load(const std::string &filename) instead", virtual bool loadModelFromFile(const std::string &filename))
 
 GRT_DEPRECATED_MSG ("loadModelFromFile(std::fstream &file) is deprecated, use load(std::fstream &file) instead", virtual bool loadModelFromFile(std::fstream &file))
 
virtual bool getModel (std::ostream &stream) const
 
virtual std::string getModelAsString () const
 
DataType getInputType () const
 
DataType getOutputType () const
 
BaseType getType () const
 
UINT getNumInputFeatures () const
 
UINT getNumInputDimensions () const
 
UINT getNumOutputDimensions () const
 
UINT getMinNumEpochs () const
 
UINT getMaxNumEpochs () const
 
UINT getBatchSize () const
 
UINT getNumRestarts () const
 
UINT getValidationSetSize () const
 
UINT getNumTrainingIterationsToConverge () const
 
Float getMinChange () const
 
Float getLearningRate () const
 
Float getRMSTrainingError () const
 
 GRT_DEPRECATED_MSG ("getRootMeanSquaredTrainingError() is deprecated, use getRMSTrainingError() instead", Float getRootMeanSquaredTrainingError() const )
 
Float getTotalSquaredTrainingError () const
 
Float getRMSValidationError () const
 
Float getValidationSetAccuracy () const
 
VectorFloat getValidationSetPrecision () const
 
VectorFloat getValidationSetRecall () const
 
bool getUseValidationSet () const
 
bool getRandomiseTrainingOrder () const
 
bool getTrained () const
 
 GRT_DEPRECATED_MSG ("getModelTrained() is deprecated, use getTrained() instead", bool getModelTrained() const )
 
bool getConverged () const
 
bool getScalingEnabled () const
 
bool getIsBaseTypeClassifier () const
 
bool getIsBaseTypeRegressifier () const
 
bool getIsBaseTypeClusterer () const
 
bool getTrainingLoggingEnabled () const
 
bool getTestingLoggingEnabled () const
 
bool enableScaling (const bool useScaling)
 
bool setMaxNumEpochs (const UINT maxNumEpochs)
 
bool setBatchSize (const UINT batchSize)
 
bool setMinNumEpochs (const UINT minNumEpochs)
 
bool setNumRestarts (const UINT numRestarts)
 
bool setMinChange (const Float minChange)
 
bool setLearningRate (const Float learningRate)
 
bool setUseValidationSet (const bool useValidationSet)
 
bool setValidationSetSize (const UINT validationSetSize)
 
bool setRandomiseTrainingOrder (const bool randomiseTrainingOrder)
 
bool setTrainingLoggingEnabled (const bool loggingEnabled)
 
bool setTestingLoggingEnabled (const bool loggingEnabled)
 
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 GRTBase
 GRTBase (const std::string &id="")
 
virtual ~GRTBase (void)
 
bool copyGRTBaseVariables (const GRTBase *GRTBase)
 
 GRT_DEPRECATED_MSG ("getClassType is deprecated, use getId() instead!", std::string getClassType() const )
 
std::string getId () const
 
std::string getLastWarningMessage () const
 
std::string getLastErrorMessage () const
 
std::string getLastInfoMessage () const
 
bool setInfoLoggingEnabled (const bool loggingEnabled)
 
bool setWarningLoggingEnabled (const bool loggingEnabled)
 
bool setErrorLoggingEnabled (const bool loggingEnabled)
 
bool setDebugLoggingEnabled (const bool loggingEnabled)
 
GRTBasegetGRTBasePointer ()
 
const GRTBasegetGRTBasePointer () const
 
Float scale (const Float &x, const Float &minSource, const Float &maxSource, const Float &minTarget, const Float &maxTarget, const bool constrain=false)
 
Float SQR (const Float &x) const
 
- Public Member Functions inherited from Observer< TrainingResult >
virtual void notify (const TrainingResult &data)
 
- Public Member Functions inherited from Observer< TestInstanceResult >
virtual void notify (const TestInstanceResult &data)
 

Static Public Member Functions

static std::string getId ()
 
- Static Public Member Functions inherited from Regressifier
static Vector< std::string > getRegisteredRegressifiers ()
 
static Regressifiercreate (const std::string &id)
 
- Static Public Member Functions inherited from GRTBase
static std::string getGRTVersion (bool returnRevision=true)
 
static std::string getGRTRevison ()
 

Protected Member Functions

bool isNAN (const Float &v) const
 
bool setOutputTargets ()
 
bool trainModel (RegressionData &trainingData)
 
bool trainOnlineGradientDescentClassification (const RegressionData &trainingData, const RegressionData &validationData)
 
bool trainOnlineGradientDescentRegression (const RegressionData &trainingData, const RegressionData &validationData)
 
bool loadLegacyModelFromFile (std::fstream &file)
 
Float back_prop (const VectorFloat &inputVector, const VectorFloat &targetVector, const Float alpha, const Float beta)
 
VectorFloat feedforward (VectorFloat data)
 
void feedforward (const VectorFloat &data, VectorFloat &inputNeuronsOutput, VectorFloat &hiddenNeuronsOutput, VectorFloat &outputNeuronsOutput)
 
- Protected Member Functions inherited from Regressifier
bool saveBaseSettingsToFile (std::fstream &file) const
 
bool loadBaseSettingsFromFile (std::fstream &file)
 
- Protected Member Functions inherited from MLBase
bool saveBaseSettingsToFile (std::fstream &file) const
 
bool loadBaseSettingsFromFile (std::fstream &file)
 

Protected Attributes

UINT numInputNeurons
 
UINT numHiddenNeurons
 
UINT numOutputNeurons
 
Neuron::Type inputLayerActivationFunction
 
Neuron::Type hiddenLayerActivationFunction
 
Neuron::Type outputLayerActivationFunction
 
UINT trainingMode
 
Float momentum
 
Float gamma
 
Float trainingError
 
MinMax outputTargets
 
bool initialized
 
Vector< NeuroninputLayer
 
Vector< NeuronhiddenLayer
 
Vector< NeuronoutputLayer
 
Vector< VectorFloattrainingErrorLog
 
bool classificationModeActive
 
bool useNullRejection
 
UINT predictedClassLabel
 
Float nullRejectionThreshold
 
Float nullRejectionCoeff
 
Float maxLikelihood
 
VectorFloat classLikelihoods
 
VectorFloat inputNeuronsOutput
 
VectorFloat hiddenNeuronsOutput
 
VectorFloat outputNeuronsOutput
 
VectorFloat deltaO
 
VectorFloat deltaH
 
- Protected Attributes inherited from Regressifier
std::string regressifierType
 
VectorFloat regressionData
 
Vector< MinMaxinputVectorRanges
 
Vector< MinMaxtargetVectorRanges
 
- Protected Attributes inherited from MLBase
bool trained
 
bool useScaling
 
bool converged
 
DataType inputType
 
DataType outputType
 
BaseType baseType
 
UINT numInputDimensions
 
UINT numOutputDimensions
 
UINT numTrainingIterationsToConverge
 
UINT minNumEpochs
 
UINT maxNumEpochs
 
UINT batchSize
 
UINT validationSetSize
 
UINT numRestarts
 
Float learningRate
 
Float minChange
 
Float rmsTrainingError
 
Float rmsValidationError
 
Float totalSquaredTrainingError
 
Float validationSetAccuracy
 
bool useValidationSet
 
bool randomiseTrainingOrder
 
VectorFloat validationSetPrecision
 
VectorFloat validationSetRecall
 
Random random
 
Vector< TrainingResulttrainingResults
 
TrainingResultsObserverManager trainingResultsObserverManager
 
TestResultsObserverManager testResultsObserverManager
 
TrainingLog trainingLog
 
TestingLog testingLog
 
- Protected Attributes inherited from GRTBase
std::string classId
 Stores the name of the class (e.g., MinDist)
 
DebugLog debugLog
 
ErrorLog errorLog
 
InfoLog infoLog
 
WarningLog warningLog
 

Additional Inherited Members

- Static Protected Member Functions inherited from Regressifier
static StringRegressifierMapgetMap ()
 

Detailed Description

Constructor & Destructor Documentation

MLP::MLP ( )

Default Constructor

Definition at line 34 of file MLP.cpp.

MLP::MLP ( const MLP rhs)

Copy Constructor

Parameters
rhsanother instance of a MLP that will be copied to this instance

Definition at line 58 of file MLP.cpp.

MLP::~MLP ( )
virtual

Default Destructor

Definition at line 63 of file MLP.cpp.

Member Function Documentation

Neuron::Type MLP::activationFunctionFromString ( const std::string  activationName) const

Gets the activation function value from a string.

Parameters
activationNamethe activation function as a string
Returns
returns the activation function

Definition at line 1623 of file MLP.cpp.

std::string MLP::activationFunctionToString ( const Neuron::Type  activationFunction) const

Gets a string representation of the activation function

Parameters
activationFunctionthe 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 1599 of file MLP.cpp.

Float MLP::back_prop ( const VectorFloat inputVector,
const VectorFloat targetVector,
const Float  alpha,
const Float  beta 
)
protected

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

Parameters
inputVectorthe input Vector to use for back propagation
targetVectorthe target Vector to use for back propagation
alphathe training rate
betathe momentum
Returns
returns the squared error for the current training example

Definition at line 851 of file MLP.cpp.

bool 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 1039 of file MLP.cpp.

bool MLP::clear ( )
virtual

Clears any previous model or settings.

Returns
returns true if the MLP was cleared, false otherwise

Reimplemented from Regressifier.

Definition at line 291 of file MLP.cpp.

bool 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
regressifiera 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 Regressifier.

Definition at line 103 of file MLP.cpp.

VectorFloat MLP::feedforward ( VectorFloat  data)
protected

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

Parameters
datathe input Vector to use for the feedforward
Returns
returns a new Vector of the results from the feedforward step

Definition at line 924 of file MLP.cpp.

void MLP::feedforward ( const VectorFloat data,
VectorFloat inputNeuronsOutput,
VectorFloat hiddenNeuronsOutput,
VectorFloat outputNeuronsOutput 
)
protected

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

Parameters
datathe input Vector to use for the feedforward
inputNeuronsOutputthe results of the input layer
hiddenNeuronsOutputthe results of the hidden layer
outputNeuronsOutputthe results of the output layer

Definition at line 966 of file MLP.cpp.

VectorFloat 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 1588 of file MLP.cpp.

bool 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 1542 of file MLP.cpp.

VectorFloat 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 1583 of file MLP.cpp.

Float 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 1534 of file MLP.cpp.

Vector< Neuron > MLP::getHiddenLayer ( ) const

Returns the neurons for the hidden layer.

Returns
returns a Vector of neurons for the hidden layer

Definition at line 1554 of file MLP.cpp.

Neuron::Type MLP::getHiddenLayerActivationFunction ( ) const

Gets the hidden layer activation function.

Returns
returns the hidden layer activation function

Definition at line 1514 of file MLP.cpp.

std::string MLP::getId ( )
static

Gets a string that represents the MLP class.

Returns
returns a string containing the ID of this class

Definition at line 29 of file MLP.cpp.

Vector< Neuron > MLP::getInputLayer ( ) const

Returns the neurons for the input layer.

Returns
returns a Vector of neurons for the input layer

Definition at line 1550 of file MLP.cpp.

Neuron::Type MLP::getInputLayerActivationFunction ( ) const

Gets the input layer activation function.

Returns
returns the input layer activation function

Definition at line 1510 of file MLP.cpp.

Float 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 1578 of file MLP.cpp.

Float MLP::getMomentum ( ) const

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

Returns
returns the momentum

Definition at line 1530 of file MLP.cpp.

Float 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 1570 of file MLP.cpp.

bool 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 1566 of file MLP.cpp.

Float 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 1574 of file MLP.cpp.

UINT 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 1492 of file MLP.cpp.

UINT MLP::getNumHiddenNeurons ( ) const

Gets the number of hidden neurons.

Returns
returns the number of hidden neurons

Definition at line 1502 of file MLP.cpp.

UINT MLP::getNumInputNeurons ( ) const

Gets the number of input neurons.

Returns
returns the number of input neurons

Definition at line 1498 of file MLP.cpp.

UINT MLP::getNumOutputNeurons ( ) const

Gets the number of output neurons.

Returns
returns the number of output neurons

Definition at line 1506 of file MLP.cpp.

UINT 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 1522 of file MLP.cpp.

Vector< Neuron > MLP::getOutputLayer ( ) const

Returns the neurons for the output layer.

Returns
returns a Vector of neurons for the output layer

Definition at line 1558 of file MLP.cpp.

Neuron::Type MLP::getOutputLayerActivationFunction ( ) const

Gets the output layer activation function.

Returns
returns the output layer activation function

Definition at line 1518 of file MLP.cpp.

UINT 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 1594 of file MLP.cpp.

bool 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 1546 of file MLP.cpp.

Float 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 1538 of file MLP.cpp.

Vector< VectorFloat > MLP::getTrainingLog ( ) const

Returns a Vector of VectorFloat 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 1562 of file MLP.cpp.

Float MLP::getTrainingRate ( ) const

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

Returns
returns the training rate

Definition at line 1526 of file MLP.cpp.

MLP::GRT_DEPRECATED_MSG ( "setNumRandomTrainingIterations() is  deprecated,
use setNumRestarts() instead"  ,
bool   setNumRandomTrainingIterationsconst UINT numRandomTrainingIterations 
)
Deprecated:
use setNumRestarts() instead 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
numRandomTrainingIterationsthe 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
bool 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
numInputNeuronsthe number of input neurons (should match the number of input dimensions in your training data)
numHiddenNeuronsthe number of hidden neurons
numOutputNeuronsthe 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
Examples:
RegressionModulesExamples/MLPRegressionExample/MLPRegressionExample.cpp.

Definition at line 214 of file MLP.cpp.

bool MLP::init ( const UINT  numInputNeurons,
const UINT  numHiddenNeurons,
const UINT  numOutputNeurons,
const Neuron::Type  inputLayerActivationFunction,
const Neuron::Type  hiddenLayerActivationFunction,
const Neuron::Type  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
numInputNeuronsthe number of input neurons (should match the number of input dimensions in your training data)
numHiddenNeuronsthe number of hidden neurons
numOutputNeuronsthe number of output neurons (should match the number of target dimensions in your training data)
inputLayerActivationFunctionthe activation function to use for the input layer
hiddenLayerActivationFunctionthe activation function to use for the input layer
outputLayerActivationFunctionthe activation function to use for the input layer
Returns
returns true if the MLP was initialized, false otherwise

Definition at line 218 of file MLP.cpp.

bool MLP::load ( std::fstream &  file)
virtual

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

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

Reimplemented from MLBase.

Definition at line 1148 of file MLP.cpp.

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

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

Parameters
rhsanother instance of a MLP
Returns
returns a reference to this instance of the MLP

Definition at line 67 of file MLP.cpp.

bool MLP::predict_ ( VectorFloat 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
inputVectorthe input Vector to classify or perform regression on
Returns
returns true if the prediction/regression was performed, false otherwise

Reimplemented from MLBase.

Definition at line 155 of file MLP.cpp.

bool 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 MLBase.

Definition at line 307 of file MLP.cpp.

void 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 993 of file MLP.cpp.

bool MLP::save ( std::fstream &  file) const
virtual

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

Parameters
filea reference to the file the MLP model will be saved to
Returns
returns true if the model was saved successfully, false otherwise

Reimplemented from MLBase.

Definition at line 1074 of file MLP.cpp.

bool MLP::setGamma ( const Float  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
gammathe 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 1709 of file MLP.cpp.

bool MLP::setHiddenLayerActivationFunction ( const Neuron::Type  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
activationFunctionthe 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 1666 of file MLP.cpp.

bool MLP::setInputLayerActivationFunction ( const Neuron::Type  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
activationFunctionthe 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 1650 of file MLP.cpp.

bool MLP::setMomentum ( const Float  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
momentumthe momentum value used during the training phase, must be greater than zero
Returns
returns true if the value was updated successfully, false otherwise
Examples:
RegressionModulesExamples/MLPRegressionExample/MLPRegressionExample.cpp.

Definition at line 1701 of file MLP.cpp.

bool 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
useNullRejectionif true then null rejection will be used
Returns
returns true if the value was updated successfully, false otherwise

Definition at line 1728 of file MLP.cpp.

bool MLP::setNullRejectionCoeff ( const Float  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
nullRejectionCoeffthe new null rejection threshold
Returns
returns true if the value was updated successfully, false otherwise

Definition at line 1733 of file MLP.cpp.

bool MLP::setOutputLayerActivationFunction ( const Neuron::Type  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
activationFunctionthe 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 1682 of file MLP.cpp.

bool MLP::setTrainingRate ( const Float  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
trainingRatethe 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 1697 of file MLP.cpp.

bool 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
trainingDatathe training data that will be used to train the classification model
Returns
returns true if the MLP model was trained, false otherwise

Reimplemented from MLBase.

Definition at line 121 of file MLP.cpp.

bool 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
trainingDatathe training data that will be used to train the regression model
Returns
returns true if the MLP model was trained, false otherwise

Reimplemented from MLBase.

Definition at line 146 of file MLP.cpp.

bool MLP::validateActivationFunction ( const Neuron::Type  avactivationFunction) const

Validates if the activationFunction is valid.

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

Definition at line 1645 of file MLP.cpp.


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