12 views

Uploaded by Nidul Sinha

Notes

- (Ann) Neural Nets Frohlich
- NeuralNetworks.CheungCannonNotes
- NeuralNets Overview
- Ramez T. Mina et al- Brain-Computer Interface Based on Classification of Statistical and Power Spectral Density Features
- Landslide Detection Using Image Processing and Neural Network
- NeuralNetworkPresentation (1)
- Bretas a.S. Artificial Neural Networks in Power System Restoration
- BPDES1
- Character Recognition Using NN
- Park 2011
- Fukushima Miyake
- Levenberg-Marquardt Backpropagation - MATLAB Trainlm
- Oullette Et Al. - 2004 - Genetic Algorithm Optimization of a Convolutional
- InTech-Energy Demand Analysis and Forecast
- SPE-184371-MS
- 657767.01_cvetkovic
- Hardware Implementation Backpropagation
- Productivity in Construction
- upec96
- Reinforcement Learning Sutton Book

You are on page 1of 10

This article is part 3 of a series of 3 articles that I am going to post. The proposed article content will be as follows: 1. Part 1 : This one, will be an introduction into Perceptron networks (single layer neural networks) 2. Part 2: Will be about multi layer neural networks, and the back propogation training method to solve a non linear classification problem such as the logic of an XOR logic gate. This is something that a Perceptron can't do. This is explained further within this article 3. Part 3 : This one, is about how to use a genetic algorithm (GA) to train a multi layer neural network to solve some logic problem, if you have never come across genetic algorithms, perhaps my other article located here may be a good place to start to learn the basics

Summary

This article will show how to use a Microbial Genetic Algorithm to train a multi-layer neural network to solve the XOR logic problem.

Before we commence with the nitty griity of this new article which deals wtih muti layer Neural Networks, let just revisit a few key concepts. If you haven't read Part 1 or Part 2 perhaps you should start there.

The inputs (x1,x2,x3..xm) and connection weights (w1,w2,w3..wm) in figure 4 are typically real values, both postive (+) and negative (-). If the feature of some xi tends to cause the perceptron to fire, the weight wi will be positive; if the feature xi inhibits the perceptron, the weight wi will be negative. The perceptron itself, consists of weights, the summation processor, and an activation function, and an adjustable threshold processor (called bias here after). For convenience the normal practice is to treat the bias, as just another input. The following diagram illustrates the revised configuration.

The bias can be thought of as the propensity (a tendency towards a particular way of behaving) of the perceptron to fire irrespective of it's inputs. The perceptron configuration network shown in Figure 5 fires if the weighted sum > 0, or if your into maths type explanations

The multi-layer network that will solve the XOR problem will look similiar to a single layer network. We are still dealing with inputs / weights / outputs. What is new is the addition of the hidden layer.

As already explained above there is one input layer, one hidden layer and one output layer. It is by using the inputs and weights that we are able to work out the activation for a given node. This is easily achieved for the hidden layer as it has direct links to the actual input layer. The output layer, however, knows nothing about the input layer as it is not directly connected to it. So to work out the activation for an output node we need to make use of the output from the hidden layer nodes, which are used as inputs to the output layer nodes. This entire process described above can be thought of as a pass forward from one layer to the next. This still works like it did with a single layer network, the activation for any given node is still worked out as follows:

Where (wi is the weight(i), and Ii is the input(i) value) You see it the same old stuff, no demons, smoke or magic here. Its stuff we've already covered. So thats how the network looks, so now I guess you want to know how to go about training it.

Learning

There are essentially 2 types of learning that may be applied, to a Neural Network, which is "Reinforcement" and "Supervised"

Reinforcement

In Reinforcement learning, during training an set of inputs is presented to the Neural Network, the Output is 0.75, when the target was expecting 1.0. The error (1.0 - 0.75) is used for training (wrong by 0.25). What if there are 2 outputs then the total error is summed to give a single number (typically sum of squared errors). Eg your total error on all outputs is 1.76 Note that this just tells you how wrong you were, not in which direction you were wrong.

Using this method we may never get a result, or could be hunt the needle. Using a generic algorithm to train a muti-layer neural network, offers a Reinforcment type training arrangement. Where the mutation is responsible for jiggling the weights a bit. This is what this article is all about.

Supervised

In Supervised Learning the Neural Network is given more information. Not just how wrong it was, but in what direction it was wrong' like Hunt the needle but where you are told North a bit West a bit. So you get, and use, far more information in Supervised Learning, and this is the normal form of Neural Network learning algorithm. This training method is normally conducted using a Back Propogation training method, which I covered in Part 2, so if this is the first article of these 3 parts, and the back propogation method is of particular interest, then you should look there.

From this point on anything that is being discussed relates directly to this articles code. Ok so what is the problem we are trying to solve ? Well it's the same as it was for Part 2, its the simply XOR logic problem. In fact this articles content is really just an incremetal build, on knowledge that was covered in Part 1 and Part 2, So lets march on. For the benefit of those that may have only read this one article, the XOR look problem looks like the following truth table

Remember with a single layer (perceptron) we cant actually achieve the XOR functionality, as its not linearly seperable. But with a multi-layer network, this is achievable. So with this in mind how are we going to achieve this ? Well we are going to use a Genetic Algorithm (GA from this point on) to breed a population of Neural Networks, that will hopefully evolve to provide a solution to the XOR logic problem, that's the basic idea anyway. So what does this all look like.

As can be seen from the figure above, what we are going to do is have a GA which will actually contain a population of Neural Networks. The idea being that the GA will jiggle the weights of the Neural Networks, within the population, in the hope that the jiggling of the weights will push the Neural Network population towards a solution to the XOR problem.

The basic operation of the Microbial GA training is as follows: o Pick 2 genotypes at random o Compares Scores (Fitness) to come up with a Winner and Loser o Go along genotype, at each locus (Point) With some probability copy from Winner to Loser (overwrite) With some probability mutate that locus of the Loser So ONLY the Loser gets changed, which gives a version of Elitism for free, this ensures a best in breed remains in the population. That's it. That's is the complete algorithm. But there are some ESSENTIAL issues to be aware of, when playing with GAs 1. The geneotype will be different for a a different problem domain 2. The Fitness function will be different for a a different problem domain These 2 items MUST be developed again, when ever a new problem is specified. For example if we wanted to find a person favourite pizza toppings the genetype and fitness would be different from that which is use for this articles problem domain. These 2 essential elements of a GA (for this article problem domain) are specified below

1. The Geneotype

For this article the problem domain states that we had a population of Neural Networks. So I created a single dimension array of NeuralNetwork objects this can be seen from the Constructor code within the GA_Trainer_XOR object

//ANN's private NeuralNetwork[] networks; public GA_Trainer_XOR() { networks = new NeuralNetwork[POPULATION]; //create new ANN objects, random weights applied at start for (int i = 0; i <= networks.GetUpperBound(0); i++) { networks[i] = new NeuralNetwork(2, 2, 1); networks[i].Change += new NeuralNetwork.ChangeHandler(GA_Trainer_NN_Change); } }

Remembering that the problem domain description stated the following truthtable is what we are trying to achieve

So how can we tell how fit (how close) the neural network is to this ? It is fairly simply really, what we do is present the entire set of inputs to the Neural Network one at a time and keep an accumulated error value, which is worked out as follows: Within the NeuralNetwork class there is an getError(..) method like this

public double getError(double[] targets) { //storage for error double error = 0.0; //this calculation is based on something I read about weight space in //Artificial Intellegence - A Modern Approach, 2nd edition.Prentice Hall //2003. Stuart Rusell, Peter Norvig. Pg 741 error = Math.Sqrt(Math.Pow((targets[0] - outputs[0]), 2)); return error; }

Then in the NN_Trainer_XOR class, there is an evaluate method, that accepts an int value, which represents the member of the population to fetch and evaluate (get fitness for). This

overall fitness is then returned to the GA training method, to see which Neural Network should be the WINNER and which Neural Network should be the LOSER.

private double evaluate(int popMember) { double error = 0.0; //loop through the entire training set for (int i = 0; i <= train_set.GetUpperBound(0); i++) { //forward these new values through network //forward weights through ANN forwardWeights(popMember, getTrainSet(i)); double[] targetValues = getTargetValues(getTrainSet(i)); error += networks[popMember].getError(targetValues); } //if the Error term is < acceptableNNError value we have found //a good configuration of weights for teh NeuralNetwork, so tell //GA to stop looking if (error < acceptableNNError) { bestConfiguration = popMember; foundGoodANN = true; } //return error return error; }

So how do we know when we have a trained Neural Network? In this articles code what I have done is provide a fixed limit value within the NN_Trainer_XOR class, that when reached, indicates that the training has yielded a best configured Neural Network. If however the entire training loop is done, and there is still no well configured Neural Network, I simply return the value of the WINNER (of the last training epoch) as the overall best configured Neural Network. This is shown in the code snippet below, this should be read in conjunction with the evaluate(..) method shown above

//check to see if there was a best configuration found, may not have done //enough training to find a good NeuralNetwork configuration, so will simply //have to return the WINNER if (bestConfiguration == -1) { bestConfiguration = WINNER; } //return the best Neural network return networks;

Well the code for this article looks like the following class diagram (Its visual studio 2005 C#, .NET v2.0)

The main classes that people should take the time to look at would be : GA_Trainer_XOR : Trains a Neural Network to solve the XOR problemm using a Microbial GA TrainerEventArgs : Training event args, for use with a GUI NeuralNetwork : A configurable Neural Network NeuralNetworkEventArgs : Training event args, for use with a GUI

SigmoidActivationFunction : A static method to provide the sigmoid activation function The rest are a GUI I constructed simply to show how it all fits together. NOTE : the demo project contains all code, so I wont list it here Also not that most of these classes are quite simliar to those included with the Part 2 article code. I wanted to keep the code, simliar so people who had already looked at Part 2 would recognize the common pattern.

- (Ann) Neural Nets FrohlichUploaded byMatt Booher
- NeuralNetworks.CheungCannonNotesUploaded byKshirod Kumar Dash
- NeuralNets OverviewUploaded bysurya
- Ramez T. Mina et al- Brain-Computer Interface Based on Classification of Statistical and Power Spectral Density FeaturesUploaded byAsvcxv
- Landslide Detection Using Image Processing and Neural NetworkUploaded byghalthota
- NeuralNetworkPresentation (1)Uploaded byhrlive123
- Bretas a.S. Artificial Neural Networks in Power System RestorationUploaded byNibedita Chatterjee
- BPDES1Uploaded bysch203
- Character Recognition Using NNUploaded byelectrical_1012000
- Park 2011Uploaded byLuchin Lopez Merino
- Fukushima MiyakeUploaded byManuel Joseph Olivé
- Levenberg-Marquardt Backpropagation - MATLAB TrainlmUploaded byLuis Carlos Ruiz Cardenas
- Oullette Et Al. - 2004 - Genetic Algorithm Optimization of a ConvolutionalUploaded byMatthew Browne
- InTech-Energy Demand Analysis and ForecastUploaded byAnkita Verma
- SPE-184371-MSUploaded bysaeed65
- 657767.01_cvetkovicUploaded byAnonymous QZSSYNFfM0
- Hardware Implementation BackpropagationUploaded byDavidThân
- Productivity in ConstructionUploaded byDore101
- upec96Uploaded bymayalasan1
- Reinforcement Learning Sutton BookUploaded byDom DeSicilia
- Neural NetworkUploaded byOlayiwola Opoosun
- Using neural networks and Dyna algorithm for integrated planning.19930015554.pdfUploaded byscsizmaz
- Product Cost Estimation, Technique ClassificationUploaded byPhạm Văn Đảng
- art3A10.10072Fs12161-013-9753-yUploaded byOvidiu Dumitru Bucur
- 2013 1 Computer ScienceUploaded bydeepakdaniel18
- Face Recognition Using Artificial Neural Network_finalUploaded byAravindan Vijayan
- PREDICTION OF COMPRESSIVE STRENGTH OF HIGH PERFORMANCE CONCRETE CONTAINING INDUSTRIAL BY PRODUCTS USING ARTIFICIAL NEURAL NETWORKSUploaded byIAEME Publication
- PssUploaded bydr-miker
- Neural Networks and Deep LearningUploaded bymanuel rascioni
- currnt lmtatinUploaded byrameshhodeee

- BActeria Foraging ELD15U08Uploaded byNidul Sinha
- Ncert PolicyUploaded byNidul Sinha
- Fuzzy Sets and Fuzzy LogicUploaded byNidul Sinha
- c2Uploaded byUpul Jayasinghe
- Lec-19 Tcps FactsUploaded byNidul Sinha
- Revised Vq Dct Au JournalUploaded byNidul Sinha
- Differences Between Delta Rule_Hebbian_ruleUploaded byNidul Sinha
- Lecture 17Uploaded byYashas Indalkar
- Chapter04 Z TransformUploaded bymagneta
- Final_Air Quality StandardsUploaded byNidul Sinha
- Que 6Uploaded byHHPPBB
- 1.3.3_dtftUploaded byNidul Sinha
- 6 Approximate ReasoningUploaded byNidul Sinha
- DCT_VQ_icprTUploaded byNidul Sinha
- Bill_Jan_2013Uploaded byNidul Sinha
- Butler_Understanding_the_St.pdfUploaded byNidul Sinha
- 01-intro1Uploaded byNidul Sinha
- fuzzy logic systems for engineeringUploaded byisaac2008
- Prolog AINotes3Uploaded byNidul Sinha
- What is Darshans Hindu DharmaUploaded byNidul Sinha
- CiviciogluBesdok11 - A conceptual comparison of Cuckoo PSO bee.pdfUploaded byNidul Sinha
- 12-prolog3Uploaded byNidul Sinha
- 14613820 Advances in Applied Artificial Intelligence FadlisyahUploaded byNidul Sinha
- akhandjyoti-englishjan_feb04Uploaded byYug Shilpi
- Centre of Gravity and Moment of InertiaUploaded byRaj Kumar
- 2004 2005 Research ReportUploaded byNidul Sinha
- ANN_L12Uploaded byNidul Sinha
- 04-Control.pdfUploaded byNidul Sinha

- engl322 syllabus fall2015Uploaded byapi-285565576
- The Miniature Guide to the Art - Richard PaulUploaded byDiego Shien
- X-uDMX512-2-3PUploaded byddrazen11
- As ViewbookUploaded byAlvi Habib
- CourseSyllabus_EEE307Uploaded byRagibNoorKingShuk
- JEE Main 2019 Detailed Analysis January Attempt Shift - 2(12th January, 2019)Uploaded byResonance Eduventures
- 10.1.1.199.5692Uploaded byFarjad Ali
- Sentence FormUploaded byOktoviani Rahmawati
- Development of Interactive E-Module for Global Warming to Grow of Critical Thinking SkillsUploaded byIjaems Journal
- Dependency and Neglect Petition ExampleUploaded byjrt2r9535
- Learned HelplessnessUploaded byLazari Chavan
- IGCSE Physics Lesson PlanUploaded bygdsuta
- Jura C E F Guide Open Machine and Remove Brew Group WMSUploaded bywicksjr
- Reaction Paper 7(1)Uploaded bykm247
- Free Multiple Intelligences Test Manual VersionUploaded byHalina Noordin
- Entrepreneurship Development ProcessUploaded byRajshree
- bottleflippinfunUploaded byapi-358685851
- DSOA Band Beat 03.08.12Uploaded byBrian Ross
- no need to fake itUploaded byCamille Morvan
- Academic Calendar Smtr Odd 2014 - 2015-Rev3-270814Uploaded byelearninglspr
- metaphorical e spanish6-crowe-la casaUploaded byapi-353819679
- Nomination Form 2018Uploaded byJodi Russell
- Possessive Adjectives ExercisesUploaded bygrover
- Labour and Industrial Laws II Course Outlines Glocal Final 2018.docUploaded byaruba ansari
- Effective Educational and Clinical SupervisionUploaded byMohammad Sutami
- Brochure FINALUploaded byjhmason38
- Bunnell High School Senior SpotlightUploaded byNHRSports
- The Work of Byron Katie - Summary.pdfUploaded bydesignsbybriangmail
- 7th grade steam welcome letter 2015Uploaded byapi-246097943
- Efectos del bilingüismo en el funcionamiento ejecutivo infantil.pdfUploaded byengelsblut