INeuralNetwork.LearnBack

Syntax

LearnBack(Var InputValues: Array; Var outputValues: Array);

Parameters

InputValues. Real array of input values.

outputValues. Real array of point-of-reference output values.

Description

The LearnBack method performs iteration on learning back-propagation network.

Comments

One iteration is called an epoch of learning. Short algorithm:

Iterations continue the specified number of times or until the assigned accuracy of the network has been reached, that is, till delta is small enough.

Example

As an example, a function is provided that learns the network. A back-propagation network is fed at the input of the function: the Net parameter. To execute the example, add links to the NN, IO system assemblies.

Function m_BPTrain(Net: NeuralNetwork): NeuralNetwork;
Var
    epoch, sampleNumber, i: Integer;
    NumberOfOut, NumberOfInp: Integer;
    inputs, outputs: Array Of Double;
    NetFile: File;
    TextW: ITextWriter;
Begin
    NetFile := New File.Create;
    TextW := NetFile.OpenTextWriter("C:/BPTrain.txt"True);
    NumberOfOut := Net.GetNumberOfOutputs;
    outputs := New Double[NumberOfOut];
    NumberOfInp := Net.GetNumberOfInputs;
    inputs := New Double[NumberOfInp];
    For epoch := 1 To 3000 Do
        For sampleNumber := 1 To NumberOfOut Do
        // set input values
            For i := 0 To NumberOfInp - 1 Do
                inputs[i] := 0.5;
            End For;
        // set output values
            For i := 0 To NumberOfOut - 1 Do
                outputs[i] := 0.5;
            End For;
        // set learning parameters
            Net.SetNju(0.1);
            Net.SetMju(0);
        // learn the network
            Net.LearnBack(inputs, outputs);
            TextW.WriteLnString("Epoch of learning: '" + epoch.ToString + "'");
            TextW.WriteLnString("  maximum value  delta: " + net.GetMaximumWeightDelta.ToString);
            TextW.WriteLnString("  output data: ");
            outputs := Net.GetOutputValues;
            For i := 0 To NumberOfOut - 1 Do
                TextW.WriteLnString("  " + outputs[i].ToString);
            End For;
        // verify whether network has been learned
            If Net.DeltasMinimumReachedBP(0.0001Then
                Return Net;
            End If
        End For;
    End For;
    Return Net;
End Function m_BPTrain;

After executing the example the network is learned according to the assigned parameters. Changing output data and delta value are written to the file C:/BPTrain.txt.

See also:

INeuralNetwork