SetLearnRateEx(newLearnRate: Double; layerIndex: Integer): Double;
SetLearnRateEx(newLearnRate: double; layerIndex: integer): double;
newLearnRate. Learning rate value.
layerIndex. Layer index.
The SetLearnRateEx method sets learning rate for the specified layer.
SetLearnRateEx returns value of the previous learning rate and is applied only for Kohonen self-organizing maps.
The learning rate determines how fast neurons learn. Usually, the learning rate tends to zero value towards the end of learning.
Indexation of the layers is continuous and starts with zero.
As an example, a function is given, which input has Kohonen self-organizing map fed into (the Net parameter). To execute the example, add links to the NN, IO system assemblies.
Function m_LearnEx(Net: NeuralNetwork): NeuralNetwork;
Var
epoch, learnRadius, layerCount, i: Integer;
learnRate: Double;
NetFile: File;
TextW: ITextWriter;
Begin
TextW := NetFile.OpenTextWriter("C:/LearnRes.txt", True);
layerCount := Net.GetNumberOfLayers;
For epoch := 1 To 100 Do
TextW.WriteLnString("Epoch of learning '" + epoch.ToString + "'");
learnRate := 0.6 * ((300 - epoch) / 300);
learnRadius := (3 * ((300 - epoch) / 350)) As Integer;
For i := 0 To layerCount - 1 Do
TextW.WriteLnString(" Layer '" + i.ToString + "'");
TextW.WriteLnString(" current learning step '" + Net.GetLearnRadius(i).ToString + "'");
TextW.WriteLnString(" new learning step '" + learnRadius.ToString + "'");
Net.SetLearnRadiusEx(learnRadius, i);
TextW.WriteLnString(" current learning rate '" + Net.GetLearnRate(i).ToString + "'");
TextW.WriteLnString(" new learning rate '" + learnRate.ToString + "'");
Net.SetLearnRateEx(learnRate, i);
If Not Net.GetUseVectorScalar(i) Then
Net.SetUseVectorScalarEx(True, i);
End If;
End For;
Net.PropagateSOFM;
Net.LearnSOFM;
TextW.WriteLnString(" Code of error: " + Net.GetError.ToString);
End For;
Return Net;
End Function m_LearnEx;
After executing the example the network is learned. To calculate the distance between neurons, algorithm of scalar multiple vector multiplication is used. Details and results of learning are written to the file C:/LearnRes.txt.
As an example, a function is given, which input has neural network fed into (the Net parameter).
Imports System.IO;
Imports Prognoz.Platform.Interop.NN;
…
Public Shared Function m_LearnEx(Net: NeuralNetwork): NeuralNetwork;
Var
epoch, learnRadius, layerCount, i: Integer;
learnRate: Double;
NetFile: StreamWriter;
Begin
NetFile := File.CreateText("C:/LearnRes.txt");
layerCount := Net.GetNumberOfLayers();
For epoch := 1 To 100 Do
NetFile.WriteLine("Epoch of learning '" + epoch.ToString() + "'");
learnRate := 0.6 * ((300 - epoch) / 300);
learnRadius := (3 * ((300 - epoch) / 350)) As Integer;
For i := 0 To layerCount - 1 Do
NetFile.WriteLine(" Layer '" + i.ToString() + "'");
NetFile.WriteLine(" current learning step '" + Net.GetLearnRadius(i).ToString() + "'");
NetFile.WriteLine(" new learning step '" + learnRadius.ToString() + "'");
Net.SetLearnRadiusEx(learnRadius, i);
NetFile.WriteLine(" current learning rate '" + Net.GetLearnRate(i).ToString() + "'");
NetFile.WriteLine(" new learning rate '" + learnRate.ToString() + "'");
Net.SetLearnRateEx(learnRate, i);
If Not Net.GetUseVectorScalar(i) Then
Net.SetUseVectorScalarEx(True, i);
End If;
End For;
Net.PropagateSOFM();
Net.LearnSOFM();
NetFile.WriteLine(" Code of error: " + Net.GetError().ToString());
End For;
NetFile.Close();
Return Net;
End Function;
After executing the example the network is learned. To calculate the distance between neurons, algorithm of scalar multiple vector multiplication is used. Details and results of learning are written to the file C:/LearnRes.txt.
See also: