ImportSynapses(synapsysData: String): Boolean;
ImportSynapses(synapsysData: string): boolean;
synapsysData. String view of the values of the synapse weights.
The ImportSynapses method loads values of synapse weights from the string view.
The method returns execution result. Available values:
True. Values of the synapses' weights are loaded successfully.
False. An error occurred during method execution. The values of synapse weights are not loaded.
The values of the weights can be loaded only form the string view of the network returned by the INeuralNetwork.ExportSynapses method. Unlike the INeuralNetwork.CreateNetwork method this method loads only the values of synapse weights. This means that the network has already been created.
Executing the example requires the file C:\NetDefenition.txt in the file system; the file contains string view of the neural network. Add links to the NN and IO system assemblies.
Function m_ImportSynapses(Net: NeuralNetwork): Boolean;
Var
NetFile: File;
TextR: ITextReader;
SynVal: String;
res: Boolean;
Begin
NetFile := New File.Create;
TextR := NetFile.OpenTextReader("C:/NetDefenition.txt");
Repeat
SynVal := SynVal + TextR.ReadLine + " ";
Until TextR.Eof;
res := Net.ImportSynapses(SynVal);
If res Then
WinApplication.ErrorBox("Loading of values of synapse weights is completed!");
Else
WinApplication.ErrorBox("Error during loading values of synapse weights!");
End If;
Return res;
End Function m_ImportSynapses;
This function loads the values of the synapse weights from the file C:\NetDefenition.txt.
Executing the example requires the file C:\NetDefenition.txt in the file system containing string view of the neural network.
Imports System.Windows.Forms;
Imports Prognoz.Platform.Interop.NN;
…
Public Shared Function m_ImportSynapses(Net: NeuralNetwork): Boolean;
Var
NetFile: StreamReader;
SynVal: String;
res: Boolean;
Begin
NetFile := File.OpenText("C:\NetDefenition.txt");
Repeat
SynVal := SynVal + NetFile.ReadLine() + " ";
Until NetFile.EndOfStream;
res := Net.ImportSynapses(SynVal);
If res Then
MessageBox.Show("Loading of values of synapse weights is completed!");
Else
MessageBox.Show("Error during loading values of synapse weights!");
End If;
Return res;
End Function;
This function loads the values of the synapse weights from the file C:\NetDefenition.txt.
See also: