Notifications
Clear all

Genetic Evolution of a Neural Network Driven Robot

134 Posts
6 Users
27 Reactions
8,599 Views
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

@thrandell 

So the genetic code (chromosome) is the set of weights?
Genetics is evolution or population learning which means in your last post the need for 80 robots.
Then (for some reason the same as the number of robots) there are 80 input reads and thus 80 actions (i/o) which are scored according I guess to how often an obstacle is hit?
The say top 5 robots (those with the highest score) have their genes mixed (and maybe some small mutations made) differently for each of another set of 80 robots?
Or are these 80 robots just 80 genes all tested in the ONE robot one at a time?

learner

   
ReplyQuote
THRandell
(@thrandell)
Brain Donor
Joined: 3 years ago
Posts: 231
Topic starter  

Casey,

Sorry for the confusion.  My intention when posting all this stuff was to fill in the holes I had from reading Floreano’s original paper, written in 1994.  Did you read it?  You got these two correct.

Posted by: @robotbuilder

So the genetic code (chromosome) is the set of weights?

Posted by: @robotbuilder

Or are these 80 robots just 80 genes all tested in the ONE robot one at a time?

 

Let’s talk about the genetic algorithm (GA) first.  It seems like the most interesting part of this experiment.  This fuzzy screen print is a report from the GA for a short run on my swarm robot.

GA report

 

 It reports data from a population of 80 individuals.  It shows the two parents of the individual, as well as the crossover point, the chromosome ‘string’, the number of parameters that are contained in the string and the fitness value that came after applying those parameters (weights) to the artificial neural network (ANN). 

The GA selects two high fitness parents from the previous generation and applies cross over and mutation to create children.  As each child has its chromosome ‘string’ created it is immediately decoded into multiple float values that are inserted as weights into the ANN.  The ANN is executed and the output produced is used as motor speed commands on the robot.

Let’s next look at how a 4-bit parameter that is pulled out the the chromosome string gets decoded into a float value.  Taking the first row from the Generation 1 output, we see that the parents were rows 79 and 32 from Generation 0.  The xsite is 88 which is the length of the chromosome ‘string’ so no cross over was done.  Now let’s grab the last 4 bits from the string, i.e. ‘1011’ and decode it.

We can decode a binary string into a real number r in the range [min,max] by first decoding it into the integer i and then applying the formula r = min + (i/15)(max - min), where 15 is the maximum integer value represented by a 4-bit string.

The experiment parameters used an Initial Weight Range [-0.5, 0.5] as input to the ANN.  

That gives us, 

r = -0.5 + (11.0/15.0)(0.5 - -0.5); 

r = -0.5 + 0.73333 * 1;

r = 0.2333; 

 

Do you have any questions about the GA process?

 

Tom

To err is human.
To really foul up, use a computer.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

@thrandell 

I will have to spend some time to "get it". Unfortunately the more someone trys to explain something often the more confusing it becomes because they don't have access to what the other is not comprehending. Not really forming a clear picture of the beginning of an explanation can mean the rest is even less clear.

While searching for a clear explanation on GA learning I found this link which has some videos on swarm behavior.
http://alexeidrummond.org/bayesian_phylo_lectures/lectureArtificialLife/?print-pdf#/

 


   
ReplyQuote
THRandell
(@thrandell)
Brain Donor
Joined: 3 years ago
Posts: 231
Topic starter  

Posted by: @robotbuilder

I will have to spend some time to "get it"

Well, if there is anything I can help with let me know.

Thanks for the link to the Artificial Life presentation!  The Boids program looks interesting.

 

Tom

To err is human.
To really foul up, use a computer.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

@thrandell wrote

"Well, if there is anything I can help with let me know."

Probably by starting with actual complete code for the neural network.

Once the network is done then how the weights are coded in the "chromosome" can be explained.

In other words replace the description of the network with the actual complete code.

I notice the neural network only has one layer meaning it cannot learn the XOR function.

What is the range of input values?

What is the range of output values? 0 to 255? direction?

In the robot the motor driver needs a speed value and a direction signal from the network.

I noticed you wrote:

"holds the normalized sensor readings" so what are the actual readings and what happens when they are normalized?

 


   
ReplyQuote
THRandell
(@thrandell)
Brain Donor
Joined: 3 years ago
Posts: 231
Topic starter  

I don’t mind compiling these things for you, after all I did volunteer, but you need to understand that this isn’t a one way street.  I’d like you to put in some effort too.  I’ve posted the answers to some of your questions elsewhere in this topic which makes me think that you might try some memory aids.  This isn’t meant as a put down.  Personally I take notes on things I’m trying to learn and things that I want to try out and I’d be lost without them.

Posted by: @robotbuilder

Probably by starting with actual complete code for the neural network.

Once the network is done then how the weights are coded in the "chromosome" can be explained.

In other words replace the description of the network with the actual complete code.

What do you mean by ‘actual complete code’?  The code that runs on my robot?  That code is Pico specific and is split across two MCUs.

Posted by: @robotbuilder

I notice the neural network only has one layer meaning it cannot learn the XOR function

ok

Posted by: @robotbuilder

What is the range of input values?

[-0.5,0.5] Check my post dated 7/21/23 on this topic, re Initial Weight Range

Posted by: @robotbuilder

What is the range of output values? 0 to 255? direction?

[-0.5,0.5] Check my post dated 7/5/23 on this topic, re sigmoid activation function

Posted by: @robotbuilder

In the robot the motor driver needs a speed value and a direction signal from the network.

yep

Posted by: @robotbuilder

"holds the normalized sensor readings" so what are the actual readings and what happens when they are normalized?

 

Readings from sensors vary between 1 and 7 with higher numbers indicating more activation.  After normalization they become real values in the range [0,1].

“A frequent problem with input data is that the magnitudes of the values may not be homogeneous.  For example, sensors on a robot may return values that operate on different scales or display high peaks… A frequently used strategy consists in normalizing the input vectors so that the length, or norm, of the vector is always equal to 1.”

From Bio-Inspired Artificial Intelligence (2008).

 

Tom

 

To err is human.
To really foul up, use a computer.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

@thrandell wrote:
"I’ve posted the answers to some of your questions elsewhere in this topic which makes me think that you might try some memory aids."

🙂

Actually I have tried memory aids. Unfortunately I was born with a lousy memory. How do I know that? Because I have observed people with good memories who think that their ability is normal. Once when I said I forgot something the response was "well unforget!" which makes me think that a good memory doesn't always come with a logical brain. Once when I told the same person they weren't being logical the response was "Why would I be logical if it doesn't get me what I want?" which ok maybe is logical?

All my life I have be interested in how our brains work and would always buy books on the latest discoveries. One of the books was actually titled "Your Memory a users' guide" Alan Baddeley.

The neural network of the snail Aplysia has been completely mapped and used to explore the connections and chemicals involved in its short and long term memory. I suspect I am not getting enough of the chemical being released to quickly form long term memories. Some people get too much of it and remember just about everything although not necessarily understanding any of it.

I had no trouble understanding the code you posted. I have read a lot about neural networks and have had fun writing my own versions. The sigmoid function isn't always the best to use.

How well do you think you would go on this test. Numbers 1 to 9 are displayed at random positions on a screen are quickly replaced by blank squares. You have to remember the position of each number and hit the squares in the correct order 1 to 9. Here is a chimp doing the test. They declared the Chimp was smart, not really, it just had a good short term memory.


   
THRandell reacted
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

@thrandell 

I will code a neural net using the information you have given regarding the input values.  The input becomes 1 or 0 if my memory serves me well!  So the output can also be negative or positive.  Does negative -1 mean reverse direction of motor, 0 mean stop and +1 forward direction of motor?

 

 

 


   
ReplyQuote
THRandell
(@thrandell)
Brain Donor
Joined: 3 years ago
Posts: 231
Topic starter  

Posted by: @robotbuilder

Once when I said I forgot something the response was "well unforget!" which makes me think that a good memory doesn't always come with a logical brain

Ha, good one

Posted by: @robotbuilder

Does negative -1 mean reverse direction of motor, 0 mean stop and +1 forward direction of motor?

I've always used the + as forward and - as backward.

Actually the output of the neural network is -0.5 to +0.5, so I use the sign for direction and the absolute value for speed.  My software uses duty cycle to control motor speed so I have a function to map the neural network output to a value between 0 and 100.

 

Tom

To err is human.
To really foul up, use a computer.


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1903
 

@thrandell,

I'm catching up... I've now dug out time to read through your thread and really study it and at least the original paper sited.  I got down to where you said you re-read and had a epiphany.  I too re-read it and did get a little more.  I also have a $8.45 copy of Goldberg coming.

I'm not really sure I am totally distinguishing what a Neural Net is and how it actually operates.  In one regard, I'm getting that it's a tree of branches (if/then statements) that's taking input at the leaves and makes decisions as it works down the branches to the trunk.  In another, I see it's a way of setting up weights compared to the inputs and the one with the highest output wins.  

This latter version sounds similar to a program I wrote using the Nedler-Mead algorithm to design a boat optimized for speed based on about 15 variables.  The algorithm walks a path in this 15D space to find local minimums or maximums... thus sounding kind of like this evolution process walking from generation to generation leading to a best chromosome.    

The first thing I stumbled across in the paper... The first half of the paper was justifying letting the robot learn on its own.  And yet when I see this equation,

image

I clearly see they are pre-loading with knowledge.  As the goal is to go the fastest while not running into things, they have already pre-disposed the equation (the robot):

  1. As V (velocity) goes up, Φ goes up.
  2. As Δv (spinning around) goes up, Φ goes down.
  3. As i (how strong an obstruction signal is) goes up, Φ goes down.

Even worse, they seem to have artificially pre-weighted Δv by taking the square-root.  All these things smack of giving it instinct.  And this instinct is based on them (the researchers) knowing how the world works.  I would think the more objective and logical research path should have been totally un-biased and use something like:

Φ = A*V + B*Δv + C*i

And let the evolution algorithm find the weighting factors and learn for itself that B and C will need to be negative to make those characteristics lower the Φ as they get larger.  I bring this up because, what if there are say 20+ sensors and some may have influences on Φ that us humans may not realize or even realize if they positively or negatively influence Φ ahead of time.  The bot would tell us once it's figured it out through evolution. 

I have some other lack of understanding based on this biological analogy that I have to re-read again for a third time to see if I can clear it up or at least ask a more intelligent question. 🤔 

VBR,

Inq

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1903
 

@thrandell,

BTW - I ran across this somewhere in my research surfing.  I thought it might be pertinent to your swarm concept.

Ant Colony Optimization based navigational decision support
system

Although, I think you're still working on the mechanics of one bot so far... have you given thought to how you are going to approach the swarm concept?  Surely there will be some kind of inter-bot-communication or at least some kind of passive inter-bot-detection.

VBR,

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

@inq wrote:

"I'm not really sure I am totally distinguishing what a Neural Net is and how it actually operates."

You might say the "neuron" adds up the evidence for a certain input pattern.

All the inputs vote (some have a bigger say than others thus the weighted values) and a decision is made accordingly.

So one input value might imply it is X (positive weight) another might imply it is not X (negative weight) and another might imply nothing at all (weight = 0)

A bit like guessing what animal it is by getting a yes/no answer to a set of questions.


   
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1903
 

As is obvious, I needed the hello world version of Neural Network concepts.  Of course I haven't been living under a rock and I can easily picture the brain's neurons and interconnections, I was more ignorant on the aspects of modeling that in software.  As you are past this phase, I see you didn't have a good reference for me to get started.  So, I just did the baseline of going to YouTube and posting a search.  I can't speak to the relative fitness of my selection or even how I selected it.  But I seem to have gotten very lucky as it talks to my ignorance level of NN quite well (rather remedial) but it also talks to my mathematical/engineering level (doctorate level) by referencing Linear Algebra and by extension the Finite Element Method of problem solving.  These aspects told me many things of where this will lead and what I can leverage of my background toward these problems.  I'm excited for the journey.  Here is the introductory video in case someone else is at the same Noob level I am.  If it doesn't ring to your strengths and weaknesses... there are hundreds of tutorials out there at many levels.

Posted by: @thrandell

A neural network can use an activation function to interpret the results of the neuron calculation.  Floreano and Mondada used a sigmoid function on the output neurons shifted by 0.5 for a range of [-0.5,0.5].  When supplied a value for x the sign of the result indicated the wheel’s direction, and the absolute value the wheel’s speed.  Sweet!

desmos graph

Also, watching this, triggered my Neuron that you had discussed the Sigmoid function.  In this video at 17:00 they discuss that the Sigmoid function is not used much anymore (Old School) and is now replace with ReLU function.  I can see why... the Sigmoid would be quite computer intensive due to it non-linear equation take literally millions of cycles more since ReLU is linear.  Not being at the stage of understanding the relative quality of the two toward an answer, but I can realize the time savings of not calculating the Sigmoid's.

VBR,

Inq

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2045
 

@inq wrote:

"Of course I haven't been living under a rock and I can easily picture the brain's neurons and interconnections"

Artificial neural networks were inspired by neural networks in the brain but they are not the same thing. As a mathematician you will have no trouble understanding an Artificial Neural Network which I read is an example of multivariate statistics. There are tools available that make creating ANNs easy for those with a mathematical background. It is only with fast computers and fast hardware that they are becoming a practical solution to the problem of learning to classify patterns.

However they are not 100% reliable and can make strange errors humans would never make.

https://www.digica.com/blog/how-to-fool-a-neural-network.html

"I see you didn't have a good reference for me to get started."

I was giving an intuitive description as mathematics is not my strength.

My introduction to pattern recognition was in the old days using hard coded solutions.

 


   
Inst-Tech reacted
ReplyQuote
Inq
 Inq
(@inq)
Member
Joined: 2 years ago
Posts: 1903
 

Posted by: @robotbuilder

"I see you didn't have a good reference for me to get started."

I was giving an intuitive description as mathematics is not my strength.

My introduction to pattern recognition was in the old days using hard coded solutions.

What I meant was that both of you are way, way further along in understanding and using NN.  I was hoping that you might have some old bookmarks of when you got started.  Like you said, "old days"... if someone now asked me to provide links on how to learn C++, I'd be at a total loss having learned long before the Internet had links and have never looked at an on-line C++ tutorial.

Posted by: @robotbuilder

Artificial neural networks were inspired by neural networks in the brain but they are not the same thing.

I've gone through the second and third videos in that series that discusses the back-propagation in more human, hand-waving terms and it so far is very similar to work I did with Nedler-Mead and with some of the same pitfalls.  I'm looking forward to the 4th where it starts getting into the Mathematics of backward propagation.  I hope the series will touch on the forward feeding you are discussing.  

 

3 lines of code = InqPortal = Complete IoT, App, Web Server w/ GUI Admin Client, WiFi Manager, Drag & Drop File Manager, OTA, Performance Metrics, Web Socket Comms, Easy App API, All running on ESP8266...
Even usable on ESP-01S - Quickest Start Guide


   
Inst-Tech reacted
ReplyQuote
Page 2 / 9