Go back
Neural network menu

Back-Propagation Neural Network Constructor

This page lets you create a simple Multi-Layer Perceptron. The neural network is constructed on this web page. However, the page does not save the file on leaving the page, so you must save any work that you have created before leaving the page. Please read through all the following before proceeding.

Specifying inputs

In this section of the page you specify the input controls that pass values to the network. At the moment the number of control types is severely limited, but I am hoping to add more in later versions. The possible control types are as follows:

Check boxes (for entering true/false, or 1/0):
Text slots (for entering numbers):

N.B. Text slots are designed for accepting any positive number (decimal or whole number) up to a maximum value that you specify (e.g. you can specify a text slot that takes numbers in the range 0 to 100, or one that takes numbers in the range 0 to 4500 etc.)

To create an input control, fill in a caption for the control, and select whether you want a checkbox-type input or a text slot-type input. You can also specify an upper limit if you want to create a text slot. If you don't specify a value, it will default to the range 0 - 100. N.B. If you don't fill in a caption for the input control, it will default to a blank string. (You can always edit it later).

The controls that you create will appear within the rectangle below. Each control has a caption, a type (checkbox or text slot) and, if it's a text slot, a maximum value. The controls will appear in the final network in the order in which they appear below - buttons will appear alongside each control as it is created to allow it to be promoted (moved higher in the list) or demoted.

Caption:
Checkbox
Text-slot Range: 0 -

Input controls
You have no controls currently created

Specifying outputs

This works in the same way as above, except that you specify the outputs from the network. The outputs can also be check boxes or text slots, and you needn't have the same number of outputs as inputs.

Caption:
Checkbox
Text-slot Range: 0 -

Output controls
You have no controls currently created

Hidden nodes

By default, the number of hidden nodes in the network is the sum of the number of inputs and the number of outputs (i.e. if you have 3 inputs and 5 outputs, the network will assume that it needs 8 hidden nodes). You may find that you can get better performance from the net (i.e. a greater proportion of successful input classifications) with a different number of hidden nodes (typically more than the default). For this reason, you can enter a new number in the text slot below before you train the network. Don't forget to click on the "Update the number of hidden nodes" button after changing the number of hidden nodes.

Number of hidden nodes:

N.B. If, after specifying the number of hidden nodes, you create/delete further input or outputs, the number of hidden nodes then reverts to the default (i.e. the new number of inputs + the new number of outputs), so specify the number of hidden nodes at the very end, just before you train. Yes, I agree, it's a pain, but it's tricky to create the code that overcomes this. Perhaps in a later version...

Training the network

In the text area on the left you should put the data on which you would like the network trained. Back-propagation networks are trained by applying many training patterns repeatedly. Each pattern forms a row in the textarea, with the elements separated by commas.

For instance, suppose you have three inputs (a checkbox, a text slot and another checkbox in that order) and two outputs (a checkbox and a text slot in that order). Each checkbox is represented by the values 1 and 0, each text slot by a value from 0 to the maximum for that slot (e.g. 100 or 4500 in the example above). In this case, rows in the text area will consist of 5 numbers, separated by commas (inputs, then outputs), such as the following three training patterns (colour coded for convenience):

1,56,0,0,100
0,30,1,0,27
1,81,0,1,66

You can type the training data into the slot above, but it is more efficient to paste it in using Copy and Paste from a text file. There is no "save" facility in this program, so a text file in Notepad or something similar is the only way to save the data in any case.

When you click on the button below, the program will check that the training data you have entered matches the controls that you have set up. If it does, then training will begin. The training consists of 10,000 cycles, and you can read how far it has got using the text slot on the right of the button. You can break into the process by saving the network at any stage (it doesn't matter if the count hasn't reached 10,000 - it just means that the network won't have trained as well as it might have done).

(It might be worthwhile saving this page to your hard disk before doing any lengthy training, particularly if you have a slow Internet connection).

Iterations completed :

Displaying the network

When you have created your inputs and outputs, specified the training data and trained the network, you can then display it by clicking on the button below. It will appear in its own pop-up window with a light-yellow background. Please ensure that you have pop-ups enabled before you display the network. If pop-ups are blocked, you will get a "This site is trying to produce a pop-up" error message just above your web page.

Assuming the network does appear correctly, you can then test it by specifying some test input data and clicking on the "Run" button. If the network behaves correctly, bravo! You can then go on to save it (see below). You may find, however, that it fails for some or all combinations of input data. This could be for any of these reasons:

  • Your training data wasn't general enough (in other words, it's your fault!)

  • You need a different number of hidden nodes (usually more than the number you have already). Try increasing the number in the appropriate slot above and retraining.

  • The network needs more training iterations. Just click on the train button again. (And again, and again...)

  • There is some unspecified fault in the network code itself (in other words, it's my fault!) Sorry! It's a fairly primitive system, and I can't guarantee Rolls Royce performance.

In general, you can improve performance by addressing a combination of these causes and doing some general tinkering.

Saving the network

As you probably know by now, there is no save facility in JavaScript. However, we can cheat a little. In order to save the network, you should do the following:

  • Display the network using the button above.

  • Click the right-hand mouse button somewhere over the small yellow window that appears.

  • From the menu that appears, choose "View Source" (or a similar name depending on which browser you are using). This causes the HTML and JavaScript code for the network to appear in its own little window. Depending on your browser, it may even open in a text editor such as Notepad, in which you can simply save it.
    • Choose the Save As option from the File menu of the text editor.
    • Choose a file name and a folder in which to save the program. Since the neural network is in the form of a web page, the file name should end in the extension .htm or .html

  • If you are using a browser such as IE8, then the HTML code will appear in a window that doesn't have edit facilities. There is still a save facility on the File menu, which you should use:
    Saving the net in IE

  • Then simply save the file. The web page that is created will run totally independently of this site, and can be included in your own web sites.

Please feel free to change the page that you create in any way. What this program gives you is the barest minimum, so I would encourage you to personalise it as you think fit.

An Example

All a bit too much to take in? Don't worry, here's an example you can follow to get you started. We are going to create a neural net that takes three whole numbers in the range 0 to 100, and tells you whether they are in ascending order, descending order, or no particular order.

Use the Create input controls feature to create three inputs. For the first control, type the caption First and select the Text Slot option (keeping the default upper limit of 100). Then create two more controls, Second and Third, also text slots in the range 0 to 100. After this, your input controls should look like this:

Example inputs

Now create three output controls, each of which is a checkbox. The first one should be called Ascending, the next Descending and the third No order. Your output controls should look like this:

Example inputs
If you check the number of hidden nodes in the box below these, it should read 6 (=3 inputs + 3 outputs). That's fine. Now enter the data shown in the box on the right into the Training text area. (Actually, don't bother typing it in, just copy and paste it). Each line has 6 numbers in it separated by commas. The first three numbers are the input numbers (First, second and third) and the next three are the values for the check boxes (1 = selected, 0 = not selected). So, for the first line, 0,50,100,1,0,0 means that the input numbers 0, 50 and 100 (in that order) should produce a tick for the Ascending checkbox and no ticks for the other two. Feel free to add extra data lines if you think it will improve the performance!

Click on the "Click here to train" button and wait for the count to reach 10,000 (It takes about three minutes on my machine). Then click on the "Click here to display the net" button and try it out!


Go back
Neural network menu