- Click on cell E14, and enter a number 1. This will refer to line 1 of the input table we've just created. When we've finished the following few steps, we'll be able to change all the inputs just by changing this to a 2.
- Click on the first of our feature sensors - cell A3.
- Go to the Formulas tabbed menu and click the Insert Function button on the left.
- In the floating window that pops up, select the CHOOSE function (if it's not there, you may need to select 'All' in the drop down category menu).
- In the new floating window that appears for the CHOOSE function, type E14. This means that the feature sensor checks cell E14 to find out which row of the inputs table to look at.
- In the box for value1, type A18. This is the yellowness feature of the banana. In the box for value2, type A19. This is the yellowness feature of the apple. Press OK.
- Open a new CHOOSE box for our second feature sensor - cell A4. This should again reference cell E14, but this time the two values should be B18 and B19, the greenness features of the banana and apple.
- Repeat this process for the other four feature sensors, cells A5, A6, A7 and A8.
I always had trouble working out what the smart people were going on about when they explained artificial neural networks using lots of maths. This is my attempt to explain them (and the maths that goes with them) in an easier way! I'll be using Excel to make several networks.
Monday 21 March 2011
Monday 14 March 2011
In this post we're going to build a simple neural network in Microsoft Excel. Excel is surprisingly good for doing this as it's familiar to many people and simple to use after minimal exposure. Moreover, it has a lot of built in functions (IF, CHOOSE, etc) that are the same as in any programming language (Matlab, C#, Java), plus many other useful functions.
What you’ve said here is that there are two inputs, each with a value of zero. There are two weights, with values of -0.5 and 0.2 respectively. There is a threshold of 1. There are also activation and output values, but these are not set yet – this is because we are going to have the network (Grak) calculate these itself.
When you press return, the value zero should appear in cell C4. This is because S1*w1 + S2*w2 = 0.
4. Finally, we need to compare the value we’ve just calculated with the threshold, and output a 1 if the value exceeds the threshold and a 0 otherwise.
Click on cell E4. Now go up to the formalas tabbed menu and select 'Insert Function':
When you have done this, a separate window will pop up that gives the option to “Select a function:”. From this list, choose IF. Another window will pop up. Input the following data and click ok:
What you have said is: if the data in cell C4 is greater than or equal to ( >= ) the value in cell D4, then make the value in cell E4 1. If not, make it 0. Simple, isn’t it!
5. Now try each of the following input pairs for the Darwinian Grak's sensors:
Bearing in mind that the Darwinian Grak only feeds on Fraggles, does the Grak you have made survive? Why, or why not?
So far we’ve seen two sibling Graks whose behaviours are pre-determined at birth (perhaps genetically). Should one of them be born with a mutation that makes it perform badly, it will die. This was the case with the first of the two, but not with the second. This is all fine, but it would be better if a baby were able to get some instruction from their mother so that any birth defects in synapse strength could be updated and they could survive... it would be better if it could learn! This is the case with the Common Grak that we'll look at in the next post.
Here's a video of me going through the steps from this post:
Sunday 13 March 2011
Saturday 12 March 2011
In this picture we can see a neuron with the dendrites, cell body and axon labelled. The dendrites receive information from other neurons via chemical messengers (neurotransmitters), this information is converted to an electrical charge which accumulates in the cell body and which, if it exceeds a certain threshold charge, will send a pulse (actually, a series of pulses) down the axon. This pulse is the output message from this neuron, and when it reaches the end of the axon, it is converted to chemical messengers to be sent to the dendrites of other neurons, so the process repeats.
This whole process is easy to model on a computer. The following two diagrams show how this is done.
This picture is the same as the first we saw, but I've stripped away most of the dendrites to leave just two. This is not a necessity – neurons with any number of dendrites (inputs) can be modelled, but just to keep it simple let's start with two. The two dendrites are labelled x and y. The cell body is still present, and still sums the inputs of the two dendrites, and the axon is still there to send the information on if the threshold is exceeded.
Drawing this in a more formal manner, we get the diagram on the right. All the information in the above picture is included in this one too.
The Σ sign represents the summation of x + y in the cell body.
Ok, so we have a simple model of a neuron (called a perceptron now that it's on our computer). So what is it capable of doing? Well, we can answer this question just by thinking about what comes out of the axon; the output. We only have one neuron, so one axon, and therefore one output. In the case of a biological neuron, it's either firing, or it isn't. We can represent this as either 1 (when it fires) or 0 (when it doesn't). So there's our answer; the perceptron is capable of taking it's inputs, summing them together and categorising them into one of two groups depending on whether the sum is greater than the threshold or not.
Our model does not actually do this yet though. At the moment it just sums the inputs together and tells us what that sum is. So if the x input is 0.5 and the y input is 0.7, the axon will give an output of 1.2. We need to add the threshold function so that it outputs only 1 or 0 (which could mean 'yes' or 'no', 'cat' or 'dog', or any pair of categories). The following diagram includes a threshold function:
The dashed line is the threshold. We haven't yet determined what the value of the threshold is. In a normal biological neuron the threshold is about 15mV (it rests at about -70mV and fires at about -55mV, so the threshold is the difference between these). For our model, let's keep things simple and set the threshold as 1. Therefore if the sum of x + y equals or exceeds 1, the output from the axon will be 1. If the sum is less than 1, the output will be 0.
Right, now we have everything we need to give a little demonstration of the perceptron.
It's going to be a simple demonstration. We want to know when both of the inputs into the neuron are active, so if both x and y receive a message from other neurons, then we want our neuron also to send a message by outputting a 1. On the other hand, if only one of our inputs is receiving a message, or if neither is, then we don't want our neuron to fire, and so a 0 should be outputted. We can use the input values that we set before: the input to x = 0.5 and the input to y = 0.7.
The above diagram shows the case when the inputs to both dendrite x and y are active. The sum exceeds the threshold value, and thus the perceptron outputs a 1, as we wanted.
The three other possible cases are shown in the three diagrams below; when there is an input to x, but not to y, when there's an input to y, but not to x, and when there is no input at all. In all these cases the sum in the cell body does not equal or exceed the threshold value of 1, so the output of the perceptron is 0, equivalent to a neuron not firing. The perceptron does what we have asked it to – it tells us when both of its inputs are active by outputting a 1 as opposed to a 0 in any other case.
Well, if you're anything like me, at this point you'll be thoroughly unimpressed by what a perceptron does! It's really no more than adding a few numbers together and then saying if they are more or less than a given threshold value. This can all be written a lot more concisely in mathematical form:
If sum(inputs) >= 1, then output = 1
else output = 0
So what exactly is the use of the perceptron?
I'll provide three answers to this question:
- The perceptron above doesn't actually learn anything. Things don't get interesting with neural networks until you get them learning, so hold on in there!
- A neural network is able to generalise from the things they know to things they've never seen before. They can make educated guesses!
- Nervous systems, including brains, are stunningly good at processing information. They are not only responsible for (almost) everything we do, but actually who we are. They give rise to consciousness. Yet all of these amazing functions are based upon little processing units (more or less) like the perceptron we described above and how they work together.