Entry
Computer:Artificial intelligence: Neural network: Simple: How create simple neural network? [Delphi]
Mar 13th, 2005 02:05
Knud van Eeden,
----------------------------------------------------------------------
--- Knud van Eeden --- 17 November 2003 - 00:28 am -------------------
Computer:Artificial intelligence: Neural network: Simple: How create
simple neural network? [Delphi]
---
The purpose is here to get the basic idea, so that you can use
it to connect two or more of this basic units together.
---
The most basic unit of a neural network could be the following:
1. 1 input
2. 1 weight
3. 1 treshold
4. 1 activation function
---
This might be represented like the following:
weight1 +---------------+ +--------------------+
input1---->----|linear combiner|-->--|activation function1|->-output1
+---------------+ +--------------------+
^
|
treshold
---
To create a very simple computer program calculating this,
you have basically 3 steps:
---
Steps: Overview:
Given
1. activationfunction1
2. input1
3. weight1
4. treshold1
1. Calculate what comes out of the linear combiner
newsum1 = oldsum1 + input1 times weigth1
2. Calculate the activation function
x1 = newsum1
y1 = activationfunction1 as a function of this x1
3. Calculate the output
if y1 is greater than given treshold
then fire else do nothing
---
Steps: Worked out:
Given:
activationfunction1 = 1 / ( 1 + exp( - x1 ) )
input1 = 0.7
weight1 = 0.5
treshold1 = 0.2
sum1 = 0
1. Calculate what comes out of the linear combiner
sum1 = sum1 + input1 * weight1
2. Calculate the activation function
x1 = sum1
y1 = 1 / ( 1 + exp( - x1 ) )
3. Calculate the output
IF ( y1 > treshold1 ) BEGIN
writeline( 'fired' );
END
ELSE
writeline( 'do nothing' );
END;
---
So working out this numeric example:
---
input1 := 0.7;
weight1 := 0.5;
treshold1 := 0.2;
sum1 := 0;
// 1. Calculate what comes out of the linear combiner
sum1 := sum1 + input1 * weight1;
// sum1 = 0 + 0.7 * 0.5
// or thus
// sum1 = 0.35
// 2. Calculate the activation function
x1 := sum1;
// or thus
// x1 = 0.35
y1 := 1 + ( 1 + exp( - x1 ) );
// or thus
// y1 = 1 + ( 1 + exp( - 0.35 ) )
// or thus
// y1 = 0.58
// 3. Calculate the output
if ( y1 > treshold1 ) then begin
writeline( 'fired' );
end
else
writeline( 'do nothing' );
end;
// now 0.58 is greater than 0.20 thus it will fire
---
Writing a small Delphi program to test this idea:
Steps: Overview:
1. -Open Delphi
2. -Create a new application
3. -Put a button on the form
4. -Double click on the button
and fill in the following source code
--- cut here ---------------------------------------------------------
procedure TForm1.Button1Click(Sender: TObject);
var input1 : double;
var weight1 : double;
var treshold1 : double;
var sum1 : double;
var x1 : double;
var y1 : double;
begin
input1 := 0.7;
weight1 := 0.5;
treshold1 := 0.2;
sum1 := 0;
// 1. Calculate what comes out of the linear combiner
sum1 := sum1 + input1 * weight1;
// sum1 = 0 + 0.7 * 0.5
// or thus
// sum1 = 0.35
// 2. Calculate the activation function
x1 := sum1;
// or thus
// x1 = 0.35
y1 := 1 + ( 1 + exp( - x1 ) );
// or thus
// y1 = 1 + ( 1 + exp( - 0.35 ) )
// or thus
// y1 = 0.58
// 3. Calculate the output
if ( y1 > treshold1 ) then begin
ShowMessage( 'fired' );
end
else begin
ShowMessage( 'do nothing' );
end;
// now 0.58 is greater than 0.20 thus it will fire
end;
--- cut here ---------------------------------------------------------
5. -If you run this program, it will show a message box
with 'fired'
---
---
Internet: see also:
---
Neural network: Link: Can you give an overview of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/34415/fid/1760
----------------------------------------------------------------------