Module 200: An Introduction to Neural Networks
Photograph of a biological
neuron: retinal neuron1
|
UNIT 1
Contents:
What are neural networks?
What is an artificial neuron?
Pattern recognition
Laboratory workbook exercises
References
Biological neurons and artificial neurons
The photograph of a biological neuron at the top of this page
shows a neuron from the part of the eye called the retina. Neurons
are cells which are found throughout the bodies of living things.
They are linked to other neurons and transmit information using chemical
and electrical signals. But they do not simply act in the same way
as conductors in an electrical circuit. Each neuron can be looked at
as an individual information processing unit which will only transmit
information in certain circumstances. The extremely large numbers of
neurons in the human brain and the many thousands of interconnections
between each of them are the basis for complex behaviour such as thinking,
feeling, seeing and hearing.
A biological neuron is made up of a cell body (soma), an axon, and dendrites which branch out from the cell body. The nucleus of the cell body controls the operation of the neuron, the axon transmits messages between neurons, and the dendrites receive information from the axons of other neurons. The simplified diagram shows two neurons connected by the axon of the neuron on the left. Connections are made through the transmission of chemical messages across the synapses between the axon and dendrites. The axon of each neuron in the brain is likely to have 15,000 synaptic connections to the dendrites of many other neurons.Diagram showing the connections between two neurons![]()
How artificial neural networks work
Artificial neural networks in computing simulate the two basic
features of biological neural networks: each artificial neuron is an
individual information processing unit and each neuron is interconnected
with many others. It is these two features which give artificial neural
networks their computational power. An important feature of this power
is the ability of artificial neural networks to adapt their functioning
in response to training data. In effect, the network 'learns' by being
'shown' correct examples. The adaptations which the network then makes in
its own functioning represent a form of generalisation. The network 'learns'
the principles which determine what is a correct example. The effect of
this is to give the network the ability to apply these principles to completely
new data. We will look in detail at how the simulation of these features
is achieved.
Neurons in the brain
It is important to realise how simple artificial neural networks
are in comparison to the operation of networks of real neurons. Each
of the 10 billion neurons in the brain has connections to many thousands
of other neurons. The computer programs which imitate biological neurons
do not approach this level of complexity. But, even though these programs
are much simplified versions of biological neural networks, they are able
to carry out highly complex functions which would be difficult to achieve
in other ways.
Pattern recognition
One of the functions
which artificial neural networks have been designed to carry out is
pattern recognition. Some examples of this include the recognition
of handwritten characters, images, speech patterns, or the results of
chemical analysis. We will examine the use of artificial neural networks
in pattern recognition throughout this module. More generally, artificial
neural networks are used in many areas, including weather forecasting,
self-regulating
control systems, computer games, economic and financial modelling, the
interpretation of data which has been corrupted by noise, and simulations
of the working of the brain.
A mathematical model
Artificial neurons can be looked at as mathematical models of the way biological neurons function. We will examine these mathematical models using the illustration of an artificial neuron shown below. At this point, we will not use mathematical notation. This will be introduced in later Units.
![]()
In simple terms, the artificial neuron will add the inputs (A1 to AN) together and produce an output only if the sum of the inputs triggers the activation function. But, looking at the illustration, you can see that the model has features such as the weights (W1 to WN) and the Threshold (bias) which will also play a part in determining whether or not the neuron produces an output. You can also see that the exact form of the activation function f(x) will have an effect on whether or not an output is produced. In order to make clear how the mathematical model works, we will define each part of the model and then input some example data to see the result.
DEFINITIONS:
Inputs (A1 to AN): these are normally the inputs from other artificial neurons, although they could simply be inputs of data to a single neuron. The binary inputs to the single neuron program we will look at in the next Unit are entered by the human user running the program. The values of the inputs will vary according to the function the network was designed to carry out. For example, they might have simple binary values of 1 or 0, or ranges of values such as 0.4, 0.8, 1.2, etc.
Weights (W1 to WN): the artificial neuron is designed to apply a 'weight' to each input. The weight is usually a value between 0 and 1 by which the input is multiplied. For example, if input A1 has the value 1 and weight W1 is 0.5, its input to the neuron's summation function will be 1 x 0.5 = 0.5. It is important to realise that the weights are not static. While the neuron is 'learning', it is programmed to adjust the weights until its output is correct. It does this by comparing its output with the 'correct' output it is 'shown' for the particular inputs. It then makes successive adjustments to the weights until it produces the correct output. We will look later at how these adjustments are made.
Summation Function: this quite simply adds together the result of multiplying each input by its respective weight: (A1 x W1) + (A2 x W2) + ...(AN x WN).
Activation Function f(x): the activation function receives the result of the summation function and its form determines whether or not the neuron produces an output. One simple activation function takes the form:
f(x) = 1 if x > 1
f(x) = 0 if x < 1.
In this function, the threshold value is 1. You can see that the neuron will produce an output of 1 if the result of the summation function is greater than 1.
Threshold (bias): This is an alternative way to set the threshold value. Rather than defining the threshold value within the activation function, it can be regarded as an input which is multiplied by a constant weight of 1. For the purposes of this Unit we will continue to set the threshold value within the activation function.
Running the model
Imagine we have a single neuron with two inputs (A1 and A2) which can take input values of 1 or 0. For the sake of this exercise we will start by setting an arbitrary value of 1 and 0 for inputs A1 and A2 respectively. We will define the weights can as taking positive integer values from 0 to 2 and will set an arbitrary initial value of 0 for both weights. As a result, the summation function for this neuron will carry out the following calculation (1 x 0) + (0 x 0) = 0. Assume that the activation function for the neuron uses the threshold value shown in the Definitions section. This means that it will produce an output of 1 if the result of the summation function is greater than 1. Then, clearly, in this case the neuron will not produce an output.
The trace table below shows the result of inputting all the possible combinations of binary inputs to the artificial neuron with the characteristics we have just defined.
Inputs Weights
Inputs x Weights Sum Output
A1 A2 W1 W2 (A1xW1) (A2xW2)
1 0 0 0 0
0 0 0
0 1 0 0 0
0 0 0
0 0 0 0 0
0 0 0
1 1 0 0 0
0 0 0
The
result is pretty unexciting because as long as the weights are set to 0
there will be no output from the neuron, whatever the value of the inputs.
Exercise
The following exercise is designed to allow you to simulate the neuron's 'training' process by devising a set of weights which will enable the artificial neuron to act as a logical AND gate. You will remember that the truth table for an AND gate with two binary inputs is as follows:
INPUTS OUTPUT
1 0 0
0 1 0
0 0 0
1 1 1
The table below shows the input and output values for our artificial neuron if it was to act as an AND gate. Using the characteristics we have defined for this particular neuron, can you find a pair of weights for W1 and W2 which will ensure that the required output in the table below is always achieved? Remember that the weights can be positive integers from 0 to 2 and that the threshold of this particular neuron is set so that it will produce an output if the result of the summation function is greater than 1.
Inputs Weights Inputs x Weights Sum Output
1 0 ? ? ? ? ? 0
A1 A2 W1 W2 (A1xW1) (A2xW2)
0 1 ? ? ? ? ? 0
0 0 ? ? ? ? ? 0
1 1 ? ? ? ? ? 1
Click here to check your answer.
Now try to find the values of weights that will allow the neuron to act as a logical OR gate. The truth table for the OR gate and an incomplete trace table for the neuron are set out below:
INPUTS OUTPUT
1 0 1
0 1 1
0 0 0
1 1 1
Inputs Weights Inputs x Weights Sum Output
1 0 ? ? ? ? ? 1
A1 A2 W1 W2 (A1xW1) (A2xW2)
0 1 ? ? ? ? ? 1
0 0 ? ? ? ? ? 0
1 1 ? ? ? ? ? 1
Click here to check your answer.
Pattern recognition
![]()
In this section of unit 1 we will begin to examine the use of artificial neural networks in pattern recognition.
Character recognition: the problem
Neural networks have been successfully used as the basis of character recognition programs, such as those used by banks. These programs have to deal with the fact that handwritten characters come in all shapes and sizes. They have to be able to compare the features of a handwritten character with standard representations of characters. From this comparison, they must correctly identify the handwritten character. It would be very difficult to create a conventional program which contained within it the means of recognising all the many possible permutations of the shapes of each handwritten character.
Programs using neural networks provide a solution to this problem because the networks can 'learn' to recognise the common features of handwritten characters. They learn by being 'shown' many different handwritten examples of a particular character. The program is instructed that the particular handwritten characters should be recognised as a certain standard character. Feedback within the program causes amendments to be made to the way program functions.
Exercise
This exercise looks in more detail at the problem of creating a character recognition program.
The illustrations below represent the arrangement of pixels on a simple computer screen. A white pixel has the value 0 and a black pixel has the value 1. The screen is currently showing the shape of the numeral '1'.
0 0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
The following extract from a C++ program creates a 5x5 array called 'map' to represent the simple screen. It intialises this array to the all white screen where every array position has the value 0. The program then enters the value 1 in each of the relevant array positions (as shown in the illustrations above) to form the shape of the numeral '1'. Finally the program checks the relevant array positions to confirm whether the numeral '1' is represented on the screen. Copy the full 'map.cpp' program from the Unit 1 part of the Datafiles section of this CD-ROM and run it on your C++ compiler. Study the program so that you are familiar with the data structures and algorithms which it uses.
//map.cpp
#include
void main()
{
int a, i, j;
// two-dimensional array representing numeral shapes
int map [5] [5];
// enter 0 in all array positions and display map
for (i=0; i<5; i++)
{
for (j=0; j<5; j++)
{
map [i] [j] = 0;
cout << map [i] [j];
}
cout << endl;
}
cout << endl;
// enter 1 in relevant array positions to form shape of
// numeral '1' and display map.
i = 2;
for (j=1; j<=3; j++)
{
map [j] [i] = 1;
}
for (i=0; i<5; i++)
{
for (j=0; j<5; j++)
{
cout << map [i] [j];
}
cout << endl;
}
cout << endl;
// check relevant array positions for shape of numeral '1'
a = 0;
i=2;
for (j=1; j<=3; j++)
{
if(map[j] [i] == 1)
{
a++;
}
}
// display result
if(a==3)
cout << "This numeral is 1";
else
cout << "This numeral is not 1";
}
This complete the introduction to the basic features of artificial neurons and the problem of pattern recognition. The next Unit will analyse the operation of a simple computer program representing an artificial neuron. It will also examine the concept of networks of artificial neurons.
Before going on to the next Unit you should complete the Laboratory Workbook exercises set out below.
Laboratory workbook exercises
![]()
The Laboratory workbook exercises for this Unit are contained in the Unit 1 chapter of the workbook.
References
![]()
1. Photograph of a retinal neuron taken from the website of Dr Mark Hill, Cell Biology Lab, University of New South Wales, Australia. http://anatomy.med.unsw.edu.au/cbl/embryo/Sections/CBL97/neuron.htm
2. Illustration of an artificial neuron taken from a paper on 'Neural Network Applications' by Kiyoshi Kawaguchi: http://www.ece.utep.edu/research/webfuzzy/docs/kk-thesis/kk-thesis-html/node12.html
Page updated 19.5.03