ANN NEURONs made simple 1.0

By Bo Palmblad

Commercial 22 Oct 2018

In category

Components > Component Packs > Other

Description

DEMO TRAINING PATTERN OF THE PROPAGATION NEURON [ANN:4-3-4 ] Training session ---------------------- The inputs from the pattern file 1.00 1.00 0.00 0.00 The outputs we want from the pattern 1.00 0.00 0.00 0.00 The inputs from the pattern file 0.00 0.00 1.00 1.00 The outputs we want from the pattern 0.00 0.00 0.00 1.00 The inputs from the pattern file 1.00 0.00 1.00 0.00 The outputs we want from the pattern 0.00 0.00 1.00 0.00 The inputs from the pattern file 0.00 1.00 0.00 1.00 The outputs we want from the pattern 0.00 1.00 0.00 0.00 The inputs from the pattern file 1.00 1.00 0.00 1.00 The outputs we want from the pattern 1.00 0.00 0.00 0.00 The inputs from the pattern file 0.00 0.00 0.00 0.00 The outputs we want from the pattern 0.00 0.00 0.00 0.00 [ANN:4-3-4] answer to queries ======================== Testing network inputs (4) values Input of the network is: 0.00 0.00 1.00 0.00 Output of the network is: 0.00 0.00 0.02 0.97 Global error calculus 0.00075 --------------------------------------------------------------------- Propagation NEURON object --------------------------------------------------------------------- Inizialising NEURON OBJECT. Input of the network is : 0.00 0.00 1.00 0.00 Output of the obj net is: 0.00 0.00 0.07 0.93 No of cycles computed 2000 No of iterations computed 15 Global error calculus 0.00049 OBJECT NEURON is unloaded from memory. DEBUG Training time: 2000 * 15 iterations * 6 patterns is 181 ms RELEASE Training time: 2000 * 15 iterations * 6 patterns is 128 ms Query time 0 ms --------------------------------------------------------------------- Testing network inputs (4) values Input of the network is: 1.00 1.00 0.00 0.00 Output of the network is: 0.99 0.00 0.00 0.00 Global error calculus 0.00075 --------------------------------------------------------------------- Propagation NEURON object --------------------------------------------------------------------- Inizialising NEURON OBJECT. Input of the network is : 1.00 1.00 0.00 0.00 Output of the obj net is: 0.99 0.00 0.00 0.00 No of cycles computed 2000 No of iterations computed 15 Global error calculus 0.00049 OBJECT NEURON is unloaded from memory. DEBUG Training time: 2000 * 15 iterations * 6 patterns is 176 ms RELEASE Training time: 2000 * 15 iterations * 6 patterns is 119 ms Query time 0 ms --------------------------------------------------------------------- To my surprise the 32-bit code was always faster than 64-bit. Demo code how to setup and run the NEURON ======================================== Neuron:=TPropagationNeuron.Create(Nil); // Create the NEURON. Neuron.ANNSetIHOsize(4,3,4); // 4 inp 3 hidden 4 outputs if Neuron.ANNInitPatterns('PATTERNS.txt') then // Actually setup the PATTERNS.TXT Begin Neuron.ANNSetCycles:=2000; // Number of cycles to run training Neuron.ANNSetIterations:=15; // Number of itterations / training cycle Neuron.ANNTraining; // Actually TRAIN the neuron Val(Edit1.Text, v, e); Neuron.ANNSetInput(1,v); // Setup Input grid value 1 with value v Val(Edit2.Text, v, e); Neuron.ANNSetInput(2,v); // Setup Input grid value 2 with value v Val(Edit3.Text, v, e); Neuron.ANNSetInput(3,v); // Setup Input grid value 3 with value v Val(Edit4.Text, v, e); Neuron.ANNSetInput(4,v); // Setup Input grid value 4 with value v Neuron.ANNTestData; // ACTUALLY DO THE ANALYSIS . Tyt:=' '; for i:=1 to 4 do Begin Str(Neuron.ANNGetOutput(i):5:2, Txt); // Get the answers from the Outputs of the NEURON Tyt:=Tyt+Txt; End; Form1.Memo1.Lines.Add(' Input of the network is :'+Inp); // Present input pattern Form1.Memo1.Lines.Add('Output of the obj net is:'+Tyt); // Present answer Str(Neuron.ANNGetCycles, Txt); // Aquire no of cycles training has been done Form1.Memo1.Lines.Add('No of cycles computed '+Txt); // SHOW result Str(Neuron.ANNGetIterations, Txt); // Aquire no of itterations Form1.Memo1.Lines.Add('No of iterations computed '+Txt); // SHOW result Str(Neuron.ANNGlobalError:5:5, Txt); // Aquire the Global error Form1.Memo1.Lines.Add('Global error calculus '+Txt); // SHOW result End; Neuron.ANNClose; // Shut down structure Neuron.Free; // Free computer memory from NEURON DEMO PATTERNS FROM FILE NEURON is [ANN:4-3-4] ======================== 6 Number of patterns to handle 1 1 0 0 1 0 0 0 4 inputs 4 result we want 0 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 1 0 1 0 1 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 4 inputs 4 result we want ( rubbish collection ) don't forget. as is on disc "PATTERNS.TXT" 6 1 1 0 0 1 0 0 0 0 0 1 1 0 0 0 1 1 0 1 0 0 0 1 0 0 1 0 1 0 1 0 0 1 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 "DELPHI 10.2.3 Tokyo" values PropagationNeuron.dcu is 21Kbyte in size compiled I-H-O Sourcecode is 12Kbyte. "DELPHI 10.2.3 Tokyo" values PropagationNeuron2.dcu is 22Kbyte in size compiled I-H-H-O Sourcecode is 13Kbyte. Same functionallity of both versions, based on same code, simply expanded to 2 hidden layers. Pure PASCAL no added units, no restrictions compile in any compiler from D7 and forward. All tests development and compillations made in DELPHI 10.2.3 Tokyo Testcompiled clean in DELPHI 10 Seattle Object "PropagationNeuron" testcompiled clean in Delphi7, test enviroment code available if you want it. Edit1..4 for input ch 1,2,3,4 Memo1 to report results and a Button, that is it. -------------------------------------------------------------------------------------------------------------------------------------------- unit NUnit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, PropagationNeuron; type TForm1 = class(TForm) Button1: TButton; Memo1: TMemo; Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Edit4: TEdit; procedure Button1Click(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; Neuron : TPropagationNeuron; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); Var v : Real; i,e : Integer; Txt, Tyt, Inp : String; begin Inp:=Edit1.Text+' '+Edit2.Text+' '+Edit3.Text+' '+Edit4.Text; Neuron:=TPropagationNeuron.Create(Nil); Neuron.ANNSetIHOsize(4,3,4); if Neuron.ANNInitPatterns('PATTERNS.txt') then Begin Neuron.ANNSetCycles:=2000; Neuron.ANNSetIterations:=15; Neuron.ANNTraining; Val(Edit1.Text, v, e); Neuron.ANNSetInput(1,v); Val(Edit2.Text, v, e); Neuron.ANNSetInput(2,v); Val(Edit3.Text, v, e); Neuron.ANNSetInput(3,v); Val(Edit4.Text, v, e); Neuron.ANNSetInput(4,v); Neuron.ANNTestData; Tyt:=' '; for i:=1 to 4 do Begin Str(Neuron.ANNGetOutput(i):5:2, Txt); Tyt:=Tyt+Txt; End; Form1.Memo1.Lines.Add(' Input of the network is :'+Inp); Form1.Memo1.Lines.Add('Output of the obj net is:'+Tyt); Str(Neuron.ANNGetCycles, Txt); Form1.Memo1.Lines.Add('No of cycles computed '+Txt); Str(Neuron.ANNGetIterations, Txt); Form1.Memo1.Lines.Add('No of iterations computed '+Txt); Str(Neuron.ANNGlobalError:5:5, Txt); Form1.Memo1.Lines.Add('Global error calculus '+Txt); End; //Neuron.ANNSaveNeuralCore('N2.core'); Neuron.ANNClose; Neuron.Free; end; procedure TForm1.FormShow(Sender: TObject); begin Edit1.Text:='0'; Edit2.Text:='0'; Edit3.Text:='1'; Edit4.Text:='0'; end; -------------------------------------------------------------------------------------------------------------------------------------------- OBS. All versions used same TPropagationNeuron code, only enviroment was rewritten for D7. OBS.

Informations

  • Status: Fully functional
  • Source: C
  • Source price: $25
  • Size: 677 360kB

Platforms:

  • Delphi 10
  • Delphi 7
  • Delphi XE
  • Delphi XE 2
  • Delphi XE3
  • Delphi XE4
  • Delphi XE5
  • Delphi XE6
  • Delphi XE2 64-bit
  • Delphi XE7
  • Delphi XE8

Downloads