Creating a Neural Network
We will begin by creating a neural network. The Encog Workbench starts with an empty file. Once things have been added to this empty file, it can be saved to an .EG file. This .EG file can then be loaded by the workbench again or loaded by Java or C# Encog applications. The C# and Java versions of Encog read exactly the same type of .EG files.
To create a neural network, select “Create Object on the “Objects menu”. A small popup window will appear that asks for the type of object to create. Choose “Neural Network” to create a new neural network. This will bring up a window that lets you browse the available types of neural networks to create. These are predefined templates for many of the common neural network types supported by Encog. This window can be seen in Figure 4.4.
Figure 4.4: Create a Neural Network

You will notice that the first option is to create an “Empty Neural Network”. Any of the neural networks shown here could be created this way. You would simply create an empty network and add the appropriate layers, synapses, tags and properties to create the neural network type you wish to create. However, if you would like to create one of the common neural network types, it is much faster to simply use one of these predefined templates. Choose the “Feedforward Neural Network”. You will need to fill in some information about the type of feedforward neural network you would like to create. This dialog box is seen in Figure 4.5.
Figure 4.5: Create a Feedforward Neural Network

We are going to create a simple, neural network that learns the XOR operator. Such a neural network should be created as follows:
- Input Neuron Count: 2
- Output Neuron Count: 2
- Hidden Layer 1 Neuron Count: 1
The two input neurons are necessary because the XOR operator takes two input parameters. The one output neuron is needed because the XOR operator takes one output parameter. This can be seen from the following truth table for the XOR operator.
0 XOR 0 = 0 1 XOR 0 = 1 0 XOR 1 = 1 1 XOR 1 = 0
As you can see from the code above, the XOR operator takes two parameters and produces one value. The XOR operator only returns true, or one, when the two input operators are different. This defines the input and output neuron counts.
The hidden layer count is two. The hidden neurons are necessary to assist the neural network in learning the XOR operator. Two is the minimum number of hidden neurons that can be provided for the XOR operator. You may be wondering how we knew to use two. Usually this is something of a trial and error process. You want to choose the minimum number of hidden neurons that still sufficiently solves the problem. Encog can help with this trial and error process. You will learn about pruning, and other automated techniques for determine good hidden layer counts in Chapter 13, “Pruning and Structuring Networks”.
Now that the feedforward neural network has been created, you will see it in the workbench. Figure 4.6 shows the workbench with a neural network added.
Figure 4.6: Neural Network Added

If you double click the feedforward neural network shown in Figure 4.6, it will open. This allows you to see the layers and synapses. Figure 4.7 shows the feedforward neural network that was just created.
Figure 4.7: The Newly Created Neural Network

The above figure shows how neural networks are edited with Encog. You can add additional layers and synapses. You can also edit other aspects of the neural network, such as properties and the type of neural logic that it uses.
Now that the neural network has been created, a training set should be created. The training set will be used to train the neural network.




