| IGLib 1.4 The IGLib base library for development of numerical, technical and business applications.

- Main Page
- Namespaces
- Classes
- Files
- Directories

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Private Attributes

# IG::Neural::NeuralApproximatorBase Class Reference

Base class for neural network approximators. More...

Inheritance diagram for IG::Neural::NeuralApproximatorBase:
[legend]
Collaboration diagram for IG::Neural::NeuralApproximatorBase:
[legend]

List of all members.

## Public Member Functions
| NeuralApproximatorBase ()
virtual int | GetNumNeuronsInHiddenLayer (int whichLayer)
| Returns the number of neurons in the specified hidden layer. Hidden layers are those not containing input or output neurons.
virtual void | SetNumNeuronsInHiddenLayer (int whichLayer, int numNeurons)
| Sets the number of neurons in the specified hidden layer. Hidden layers are those not containing input or output neurons.
virtual void | SetHiddenLayers (params int[] numNeurons)
| Sets the numbers of neurons in each hidden layer. Can be called with table of integers as argument, kor with variable number of integer parameters. Numbers are set by an array of integers in which each element contains the number of neurons in the corresponding hidden layer (indexed from 0). Hidden layers are those not containing input or output neurons.
abstract void | PrepareNetwork ()
| Prepares neural network for use. If networks have not yet been created accordinfg to internal data, they are created. If networks are already prepared then this method does nothing.
abstract void | CreateNetwork ()
| Creates the neural network anew. It the network already exists on the current object, it is discarded.
abstract void | ResetNetwork ()
| Resets the neural network.
abstract void | DestroyNetwork ()
| Destroys the neural network.
string | GetNetworkFilePath (string fileOrDirectoryPath, int whichNetwork)
| Returns an absolute path to the file for storing the specified neural network contained on the current object, with respect to suggested file path and index of the network. The returned path is in the same directory as suggested file path and has the same file extension (if any). If the suggested path represents a directory, then some default suggested path is assumed. If there is only one network then the returned file path is the same as the suggested one (or the same as default file name within the suggested directory, if a directory path is proposed).
void | SaveNetwork (string filePath)
| Saves the state of the neural network to the specified file. If the file already exists, its contents are overwritten.
void | LoadNetwork (string filePath)
| Restores neural network from a file where it has been stored before.
void | SetTrainingAndVerificationData (SampledDataSet trainingData, SampledDataSet verificationData)
void | GetTrainingData (ref SampledDataSet trainingData)
void | GetVerificationData (ref SampledDataSet veerificationData)
void | GetTrainingAndVerificationData (ref SampledDataSet trainingData, ref SampledDataSet verificationData)
void | SaveTrainingDataJson (string filePath)
| Saves network's training data to the specified JSON file. File is owerwritten if it exists.
void | LoadTrainingDataJson (string filePath)
| Restores training data from the specified file in JSON format.
void | SetNeuronsInputRange (double min, double max)
| Sets the neurons input range. Bounds for all input neurons are set equally.
void | SetNeuronsOutputRange (double min, double max)
| Sets the neurons output range. Bounds for all output neurons are set equally.
void | RecalculateInputDataBounds ()
| Recalculates input data bounds by taking into account the training data set of the current object.
void | RecalculateOutputDataBounds ()
| Recalculates output data bounds by taking into account the training data set of the current object.
void | RecalculateDataBounds ()
| Recalculates input and output data bounds by taking into account the training data set of the current object.
void | RecalculateInputDataBounds (SampledDataSet trainingData)
| Recalculates input data bounds by taking into account the specified training data set.
void | RecalculateOutputDataBounds (SampledDataSet trainingData)
| Recalculates output data bounds by taking into account the specified training data set.
void | RecalculateDataBounds (SampledDataSet trainingData)
| Recalculates input and output data bounds by taking into account the specified training data set.
void | GetErrorsTrainingRms (ref IVector errors)
| Calculates the RMS (root mean square) of the errors of output values for the training elements of the training set (this excludes verification points).
void | GetErrorsVerificationRms (ref IVector errors)
| Calculates the RMS (root mean square) of the errors of output values for the verification elements of the training set.
void | GetErrorsTrainingMax (ref IVector errors)
| Calculates the maximum absolute errors of output values for the training elements of the training set (this excludes verification points).
void | GetErrorsVerificationMax (ref IVector errors)
| Calculates the maximum absolute errors of output values for the verification elements of the training set.
void | GetErrorsTrainingMeanAbs (ref IVector errors)
| Calculates the mean absolute errors of output values for the training elements of the training set (this excludes verification points).
void | GetErrorsVerificationMeanAbs (ref IVector errors)
| Calculates the mean absolute errors of output values for the verification elements of the training set.
virtual void | InvalidateTrainingDependencies ()
| Invalidates all data that must be recalculated after training of the network is done. This method is called after training or additional training of the network is performed. Invalidation is achieved throughthe the appropriate flags.
virtual void | InvalidateTrainingDataDependencies ()
| Invalidates all data that must be re-calculated after training data changes. This method is called after training data is modified. Invalidation is achieved throughthe the appropriate flags.
virtual void | InvalidateNetworkDependencies ()
| Invalidates all data that must be re-calculated after the neural network itself changes. This method must be called after the internal neural network is re-defined (or are re-defined). Invalidation is achieved throughthe the appropriate flags.
void | TrainNetwork (int numEpochs)
| Trains neural network wiht the specified data, performing the specified number of epochs.
void | TrainNetworkMultiple (int numEpochs, int numIterations)
| Performs a specified number of training iterations where the specified number of epochs are run in each iteration.
void | TrainNetworkMultiple (int NumIterations)
| Performs a specified number of training iterations where the prescribed number of epochs (contained in the EpochsInBundle property) are run in each iteration.
virtual void | TrainNetwork ()
| Trains neural network until stopping criteria are met (in terms of errors and number of epochs performed.
virtual bool | StopTrainingCriteriaMet ()
| Returns true if the stopping criteria for training is met, with respect to current settings, errors and number of epochs already performed, and false otherwise.
abstract void | CalculateOutput (IVector input, ref IVector output)
| Calculates and returns the approximated outputs corresponding to the specified inputs, by using the current neural network.
virtual double | CalculateOutput (IVector input, int whichElement)
| Calculates and returns the specified output by using the neural network.
virtual void | CalculateOutput (IVector input, int[] indices, ref IVector filteredOutput)
| Calculates and returns the required output values corresponding to the specified inputs, by using the current neural network(s).
override string | ToString ()
| Returns string describing the current neural network approximator.
void | SaveTrainingDataJson_To_delete (string filePath)
| Saves network's training data to the specified JSON file. File is owerwritten if it exists.
void | LoadTrainingDataJson_To_Delete (string filePath)
| Restores training data from the specified file in JSON format.
void | TestMapping ()
| Test back and forth mapping (scaling and shifting) from actual data to data prepared for training, and vice versa (checks if transformed data falls withi the prescribed ranges and if backward transformation yields the same result as forward transformation). Testing is performed on all data from the TrainingData property, including verification elements.
## Static Public Member Functions
static void | TestTypeCreation ()
| Tests whether creation of a neural approximator according to a specified type can be successful.
static void | CalculateErrorsRms (int dimOutput, IVector[] prescribed, IVector[] calculated, ref IVector errors)
| Calculates error measures - RMS (root mean square) of the differences - for the specified arrays of prescribed and calculated output values in a set of sampling points.
static void | CalculateErrorsMeanAbs (int dimOutput, IVector[] prescribed, IVector[] calculated, ref IVector errors)
| Calculates error measures - mean absolute value of the differences - for the specified arrays of prescribed and calculated output values in a set of sampling points.
static void | CalculateErrorsMax (int dimOutput, IVector[] prescribed, IVector[] calculated, ref IVector errors)
| Calculates error measures - maximum absolute value of the differences - for the specified arrays of prescribed and calculated output values in a set of sampling points.
static void | SaveJson (INeuralApproximator approximator, string filePath)
| Saves a neural network approximator to a file. If the neural netwoek is trained then internal state is also saved to a file.
static void | SaveJson (INeuralApproximator approximator, string filePath, bool saveInternalState)
| Saves a neural network approximator to a file.
static void | LoadJson (string filePath, ref INeuralApproximator approximatorRestored)
| Loads network from a file.
static void | ExampleSaveNetwork (string directoryPath, string fileName, string internalStateFileName)
| Example of saving an entire trained neural network to a file, and then restoring it from a file. Network internal state is saved by the SaveNetwork() method that is specific to the type of the network, therefore it is saved to a separate file. The path of this file is savad with the network approximator object itself. Network is saved only once.
static void | ExampleSaveNetwork (string directoryPath, string fileName, string internalStateFileName, bool saveRestored)
| Example of saving an entire trained neural network to a file, and then restoring it from a file. Network internal state is saved by the SaveNetwork() method that is specific to the type of the network, therefore it is saved to a separate file. The path of this file is savad with the network approximator object itself. If the saveRestored flag parameter is true then the restored file ia saved again for comparison.
static INeuralApproximator | ExampleQuadratic ()
| Example demonstrating usage of the neural network approximator. A quadratic function with random coefficients is sampled with enough samples to exactly specify function coefficients, a part of samples is randomly designated as verification points, then neural network is created and trained on training samples, and it is verified how close the obtained approximation matches actual function in verification points.
static INeuralApproximator | ExampleQuadratic (int inputLength, int outputLength)
| Example demonstrating usage of the neural network approximator. A quadratic function with random coefficients is sampled with enough samples to exactly specify function coefficients, a part of samples is randomly designated as verification points, then neural network is created and trained on training samples, and it is verified how close the obtained approximation matches actual function in verification points.
static INeuralApproximator | ExampleQuadratic (int inputLength, int outputLength, int outputLevel, int maxEpochs)
| Example demonstrating usage of the neural network approximator. A quadratic function with random coefficients is sampled with enough samples to exactly specify function coefficients, a part of samples is randomly designated as verification points, then neural network is created and trained on training samples, and it is verified how close the obtained approximation matches actual function in verification points.
## Protected Member Functions
void | SetRmsToleranceRelstiveToRange ()
| Updates the tolerances on RMS errors of outputs according to the relative tolerances (defined by ToleranceRmsRelativeToRange) and the ranges in output data (defined by OutputDataBounds), if both are defined.
void | SetMaxToleranceRelstiveToRange ()
| Updates the tolerances on max. abs. errors of outputs according to the relative tolerances (defined by ToleranceMaxRelativeToRange) and the ranges in output data (defined by OutputDataBounds), if both are defined.
abstract void | PrepareNetworksArray ()
| Prepares the networks array (allocates it if necessary) for storing all neural networks of the current object.
abstract void | SaveNetworkSpecific (string filePath)
| Saves the state of the neural network to the specified file. If the file already exists, its contents are overwritten.
abstract void | LoadNetworkSpecific (string filePath)
| Restores neural network from a file where it has been stored before.
virtual double | MapInput (int componentIndex, double value)
| Maps (scales & shifts) and returns specific input value to the value prepared for the corresponding input neuron.
virtual double | MapFromNeuralInput (int componentIndex, double value)
| Inverse maps (scales & shifts) and returns specific input value back from the neural input to the actual input.
virtual void | MapInput (IVector values, ref IVector mappedValues)
| Maps (scales & shifts) vector of input values to the vector of neuron inputs.
virtual void | MapFromNeuralInput (IVector values, ref IVector mappedValues)
| Inverse maps (scales & shifts) vector of neural input values back to the vector of actual inputs.
virtual double | MapOutput (int componentIndex, double value)
| Maps (scales & shifts) and returns specific output value to the output value of the corresponding output neuron.
virtual double | MapFromNeuralOutput (int componentIndex, double value)
| Inverse maps (scales & shifts) and returns specific output value back from the neural output to the actual output.
virtual void | MapOutput (IVector values, ref IVector mappedValues)
| Maps (scales & shifts) vector of output values to the vector of neuron outputs.
virtual void | MapFromNeuralOutput (IVector values, ref IVector mappedValues)
| Inverse maps (scales & shifts) vector of neural output values back to the vector of actual outputs.
void | CalculateTrainingVerificationOutputs (bool calculateTrainingOutputs, bool calculateVerificationOutputs)
| Calculates outputs in training points contained in training set, either in training points, in verification points, or both.
void | CalculateTrainingOutputs ()
| Calculates outputs in training points of the training data set (this excludes verification points).
void | CalculateVerificationOutputs ()
| Calculates outputs in verification points of the training data set.
virtual void | PrepareErrorData (ref int dimOutput, ref IVector[] prescribed, ref IVector[] calculated, bool takeTrainingPoints, bool takeVerificationPoints)
| Prepares data for calculation of various error measures over training points or in verification points after training of the neural network(s).
abstract void | PrepareInternalTrainingData ()
| Prepares internal training data that is needed by the native training algorithm. When overridden, this method must set the InternalTrainingDataPrepared flag to true.
abstract void | TrainNetworkSpecific (int numEpochs)
| Trains neural network wiht the specified data, performing the specified number of epochs. This method must be implemented in derived classes and is specific to specific network type.
## Protected Attributes
const string | _defaultNetworkFilename = "network.dat"
double | _defaultNeuronMinInput = -2
double | _defaultNeuronMaxInput = 2
double | _defaultNeuronMinOutput = -1.0
double | _defaultNeuronMaxOutput = 1.0
List< IVector > | _calculatedOutputs = null
| List of calculated outputs in points contained in (all) training data.
bool | _calculateVerificationErrors = false
Vector | _auxErrors = null
## Properties
object | Lock`[get]`
| This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.
int | OutputLevel`[get, set]`
| Level of output printed to console when performing actions.
virtual bool | MultipleNetworks`[get, set]`
| Flag indicating whether multiple neural networks are used to approximate multiple outputs (one network for each output)
virtual int | InputLength`[get, set]`
| Gets or sets the number of input neurons.
virtual int | OutputLength`[get, set]`
| Gets or sets the number of output neurons.
virtual int[] | NumHiddenNeurons`[get, set]`
| Gets or sets the numbers of neurons in each hidden layer. When setting, contents of array are copied, not only a reference. Numbers are set by an array of integers in which each element contains the number of neurons in the corresponding hidden layer (indexed from 0). Hidden layers are those not containing input or output neurons.
virtual int | NumHiddenLayers`[get, set]`
| Gets or sets the number of hidden layers of the neural network (these are layers that don't contain input or output neurons).
bool | NetworkPrepared`[get, set]`
| Gets a flag telling whether the network is prepared for operation (training and calculation of output).
double | SigmoidAlphaValue`[get, set]`
| Alpha value specifying the shape of the activation function.
double | LearningRate`[get, set]`
| Gets or sets learning rate.
double | Momentum`[get, set]`
| Gets or sets momentum.
int | EpochCount`[get, set]`
| Number of learning epochs performed up to the current moment.
int | MaxEpochs`[get, set]`
| Maximal number of epochs in training.
int | EpochsInBundle`[get, set]`
| Number of epochs in a single training bundle. This number of epochs is performed at once when training, without checking convergence criteria between. Larger value means slightly more efficient training (because of less checks) but rougher criteria checks.
IVector | ToleranceRms`[get, set]`
| Tolerances on RMS errors of outputs over training points. Training will continue until error becomes below tolerance or until maximal number of epochs is reached. If less or equal than 0 then this tolerance is not taken into account.
IVector | ToleranceMax`[get, set]`
| Tolerances on maximal errors of outputs over training points. Training will continue until error becomes below tolerance or until maximal number of epochs is reached. If less or equal than 0 then this tolerance is not taken into account.
IVector | ToleranceRmsRelativeToRange`[get, set]`
| Relative tolerances on RMS errors of outputs over training points, relative to the correspoinding ranges of output data.
double | ToleranceRmsRelativeToRangeScalar`[get, set]`
| Scalar through which all components of the Relative tolerances on RMS errors of outputs can be set to the same value.
IVector | ToleranceMaxRelativeToRange`[get, set]`
| Relative tolerances on max. abs. errors of outputs over training points, relative to the correspoinding ranges of output data.
double | ToleranceMaxRelativeToRangeScalar`[get, set]`
| Scalar through which all components of the Relative tolerances on max. abs. errors of outputs can be set to the same value.
List< int > | EpochNumbers`[get, set]`
| List of epoch numbers at which convergence data was sampled. Saved after every set of epochs.
List< IVector > | ConvergenceErrorsTrainingRmsList`[get, set]`
| Convergence List of RMS errors calculated on training data. Saved after every set of epochs.
List< IVector > | ConvergenceErrorsTrainingMaxList`[get, set]`
| Convergence List of Maximum errors calculated on training data. Saved after every set of epochs.
List< IVector > | ConvergenceErrorsVerificationRmsList`[get, set]`
| Convergence List of Rms errors calculated on verification data. Saved after every set of epochs.
List< IVector > | ConvergenceErrorsVerificationMaxList`[get, set]`
| Convergence List of Maximum errors calculated on verification data. Saved after every set of epochs.
bool | SaveConvergenceRms`[get, set]`
| Flag to enable RMS error convergence colection.
string | NeuralApproximatorType`[get]`
| Gets string representation of type of the current object. This is used e.g. in deserialization in order to prevent that wrong type of internal representation would be read in.
string | NetworkStateFilePath`[get, set]`
| Path where the curren network state has been saved, or null if the current state has not been saved yet. The SaveFile methods takes care that the file path is stored when network state is saved. InvalidateTrainingDependencies() takes care that this file path is set to null if network state has changed after last save.
string | NetworkStateRelativePath`[get, set]`
| Relative path where the curren network state has been saved. Auxiliary property used in deserialization. When the whole Neural network approximator is saved to a file, tis path is updated in such a way that it points to the fiele where the network state has been saved, but relative to the path where the whole approximator is saved. This enables restore of the saved network state at a later time, even if the containing directory has moved within the file system or has even been copied to another system.
SampledDataSet | TrainingData`[get, set]`
| Gets or sets the training data.
virtual IndexList | VerificationIndices`[get, set]`
| Gets or sets indices of training data elements that are used for verification of how precise appeoximation is. These elements are excluded from training of neural network.
virtual IBoundingBox | InputDataBounds`[get, set]`
| Bounds on input data, used for scaling from actual input to input used by neural network. Scaling is performed because of the bound codomain and image of activation functions.
virtual IBoundingBox | OutputDataBounds`[get, set]`
| Bounds on output data, used for scaling from actual output to output produced by neural network. Scaling is performed because of the bound codomain and image of activation functions.
virtual double | InputBoundsSafetyFactor`[get, set]`
| Safety factor by which interval lenghts of input data bounds are enlarged after bounds are automatically determined from the range of input data in the training set. Setter re-calculated the input data bounds and therefore invalidates training data dependencies.
virtual double | OutputBoundsSafetyFactor`[get, set]`
| Safety factor by which interval lenghts of output data bounds are enlarged after bounds are automatically determined from the range of output data in the training set. Setter re-calculated the output data bounds and therefore invalidates training data dependencies.
virtual IBoundingBox | InputNeuronsRange`[get, set]`
| Gets the range in which data should be for input neurons, used for scaling from actual input to input used by neural network. This depends on the activation function.
virtual IBoundingBox | OutputNeuronsRange`[get, set]`
| Gets the range of the data output from output neurons, used for scaling from actual output to output produced by neural network. This will normally depend on the activation function.
int | NumAllTrainingPoints`[get]`
| Gets number of all training points, including verification points.
virtual int | NumTrainingPoints`[get]`
| Gets number of training points (this excludes verification points).
virtual int | NumVerificationPoints`[get]`
| Gets number of verification points.
bool | TrainingOutputsCalculated`[get, set]`
| Whether outputs have been calculated, after last training, in the training points (excluding verification points).
bool | VerificationOutputsCalculated`[get, set]`
| Whether outputs have been calculated, after last training, in the training points (excluding verification points).
bool | InternalTrainingDataPrepared`[get, set]`
| Gets or sets a flag indicating whether internal training data is prepared. This flag is used internally for signalization between methods that deal with training data.
bool | NetworkTrained`[get, set]`
| Whether network has been trained since the training data was set.
bool | BreakTraining`[get, set]`
| Flags that signalizes (if true) that training should be broken on external request.
bool | CalculateVerificationErrors`[get, set]`
## Private Attributes
object | _mainLock = new object()
int | _outputLevel = Util.OutputLevel
int | _inputLength
int | _outputLength
int[] | _numHiddenNeurons
bool | _multipleNetworks = true
bool | _networkPrepared = false
double | _sigmoidAlphaValue = NeuralTrainingParameters.DefaultSigmoidAlphaValue
double | _learningRate = NeuralTrainingParameters.DefaultLearningRate
double | _momentum = NeuralTrainingParameters.DefaultMomentum
int | _epochCount = 0
bool | _convergenceRmsEnabled = false
int | _maxEpochs = NeuralTrainingParameters.DefaultMaxEpochs
int | _epochsInBundle = NeuralTrainingParameters.DefaultEpochsInBundle
List< IVector > | _convergenceRmsList = null
List< int > | _epochNumbers = null
List< IVector > | _convergenceErrorsTrainingRmsList = null
List< IVector > | _convergenceErrorsTrainingMaxList = null
List< IVector > | _convergenceErrorsVerificationRmsList = null
List< IVector > | _convergenceErrorsVerificationMaxList = null
IVector | _toleranceRms = null
IVector | _toleranceMax = null
IVector | _tolRmsRelative
| Auxiliary properties for defining tolerances in a relative way:
double | _tolRmsRelativeScalar
IVector | _tolMaxRelative
double | _tolMaxRelativeScalar
string | _networkFilePath = null
string | _networkRelativePath = null
SampledDataSet | _trainingData
IndexList | _verificationIndices
IBoundingBox | _inputDataBounds
IBoundingBox | _outputDataBounds
IBoundingBox | _inputNeuronRange
IBoundingBox | _outputNeuronsRange
double | _inputBoundsSafetyFactor = 1.5
double | _outputBoundsSafetyFactor = 2.0
bool | _internalTrainingDataPrepared = false
bool | _trainingOutputsCalculated = false
bool | _verificationOutputsCalculated = false
bool | _networkTrained
List< IVector > | _prescribed = null
List< IVector > | _calculated = null
bool | _breakTraining = false
IVector | _output = null
IVector | _outputFiltered1 = null

## Detailed Description

Base class for neural network approximators.

$A Igor Mar11;

## Constructor & Destructor Documentation

IG::Neural::NeuralApproximatorBase::NeuralApproximatorBase | ( |  | ) | `[inline]`

## Member Function Documentation

virtual int IG::Neural::NeuralApproximatorBase::GetNumNeuronsInHiddenLayer | ( | int | whichLayer | ) | `[inline, virtual]`

Returns the number of neurons in the specified hidden layer. Hidden layers are those not containing input or output neurons.

Parameters:

  whichLayer | Index of the hidden layer for which number of neurons is returned.

Implements IG::Neural::INeuralApproximator.

virtual void IG::Neural::NeuralApproximatorBase::SetNumNeuronsInHiddenLayer | ( | int | whichLayer,
|  | int | numNeurons
| ) |  | `[inline, virtual]`

Sets the number of neurons in the specified hidden layer. Hidden layers are those not containing input or output neurons.

Parameters:

  whichLayer | Index of the hidden layer for which number of neurons is returned.
  numNeurons | Prescribed number of neurons in the specified layer.

Implements IG::Neural::INeuralApproximator.

virtual void IG::Neural::NeuralApproximatorBase::SetHiddenLayers | ( | params int[] | numNeurons | ) | `[inline, virtual]`

Sets the numbers of neurons in each hidden layer. Can be called with table of integers as argument, kor with variable number of integer parameters. Numbers are set by an array of integers in which each element contains the number of neurons in the corresponding hidden layer (indexed from 0). Hidden layers are those not containing input or output neurons.

Parameters:

  numNeurons | Array containing the prescribed numbers of neurons in each hidden layer. Instead of array, a variable number of integer parameters can be specified.

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::SetRmsToleranceRelstiveToRange | ( |  | ) | `[inline, protected]`

Updates the tolerances on RMS errors of outputs according to the relative tolerances (defined by ToleranceRmsRelativeToRange) and the ranges in output data (defined by OutputDataBounds), if both are defined.

void IG::Neural::NeuralApproximatorBase::SetMaxToleranceRelstiveToRange | ( |  | ) | `[inline, protected]`

Updates the tolerances on max. abs. errors of outputs according to the relative tolerances (defined by ToleranceMaxRelativeToRange) and the ranges in output data (defined by OutputDataBounds), if both are defined.

abstract void IG::Neural::NeuralApproximatorBase::PrepareNetworksArray | ( |  | ) | `[protected, pure virtual]`

Prepares the networks array (allocates it if necessary) for storing all neural networks of the current object.

Implemented in IG::Neural::NeuralApproximatorAforge.

abstract void IG::Neural::NeuralApproximatorBase::PrepareNetwork | ( |  | ) | `[pure virtual]`

Prepares neural network for use. If networks have not yet been created accordinfg to internal data, they are created. If networks are already prepared then this method does nothing.

Some things suc as creation of a neural network follow the pattern of lazy evaluation.

Implements IG::Neural::INeuralApproximator.

Implemented in IG::Neural::NeuralApproximatorAforge.

abstract void IG::Neural::NeuralApproximatorBase::CreateNetwork | ( |  | ) | `[pure virtual]`

Creates the neural network anew. It the network already exists on the current object, it is discarded.

Implements IG::Neural::INeuralApproximator.

Implemented in IG::Neural::NeuralApproximatorAforge.

abstract void IG::Neural::NeuralApproximatorBase::ResetNetwork | ( |  | ) | `[pure virtual]`

Resets the neural network.

Implements IG::Neural::INeuralApproximator.

Implemented in IG::Neural::NeuralApproximatorAforge.

abstract void IG::Neural::NeuralApproximatorBase::DestroyNetwork | ( |  | ) | `[pure virtual]`

Destroys the neural network.

Implements IG::Neural::INeuralApproximator.

Implemented in IG::Neural::NeuralApproximatorAforge.

string IG::Neural::NeuralApproximatorBase::GetNetworkFilePath | ( | string | fileOrDirectoryPath,
|  | int | whichNetwork
| ) |  | `[inline]`

Returns an absolute path to the file for storing the specified neural network contained on the current object, with respect to suggested file path and index of the network. The returned path is in the same directory as suggested file path and has the same file extension (if any). If the suggested path represents a directory, then some default suggested path is assumed. If there is only one network then the returned file path is the same as the suggested one (or the same as default file name within the suggested directory, if a directory path is proposed).

Parameters:

  fileOrDirectoryPath | Suggested file or directory path, can be a relative path.
  whichNetwork | Index of the network for which path of the file to store the network is returned.

Returns:

Implements IG::Neural::INeuralApproximator.

static void IG::Neural::NeuralApproximatorBase::TestTypeCreation | ( |  | ) | `[inline, static]`

Tests whether creation of a neural approximator according to a specified type can be successful.

void IG::Neural::NeuralApproximatorBase::SaveNetwork | ( | string | filePath | ) | `[inline]`

Saves the state of the neural network to the specified file. If the file already exists, its contents are overwritten.

Parameters:

  filePath | Path to the file into which the network is saved.

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::LoadNetwork | ( | string | filePath | ) | `[inline]`

Restores neural network from a file where it has been stored before.

Parameters:

  filePath | Path to the file from which the neural network is read.

Implements IG::Neural::INeuralApproximator.

abstract void IG::Neural::NeuralApproximatorBase::SaveNetworkSpecific | ( | string | filePath | ) | `[protected, pure virtual]`

Saves the state of the neural network to the specified file. If the file already exists, its contents are overwritten.

Parameters:

  filePath | Path to the file into which the network is saved.

Implemented in IG::Neural::NeuralApproximatorAforge.

abstract void IG::Neural::NeuralApproximatorBase::LoadNetworkSpecific | ( | string | filePath | ) | `[protected, pure virtual]`

Restores neural network from a file where it has been stored before.

Parameters:

  filePath | Path to the file from which the neural network is read.

Implemented in IG::Neural::NeuralApproximatorAforge.

void IG::Neural::NeuralApproximatorBase::SetTrainingAndVerificationData | ( | SampledDataSet | trainingData,
|  | SampledDataSet | verificationData
| ) |  | `[inline]`

void IG::Neural::NeuralApproximatorBase::GetTrainingData | ( | ref SampledDataSet | trainingData | ) | `[inline]`

void IG::Neural::NeuralApproximatorBase::GetVerificationData | ( | ref SampledDataSet | veerificationData | ) | `[inline]`

void IG::Neural::NeuralApproximatorBase::GetTrainingAndVerificationData | ( | ref SampledDataSet | trainingData,
|  | ref SampledDataSet | verificationData
| ) |  | `[inline]`

void IG::Neural::NeuralApproximatorBase::SaveTrainingDataJson | ( | string | filePath | ) | `[inline]`

Saves network's training data to the specified JSON file. File is owerwritten if it exists.

Parameters:

  filePath | Path to the file where training data is saved.

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::LoadTrainingDataJson | ( | string | filePath | ) | `[inline]`

Restores training data from the specified file in JSON format.

Parameters:

  filePath | File from which training data is restored.

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::SetNeuronsInputRange | ( | double | min,
|  | double | max
| ) |  | `[inline]`

Sets the neurons input range. Bounds for all input neurons are set equally.

Parameters:

  min | Lower bound for all input neurons.
  max | Upper bound for all input neurons.

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::SetNeuronsOutputRange | ( | double | min,
|  | double | max
| ) |  | `[inline]`

Sets the neurons output range. Bounds for all output neurons are set equally.

Parameters:

  min | Lower bound for all output neurons.
  max | Upper bound for all output neurons.

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::RecalculateInputDataBounds | ( |  | ) | `[inline]`

Recalculates input data bounds by taking into account the training data set of the current object.

Training data dependencies are invalidated by this method because setting bounds invalidates them.

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::RecalculateOutputDataBounds | ( |  | ) | `[inline]`

Recalculates output data bounds by taking into account the training data set of the current object.

Training data dependencies are invalidated by this method because setting bounds invalidates them.

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::RecalculateDataBounds | ( |  | ) | `[inline]`

Recalculates input and output data bounds by taking into account the training data set of the current object.

Training data dependencies are invalidated by this method because setting bounds invalidates them.

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::RecalculateInputDataBounds | ( | SampledDataSet | trainingData | ) | `[inline]`

Recalculates input data bounds by taking into account the specified training data set.

Parameters:

  trainingData | Training data set accourding to which input bounds are adjusted.

Training data dependencies are invalidated by this method because setting bounds invalidates them.

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::RecalculateOutputDataBounds | ( | SampledDataSet | trainingData | ) | `[inline]`

Recalculates output data bounds by taking into account the specified training data set.

Parameters:

  trainingData | Training data set accourding to which output bounds are adjusted.

Training data dependencies are invalidated by this method because setting bounds invalidates them.

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::RecalculateDataBounds | ( | SampledDataSet | trainingData | ) | `[inline]`

Recalculates input and output data bounds by taking into account the specified training data set.

Parameters:

  trainingData | Training data set accourding to which input and output bounds are adjusted.

Training data dependencies are invalidated by this method because setting bounds invalidates them.

Implements IG::Neural::INeuralApproximator.

virtual double IG::Neural::NeuralApproximatorBase::MapInput | ( | int | componentIndex,
|  | double | value
| ) |  | `[inline, protected, virtual]`

Maps (scales & shifts) and returns specific input value to the value prepared for the corresponding input neuron.

Parameters:

  componentIndex | Index of the input value within the input vector.
  value | Value that is mapped.

Returns:
  Input value mapped for the input to neural network.

virtual double IG::Neural::NeuralApproximatorBase::MapFromNeuralInput | ( | int | componentIndex,
|  | double | value
| ) |  | `[inline, protected, virtual]`

Inverse maps (scales & shifts) and returns specific input value back from the neural input to the actual input.

Parameters:

  componentIndex | Index of the input value within the input vector.
  value | Value that is mapped back from neural input.

Returns:
  Input value mapped back from the neural input.

virtual void IG::Neural::NeuralApproximatorBase::MapInput | ( | IVector | values,
|  | ref IVector | mappedValues
| ) |  | `[inline, protected, virtual]`

Maps (scales & shifts) vector of input values to the vector of neuron inputs.

Parameters:

  values | Vector of input values to be mapped.
  mappedValues | Vector where mapped values are stored.

virtual void IG::Neural::NeuralApproximatorBase::MapFromNeuralInput | ( | IVector | values,
|  | ref IVector | mappedValues
| ) |  | `[inline, protected, virtual]`

Inverse maps (scales & shifts) vector of neural input values back to the vector of actual inputs.

Parameters:

  values | Vector of neural inputs to be mapped.
  mappedValues | Vector where inverse mapped values are stored.

virtual double IG::Neural::NeuralApproximatorBase::MapOutput | ( | int | componentIndex,
|  | double | value
| ) |  | `[inline, protected, virtual]`

Maps (scales & shifts) and returns specific output value to the output value of the corresponding output neuron.

Parameters:

  componentIndex | Index of the output value within the output vector.
  value | Value that is mapped.

Returns:
  Output value mapped for the output to neural network.

virtual double IG::Neural::NeuralApproximatorBase::MapFromNeuralOutput | ( | int | componentIndex,
|  | double | value
| ) |  | `[inline, protected, virtual]`

Inverse maps (scales & shifts) and returns specific output value back from the neural output to the actual output.

Parameters:

  componentIndex | Index of the output value within the output vector.
  value | Value that is mapped back from neural output.

Returns:
  Output value mapped back from the neural output.

virtual void IG::Neural::NeuralApproximatorBase::MapOutput | ( | IVector | values,
|  | ref IVector | mappedValues
| ) |  | `[inline, protected, virtual]`

Maps (scales & shifts) vector of output values to the vector of neuron outputs.

Parameters:

  values | Vector of output values to be mapped.
  mappedValues | Vector where mapped values are stored.

virtual void IG::Neural::NeuralApproximatorBase::MapFromNeuralOutput | ( | IVector | values,
|  | ref IVector | mappedValues
| ) |  | `[inline, protected, virtual]`

Inverse maps (scales & shifts) vector of neural output values back to the vector of actual outputs.

Parameters:

  values | Vector of neural outputs to be mapped.
  mappedValues | Vector where inverse mapped values are stored.

void IG::Neural::NeuralApproximatorBase::CalculateTrainingVerificationOutputs | ( | bool | calculateTrainingOutputs,
|  | bool | calculateVerificationOutputs
| ) |  | `[inline, protected]`

Calculates outputs in training points contained in training set, either in training points, in verification points, or both.

Parameters:

  calculateTrainingOutputs | Whether outputs are calculated in training points.
  calculateVerificationOutputs | Whether outputs are calculated in verification points.

void IG::Neural::NeuralApproximatorBase::CalculateTrainingOutputs | ( |  | ) | `[inline, protected]`

Calculates outputs in training points of the training data set (this excludes verification points).

void IG::Neural::NeuralApproximatorBase::CalculateVerificationOutputs | ( |  | ) | `[inline, protected]`

Calculates outputs in verification points of the training data set.

static void IG::Neural::NeuralApproximatorBase::CalculateErrorsRms | ( | int | dimOutput,
|  | IVector[] | prescribed,
|  | IVector[] | calculated,
|  | ref IVector | errors
| ) |  | `[inline, static]`

Calculates error measures - RMS (root mean square) of the differences - for the specified arrays of prescribed and calculated output values in a set of sampling points.

Parameters:

  dimOutput | Dimension of output values.
  prescribed | Array of prescribed output values (e.g. from training data, measurements, etc.).
  calculated | Array of calculated output values (e.g. by a trained neural network).
  errors | Vector where error measures for each indivitual output value are stored.

static void IG::Neural::NeuralApproximatorBase::CalculateErrorsMeanAbs | ( | int | dimOutput,
|  | IVector[] | prescribed,
|  | IVector[] | calculated,
|  | ref IVector | errors
| ) |  | `[inline, static]`

Calculates error measures - mean absolute value of the differences - for the specified arrays of prescribed and calculated output values in a set of sampling points.

Parameters:

  dimOutput | Dimension of output values.
  prescribed | Array of prescribed output values (e.g. from training data, measurements, etc.).
  calculated | Array of calculated output values (e.g. by a trained neural network).
  errors | Vector where error measures for each indivitual output value are stored.

static void IG::Neural::NeuralApproximatorBase::CalculateErrorsMax | ( | int | dimOutput,
|  | IVector[] | prescribed,
|  | IVector[] | calculated,
|  | ref IVector | errors
| ) |  | `[inline, static]`

Calculates error measures - maximum absolute value of the differences - for the specified arrays of prescribed and calculated output values in a set of sampling points.

Parameters:

  dimOutput | Dimension of output values.
  prescribed | Array of prescribed output values (e.g. from training data, measurements, etc.).
  calculated | Array of calculated output values (e.g. by a trained neural network).
  errors | Vector where error measures for each indivitual output value are stored.

virtual void IG::Neural::NeuralApproximatorBase::PrepareErrorData | ( | ref int | dimOutput,
|  | ref IVector[] | prescribed,
|  | ref IVector[] | calculated,
|  | bool | takeTrainingPoints,
|  | bool | takeVerificationPoints
| ) |  | `[inline, protected, virtual]`

Prepares data for calculation of various error measures over training points or in verification points after training of the neural network(s).

Parameters:

  dimOutput | Location where number (dimension) of output values is stored.
  prescribed | Array where prescribed values from the training set are stored.
  calculated | Array where calculated values in the corresponding points from the training set are stored.
  takeTrainingPoints | Specifies whether training points (i.e., excludingverification points) are taken from the training set to constitute the output data.
  takeVerificationPoints | Specifies whether verification points are taken from the training set.

void IG::Neural::NeuralApproximatorBase::GetErrorsTrainingRms | ( | ref IVector | errors | ) | `[inline]`

Calculates the RMS (root mean square) of the errors of output values for the training elements of the training set (this excludes verification points).

Parameters:

  errors |

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::GetErrorsVerificationRms | ( | ref IVector | errors | ) | `[inline]`

Calculates the RMS (root mean square) of the errors of output values for the verification elements of the training set.

Parameters:

  errors |

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::GetErrorsTrainingMax | ( | ref IVector | errors | ) | `[inline]`

Calculates the maximum absolute errors of output values for the training elements of the training set (this excludes verification points).

Parameters:

  errors |

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::GetErrorsVerificationMax | ( | ref IVector | errors | ) | `[inline]`

Calculates the maximum absolute errors of output values for the verification elements of the training set.

Parameters:

  errors |

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::GetErrorsTrainingMeanAbs | ( | ref IVector | errors | ) | `[inline]`

Calculates the mean absolute errors of output values for the training elements of the training set (this excludes verification points).

Parameters:

  errors |

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::GetErrorsVerificationMeanAbs | ( | ref IVector | errors | ) | `[inline]`

Calculates the mean absolute errors of output values for the verification elements of the training set.

Parameters:

  errors |

Implements IG::Neural::INeuralApproximator.

abstract void IG::Neural::NeuralApproximatorBase::PrepareInternalTrainingData | ( |  | ) | `[protected, pure virtual]`

Prepares internal training data that is needed by the native training algorithm. When overridden, this method must set the InternalTrainingDataPrepared flag to true.

Implemented in IG::Neural::NeuralApproximatorAforge.

virtual void IG::Neural::NeuralApproximatorBase::InvalidateTrainingDependencies | ( |  | ) | `[inline, virtual]`

Invalidates all data that must be recalculated after training of the network is done. This method is called after training or additional training of the network is performed. Invalidation is achieved throughthe the appropriate flags.

Implements IG::Neural::INeuralApproximator.

virtual void IG::Neural::NeuralApproximatorBase::InvalidateTrainingDataDependencies | ( |  | ) | `[inline, virtual]`

Invalidates all data that must be re-calculated after training data changes. This method is called after training data is modified. Invalidation is achieved throughthe the appropriate flags.

Implements IG::Neural::INeuralApproximator.

virtual void IG::Neural::NeuralApproximatorBase::InvalidateNetworkDependencies | ( |  | ) | `[inline, virtual]`

Invalidates all data that must be re-calculated after the neural network itself changes. This method must be called after the internal neural network is re-defined (or are re-defined). Invalidation is achieved throughthe the appropriate flags.

Implements IG::Neural::INeuralApproximator.

void IG::Neural::NeuralApproximatorBase::TrainNetwork | ( | int | numEpochs | ) | `[inline]`

Trains neural network wiht the specified data, performing the specified number of epochs.

Parameters:

  numEpochs | Number of epochs used in training of the network.

Implements IG::Neural::INeuralApproximator.

abstract void IG::Neural::NeuralApproximatorBase::TrainNetworkSpecific | ( | int | numEpochs | ) | `[protected, pure virtual]`

Trains neural network wiht the specified data, performing the specified number of epochs. This method must be implemented in derived classes and is specific to specific network type.

Parameters:

  numEpochs | Number of epochs used in training of the network.

Implemented in IG::Neural::NeuralApproximatorAforge.

void IG::Neural::NeuralApproximatorBase::TrainNetworkMultiple | ( | int | numEpochs,
|  | int | numIterations
| ) |  | `[inline]`

Performs a specified number of training iterations where the specified number of epochs are run in each iteration.

Parameters:

  numEpochs | Number of epochs run in each iteration.
  numIterations | Number of iterations.

void IG::Neural::NeuralApproximatorBase::TrainNetworkMultiple | ( | int | NumIterations | ) | `[inline]`

Performs a specified number of training iterations where the prescribed number of epochs (contained in the EpochsInBundle property) are run in each iteration.

Parameters:

  numIterations | Number of iterations.

virtual void IG::Neural::NeuralApproximatorBase::TrainNetwork | ( |  | ) | `[inline, virtual]`

Trains neural network until stopping criteria are met (in terms of errors and number of epochs performed.

Implements IG::Neural::INeuralApproximator.

virtual bool IG::Neural::NeuralApproximatorBase::StopTrainingCriteriaMet | ( |  | ) | `[inline, virtual]`

Returns true if the stopping criteria for training is met, with respect to current settings, errors and number of epochs already performed, and false otherwise.

Implements IG::Neural::INeuralApproximator.

abstract void IG::Neural::NeuralApproximatorBase::CalculateOutput | ( | IVector | input,
|  | ref IVector | output
| ) |  | `[pure virtual]`

Calculates and returns the approximated outputs corresponding to the specified inputs, by using the current neural network.

Parameters:

  input | Input parameters.

Returns:
  Vector of output values generated by the trained neural network.

Currently, only all outputs at once can be calculated. This makes no difference in the arrangement with a single network with multiple outputs, but does when several networks with single output each are used. If the implementation changes in the future then performance configuratins should be taken into account carefully, and tracking input for which input parameters the outputs have been calculated might be necessary.

Implements IG::Neural::INeuralApproximator.

Implemented in IG::Neural::NeuralApproximatorAforge.

virtual double IG::Neural::NeuralApproximatorBase::CalculateOutput | ( | IVector | input,
|  | int | whichElement
| ) |  | `[inline, virtual]`

Calculates and returns the specified output by using the neural network.

Implements IG::Neural::INeuralApproximator.

virtual void IG::Neural::NeuralApproximatorBase::CalculateOutput | ( | IVector | input,
|  | int[] | indices,
|  | ref IVector | filteredOutput
| ) |  | `[inline, virtual]`

Calculates and returns the required output values corresponding to the specified inputs, by using the current neural network(s).

Parameters:

  input | Input parameters for which output values are calculated.
  indices | Array of indices of the output values to be returned.
  filteredOutput | Vector where filtered output values are stored.

Implements IG::Neural::INeuralApproximator.

override string IG::Neural::NeuralApproximatorBase::ToString | ( |  | ) | `[inline]`

Returns string describing the current neural network approximator.

static void IG::Neural::NeuralApproximatorBase::SaveJson | ( | INeuralApproximator | approximator,
|  | string | filePath
| ) |  | `[inline, static]`

Saves a neural network approximator to a file. If the neural netwoek is trained then internal state is also saved to a file.

Parameters:

  approximator | Neural network approximator to be saved.
  filePath | Path to the file where approximator is saved.

static void IG::Neural::NeuralApproximatorBase::SaveJson | ( | INeuralApproximator | approximator,
|  | string | filePath,
|  | bool | saveInternalState
| ) |  | `[inline, static]`

Saves a neural network approximator to a file.

Parameters:

  approximator | Neural network approximator to be saved.
  filePath | Path to the file where approximator is saved.
  saveInternalState | Specifies whether internal state should be saved, too (only in the case that network is trained).

static void IG::Neural::NeuralApproximatorBase::LoadJson | ( | string | filePath,
|  | ref INeuralApproximator | approximatorRestored
| ) |  | `[inline, static]`

Loads network from a file.

Parameters:

  filePath | Path to the file.
  approximatorRestored | Neural approximator that is produced by deserialization.

void IG::Neural::NeuralApproximatorBase::SaveTrainingDataJson_To_delete | ( | string | filePath | ) | `[inline]`

Saves network's training data to the specified JSON file. File is owerwritten if it exists.

Parameters:

  filePath | Path to the file where training data is saved.

void IG::Neural::NeuralApproximatorBase::LoadTrainingDataJson_To_Delete | ( | string | filePath | ) | `[inline]`

Restores training data from the specified file in JSON format.

Parameters:

  filePath | File from which training data is restored.

void IG::Neural::NeuralApproximatorBase::TestMapping | ( |  | ) | `[inline]`

Test back and forth mapping (scaling and shifting) from actual data to data prepared for training, and vice versa (checks if transformed data falls withi the prescribed ranges and if backward transformation yields the same result as forward transformation). Testing is performed on all data from the TrainingData property, including verification elements.

static void IG::Neural::NeuralApproximatorBase::ExampleSaveNetwork | ( | string | directoryPath,
|  | string | fileName,
|  | string | internalStateFileName
| ) |  | `[inline, static]`

Example of saving an entire trained neural network to a file, and then restoring it from a file. Network internal state is saved by the SaveNetwork() method that is specific to the type of the network, therefore it is saved to a separate file. The path of this file is savad with the network approximator object itself. Network is saved only once.

Parameters:

  directoryPath | Directory where the neural network is saved.
  fileName | Name o the file into which the network is saved.
  internalStateFileName | Name of the file where the state of the trained network (internal representation) is stored.

static void IG::Neural::NeuralApproximatorBase::ExampleSaveNetwork | ( | string | directoryPath,
|  | string | fileName,
|  | string | internalStateFileName,
|  | bool | saveRestored
| ) |  | `[inline, static]`

Example of saving an entire trained neural network to a file, and then restoring it from a file. Network internal state is saved by the SaveNetwork() method that is specific to the type of the network, therefore it is saved to a separate file. The path of this file is savad with the network approximator object itself. If the saveRestored flag parameter is true then the restored file ia saved again for comparison.

Parameters:

  directoryPath | Directory where the neural network is saved.
  fileName | Name o the file into which the network is saved.
  internalStateFileName | Name of the file where the state of the trained network (internal representation) is stored.
  saveRestored | If true then the restored neural network is saved again for comparison with the file where original was saved.

static INeuralApproximator IG::Neural::NeuralApproximatorBase::ExampleQuadratic | ( |  | ) | `[inline, static]`

Example demonstrating usage of the neural network approximator. A quadratic function with random coefficients is sampled with enough samples to exactly specify function coefficients, a part of samples is randomly designated as verification points, then neural network is created and trained on training samples, and it is verified how close the obtained approximation matches actual function in verification points.

Returns:
  The trained neural network approximator that includes the training data, and can be saved to a file and used at a later time.

static INeuralApproximator IG::Neural::NeuralApproximatorBase::ExampleQuadratic | ( | int | inputLength,
|  | int | outputLength
| ) |  | `[inline, static]`

Example demonstrating usage of the neural network approximator. A quadratic function with random coefficients is sampled with enough samples to exactly specify function coefficients, a part of samples is randomly designated as verification points, then neural network is created and trained on training samples, and it is verified how close the obtained approximation matches actual function in verification points.

Parameters:

  inputLength | Number of input parameters of the neural network.
  outputLength | Number of approximated output values of the neural network.

Returns:
  The trained neural network approximator that includes the training data, and can be saved to a file and used at a later time.

static INeuralApproximator IG::Neural::NeuralApproximatorBase::ExampleQuadratic | ( | int | inputLength,
|  | int | outputLength,
|  | int | outputLevel,
|  | int | maxEpochs
| ) |  | `[inline, static]`

Example demonstrating usage of the neural network approximator. A quadratic function with random coefficients is sampled with enough samples to exactly specify function coefficients, a part of samples is randomly designated as verification points, then neural network is created and trained on training samples, and it is verified how close the obtained approximation matches actual function in verification points.

Parameters:

  inputLength | Number of input parameters of the neural network.
  outputLength | Number of approximated output values of the neural network.
  outputLevel | Level of output written to console (0 - no output).
  MaxEpochs | If greater than 0 then this is the maximal number of epochs used for training.

Returns:
  The trained neural network approximator that includes the training data, and can be saved to a file and used at a later time.

## Member Data Documentation

object IG::Neural::NeuralApproximatorBase::_mainLock = new object()`[private]`

int IG::Neural::NeuralApproximatorBase::_outputLevel = Util.OutputLevel`[private]`

int IG::Neural::NeuralApproximatorBase::_inputLength`[private]`

int IG::Neural::NeuralApproximatorBase::_outputLength`[private]`

int [] IG::Neural::NeuralApproximatorBase::_numHiddenNeurons`[private]`

bool IG::Neural::NeuralApproximatorBase::_multipleNetworks = true`[private]`

bool IG::Neural::NeuralApproximatorBase::_networkPrepared = false`[private]`

double IG::Neural::NeuralApproximatorBase::_sigmoidAlphaValue = NeuralTrainingParameters.DefaultSigmoidAlphaValue`[private]`

double IG::Neural::NeuralApproximatorBase::_learningRate = NeuralTrainingParameters.DefaultLearningRate`[private]`

double IG::Neural::NeuralApproximatorBase::_momentum = NeuralTrainingParameters.DefaultMomentum`[private]`

int IG::Neural::NeuralApproximatorBase::_epochCount = 0`[private]`

bool IG::Neural::NeuralApproximatorBase::_convergenceRmsEnabled = false`[private]`

int IG::Neural::NeuralApproximatorBase::_maxEpochs = NeuralTrainingParameters.DefaultMaxEpochs`[private]`

int IG::Neural::NeuralApproximatorBase::_epochsInBundle = NeuralTrainingParameters.DefaultEpochsInBundle`[private]`

List<IVector> IG::Neural::NeuralApproximatorBase::_convergenceRmsList = null`[private]`

List<int> IG::Neural::NeuralApproximatorBase::_epochNumbers = null`[private]`

List<IVector> IG::Neural::NeuralApproximatorBase::_convergenceErrorsTrainingRmsList = null`[private]`

List<IVector> IG::Neural::NeuralApproximatorBase::_convergenceErrorsTrainingMaxList = null`[private]`

List<IVector> IG::Neural::NeuralApproximatorBase::_convergenceErrorsVerificationRmsList = null`[private]`

List<IVector> IG::Neural::NeuralApproximatorBase::_convergenceErrorsVerificationMaxList = null`[private]`

IVector IG::Neural::NeuralApproximatorBase::_toleranceRms = null`[private]`

IVector IG::Neural::NeuralApproximatorBase::_toleranceMax = null`[private]`

IVector IG::Neural::NeuralApproximatorBase::_tolRmsRelative`[private]`

Auxiliary properties for defining tolerances in a relative way:

double IG::Neural::NeuralApproximatorBase::_tolRmsRelativeScalar`[private]`

IVector IG::Neural::NeuralApproximatorBase::_tolMaxRelative`[private]`

double IG::Neural::NeuralApproximatorBase::_tolMaxRelativeScalar`[private]`

const string IG::Neural::NeuralApproximatorBase::_defaultNetworkFilename = "network.dat"`[protected]`

string IG::Neural::NeuralApproximatorBase::_networkFilePath = null`[private]`

string IG::Neural::NeuralApproximatorBase::_networkRelativePath = null`[private]`

SampledDataSet IG::Neural::NeuralApproximatorBase::_trainingData`[private]`

IndexList IG::Neural::NeuralApproximatorBase::_verificationIndices`[private]`

IBoundingBox IG::Neural::NeuralApproximatorBase::_inputDataBounds`[private]`

IBoundingBox IG::Neural::NeuralApproximatorBase::_outputDataBounds`[private]`

IBoundingBox IG::Neural::NeuralApproximatorBase::_inputNeuronRange`[private]`

IBoundingBox IG::Neural::NeuralApproximatorBase::_outputNeuronsRange`[private]`

double IG::Neural::NeuralApproximatorBase::_inputBoundsSafetyFactor = 1.5`[private]`

double IG::Neural::NeuralApproximatorBase::_outputBoundsSafetyFactor = 2.0`[private]`

double IG::Neural::NeuralApproximatorBase::_defaultNeuronMinInput = -2`[protected]`

double IG::Neural::NeuralApproximatorBase::_defaultNeuronMaxInput = 2`[protected]`

double IG::Neural::NeuralApproximatorBase::_defaultNeuronMinOutput = -1.0`[protected]`

double IG::Neural::NeuralApproximatorBase::_defaultNeuronMaxOutput = 1.0`[protected]`

bool IG::Neural::NeuralApproximatorBase::_internalTrainingDataPrepared = false`[private]`

bool IG::Neural::NeuralApproximatorBase::_trainingOutputsCalculated = false`[private]`

bool IG::Neural::NeuralApproximatorBase::_verificationOutputsCalculated = false`[private]`

bool IG::Neural::NeuralApproximatorBase::_networkTrained`[private]`

List<IVector> IG::Neural::NeuralApproximatorBase::_calculatedOutputs = null`[protected]`

List of calculated outputs in points contained in (all) training data.

List<IVector> IG::Neural::NeuralApproximatorBase::_prescribed = null`[private]`

List<IVector> IG::Neural::NeuralApproximatorBase::_calculated = null`[private]`

bool IG::Neural::NeuralApproximatorBase::_breakTraining = false`[private]`

bool IG::Neural::NeuralApproximatorBase::_calculateVerificationErrors = false`[protected]`

Vector IG::Neural::NeuralApproximatorBase::_auxErrors = null`[protected]`

IVector IG::Neural::NeuralApproximatorBase::_output = null`[private]`

IVector IG::Neural::NeuralApproximatorBase::_outputFiltered1 = null`[private]`

## Property Documentation

object IG::Neural::NeuralApproximatorBase::Lock`[get]`

This object's central lock object to be used by other object. Do not use this object for locking in class' methods, for this you should use InternalLock.

Implements IG::Lib::ILockable.

int IG::Neural::NeuralApproximatorBase::OutputLevel`[get, set]`

Level of output printed to console when performing actions.

Implements IG::Neural::INeuralApproximator.

virtual bool IG::Neural::NeuralApproximatorBase::MultipleNetworks`[get, set]`

Flag indicating whether multiple neural networks are used to approximate multiple outputs (one network for each output)

Implements IG::Neural::INeuralApproximator.

virtual int IG::Neural::NeuralApproximatorBase::InputLength`[get, set]`

Gets or sets the number of input neurons.

Implements IG::Neural::INeuralApproximator.

virtual int IG::Neural::NeuralApproximatorBase::OutputLength`[get, set]`

Gets or sets the number of output neurons.

Implements IG::Neural::INeuralApproximator.

virtual int [] IG::Neural::NeuralApproximatorBase::NumHiddenNeurons`[get, set]`

Gets or sets the numbers of neurons in each hidden layer. When setting, contents of array are copied, not only a reference. Numbers are set by an array of integers in which each element contains the number of neurons in the corresponding hidden layer (indexed from 0). Hidden layers are those not containing input or output neurons.

Getter is protected cecause we don't want users of the class to set number of neurons in individual layers.

Implements IG::Neural::INeuralApproximator.

virtual int IG::Neural::NeuralApproximatorBase::NumHiddenLayers`[get, set]`

Gets or sets the number of hidden layers of the neural network (these are layers that don't contain input or output neurons).

Implements IG::Neural::INeuralApproximator.

bool IG::Neural::NeuralApproximatorBase::NetworkPrepared`[get, set]`

Gets a flag telling whether the network is prepared for operation (training and calculation of output).

Implements IG::Neural::INeuralApproximator.

double IG::Neural::NeuralApproximatorBase::SigmoidAlphaValue`[get, set]`

Alpha value specifying the shape of the activation function.

Implements IG::Neural::INeuralApproximator.

double IG::Neural::NeuralApproximatorBase::LearningRate`[get, set]`

Gets or sets learning rate.

Implements IG::Neural::INeuralApproximator.

double IG::Neural::NeuralApproximatorBase::Momentum`[get, set]`

Gets or sets momentum.

Implements IG::Neural::INeuralApproximator.

int IG::Neural::NeuralApproximatorBase::EpochCount`[get, set]`

Number of learning epochs performed up to the current moment.

Implements IG::Neural::INeuralApproximator.

int IG::Neural::NeuralApproximatorBase::MaxEpochs`[get, set]`

Maximal number of epochs in training.

Implements IG::Neural::INeuralApproximator.

int IG::Neural::NeuralApproximatorBase::EpochsInBundle`[get, set]`

Number of epochs in a single training bundle. This number of epochs is performed at once when training, without checking convergence criteria between. Larger value means slightly more efficient training (because of less checks) but rougher criteria checks.

Implements IG::Neural::INeuralApproximator.

IVector IG::Neural::NeuralApproximatorBase::ToleranceRms`[get, set]`

Tolerances on RMS errors of outputs over training points. Training will continue until error becomes below tolerance or until maximal number of epochs is reached. If less or equal than 0 then this tolerance is not taken into account.

Implements IG::Neural::INeuralApproximator.

IVector IG::Neural::NeuralApproximatorBase::ToleranceMax`[get, set]`

Tolerances on maximal errors of outputs over training points. Training will continue until error becomes below tolerance or until maximal number of epochs is reached. If less or equal than 0 then this tolerance is not taken into account.

Implements IG::Neural::INeuralApproximator.

IVector IG::Neural::NeuralApproximatorBase::ToleranceRmsRelativeToRange`[get, set]`

Relative tolerances on RMS errors of outputs over training points, relative to the correspoinding ranges of output data.

When this vector is set to a non-null value, elements of RMS tolerances vector (property ToleranceRms) are set to the specified fractions of the ranges of the corresponding output values in training parameters (defined by the property OutputDataBounds) if these are defined (otherwise this may happen when the property gets defined).

Whenever this property is defined, re-setting the property OutputDataBounds will cause recalculation of ToleranceRms according to elements of this property and the ranges of corresponding output values.

Setting this property undefines the ToleranceRmsRelativeToRangeScalar property, even if it is set to null.

If the scalar relative tolerance is set (property ToleranceRmsRelativeToRangeScalar) and this property is not set yet, the getter of this property will evaluate to a vector whose elements are equal to the scalar relative tolerance.

Implements IG::Neural::INeuralApproximator.

double IG::Neural::NeuralApproximatorBase::ToleranceRmsRelativeToRangeScalar`[get, set]`

Scalar through which all components of the Relative tolerances on RMS errors of outputs can be set to the same value.

Getter returns a value greater than 0 only if the property has been previously set.

Setting a vector of relative tolerances (property ToleranceRmsRelativeToRange) sets this property to 0, even it it is set to null.

Setting the property to a value greater than 0 automatically sets the vector of relative tolerances (property ToleranceRmsRelativeToRange) in such a way that all elements are equal to this property.

Implements IG::Neural::INeuralApproximator.

IVector IG::Neural::NeuralApproximatorBase::ToleranceMaxRelativeToRange`[get, set]`

Relative tolerances on max. abs. errors of outputs over training points, relative to the correspoinding ranges of output data.

When this vector is set to a non-null value, elements of max. abs. tolerances vector (property ToleranceMax) are set to the specified fractions of the ranges of the corresponding output values in training parameters (defined by the property OutputDataBounds) if these are defined (otherwise this may happen when the property gets defined).

Whenever this property is defined, re-setting the property OutputDataBounds will cause recalculation of ToleranceMax according to elements of this property and the ranges of corresponding output values.

Setting this property undefines the ToleranceMaxRelativeToRangeScalar property, even if it is set to null.

If the scalar relative tolerance is set (property ToleranceMaxRelativeToRangeScalar) and this property is not set yet, the getter of this property will evaluate to a vector whose elements are equal to the scalar relative tolerance.

Implements IG::Neural::INeuralApproximator.

double IG::Neural::NeuralApproximatorBase::ToleranceMaxRelativeToRangeScalar`[get, set]`

Scalar through which all components of the Relative tolerances on max. abs. errors of outputs can be set to the same value.

Getter returns a value greater than 0 only if the property has been previously set.

Setting a vector of relative tolerances (property ToleranceMaxRelativeToRange) sets this property to 0, even it it is set to null.

Setting the property to a value greater than 0 automatically sets the vector of relative tolerances (property ToleranceMaxRelativeToRange) in such a way that all elements are equal to this property.

Implements IG::Neural::INeuralApproximator.

List<int> IG::Neural::NeuralApproximatorBase::EpochNumbers`[get, set]`

List of epoch numbers at which convergence data was sampled. Saved after every set of epochs.

$A Tako78 Sep12;

Implements IG::Neural::INeuralApproximator.

List<IVector> IG::Neural::NeuralApproximatorBase::ConvergenceErrorsTrainingRmsList`[get, set]`

Convergence List of RMS errors calculated on training data. Saved after every set of epochs.

Implements IG::Neural::INeuralApproximator.

List<IVector> IG::Neural::NeuralApproximatorBase::ConvergenceErrorsTrainingMaxList`[get, set]`

Convergence List of Maximum errors calculated on training data. Saved after every set of epochs.

Implements IG::Neural::INeuralApproximator.

List<IVector> IG::Neural::NeuralApproximatorBase::ConvergenceErrorsVerificationRmsList`[get, set]`

Convergence List of Rms errors calculated on verification data. Saved after every set of epochs.

Implements IG::Neural::INeuralApproximator.

List<IVector> IG::Neural::NeuralApproximatorBase::ConvergenceErrorsVerificationMaxList`[get, set]`

Convergence List of Maximum errors calculated on verification data. Saved after every set of epochs.

Implements IG::Neural::INeuralApproximator.

bool IG::Neural::NeuralApproximatorBase::SaveConvergenceRms`[get, set]`

Flag to enable RMS error convergence colection.

Implements IG::Neural::INeuralApproximator.

string IG::Neural::NeuralApproximatorBase::NeuralApproximatorType`[get]`

Gets string representation of type of the current object. This is used e.g. in deserialization in order to prevent that wrong type of internal representation would be read in.

Implements IG::Neural::INeuralApproximator.

string IG::Neural::NeuralApproximatorBase::NetworkStateFilePath`[get, set]`

Path where the curren network state has been saved, or null if the current state has not been saved yet. The SaveFile methods takes care that the file path is stored when network state is saved. InvalidateTrainingDependencies() takes care that this file path is set to null if network state has changed after last save.

Implements IG::Neural::INeuralApproximator.

string IG::Neural::NeuralApproximatorBase::NetworkStateRelativePath`[get, set]`

Relative path where the curren network state has been saved. Auxiliary property used in deserialization. When the whole Neural network approximator is saved to a file, tis path is updated in such a way that it points to the fiele where the network state has been saved, but relative to the path where the whole approximator is saved. This enables restore of the saved network state at a later time, even if the containing directory has moved within the file system or has even been copied to another system.

Implements IG::Neural::INeuralApproximator.

SampledDataSet IG::Neural::NeuralApproximatorBase::TrainingData`[get, set]`

Gets or sets the training data.

Implements IG::Neural::INeuralApproximator.

virtual IndexList IG::Neural::NeuralApproximatorBase::VerificationIndices`[get, set]`

Gets or sets indices of training data elements that are used for verification of how precise appeoximation is. These elements are excluded from training of neural network.

Object of type IndexList that contains indices of elements used for verification, always contains a sorted list of unique indices.

Implements IG::Neural::INeuralApproximator.

virtual IBoundingBox IG::Neural::NeuralApproximatorBase::InputDataBounds`[get, set]`

Bounds on input data, used for scaling from actual input to input used by neural network. Scaling is performed because of the bound codomain and image of activation functions.

Implements IG::Neural::INeuralApproximator.

virtual IBoundingBox IG::Neural::NeuralApproximatorBase::OutputDataBounds`[get, set]`

Bounds on output data, used for scaling from actual output to output produced by neural network. Scaling is performed because of the bound codomain and image of activation functions.

Implements IG::Neural::INeuralApproximator.

virtual double IG::Neural::NeuralApproximatorBase::InputBoundsSafetyFactor`[get, set]`

Safety factor by which interval lenghts of input data bounds are enlarged after bounds are automatically determined from the range of input data in the training set. Setter re-calculated the input data bounds and therefore invalidates training data dependencies.

Implements IG::Neural::INeuralApproximator.

virtual double IG::Neural::NeuralApproximatorBase::OutputBoundsSafetyFactor`[get, set]`

Safety factor by which interval lenghts of output data bounds are enlarged after bounds are automatically determined from the range of output data in the training set. Setter re-calculated the output data bounds and therefore invalidates training data dependencies.

Implements IG::Neural::INeuralApproximator.

virtual IBoundingBox IG::Neural::NeuralApproximatorBase::InputNeuronsRange`[get, set]`

Gets the range in which data should be for input neurons, used for scaling from actual input to input used by neural network. This depends on the activation function.

Setter is not public.

Implements IG::Neural::INeuralApproximator.

virtual IBoundingBox IG::Neural::NeuralApproximatorBase::OutputNeuronsRange`[get, set]`

Gets the range of the data output from output neurons, used for scaling from actual output to output produced by neural network. This will normally depend on the activation function.

Setter is not public.

Implements IG::Neural::INeuralApproximator.

int IG::Neural::NeuralApproximatorBase::NumAllTrainingPoints`[get]`

Gets number of all training points, including verification points.

Implements IG::Neural::INeuralApproximator.

virtual int IG::Neural::NeuralApproximatorBase::NumTrainingPoints`[get]`

Gets number of training points (this excludes verification points).

Implements IG::Neural::INeuralApproximator.

virtual int IG::Neural::NeuralApproximatorBase::NumVerificationPoints`[get]`

Gets number of verification points.

Implements IG::Neural::INeuralApproximator.

bool IG::Neural::NeuralApproximatorBase::TrainingOutputsCalculated`[get, set, protected]`

Whether outputs have been calculated, after last training, in the training points (excluding verification points).

bool IG::Neural::NeuralApproximatorBase::VerificationOutputsCalculated`[get, set, protected]`

Whether outputs have been calculated, after last training, in the training points (excluding verification points).

bool IG::Neural::NeuralApproximatorBase::InternalTrainingDataPrepared`[get, set, protected]`

Gets or sets a flag indicating whether internal training data is prepared. This flag is used internally for signalization between methods that deal with training data.

bool IG::Neural::NeuralApproximatorBase::NetworkTrained`[get, set]`

Whether network has been trained since the training data was set.

Implements IG::Neural::INeuralApproximator.

bool IG::Neural::NeuralApproximatorBase::BreakTraining`[get, set]`

Flags that signalizes (if true) that training should be broken on external request.

Implements IG::Neural::INeuralApproximator.

bool IG::Neural::NeuralApproximatorBase::CalculateVerificationErrors`[get, set]`

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

- NeuralApproximatorBase.cs

All Classes Namespaces Files Functions Variables Enumerations Properties Events