A Hopfield neural network is typically used for pattern recognition. The user trains the network with a set of black-and-white templates; for each template, each neuron in the network (corresponding to one pixel) learns to turn itself on or off based on the current output of every other neuron in the network. After training, the network can be provided with an arbitrary input pattern, and (in theory) will provide an output pattern resembling whichever template most closely matches this input pattern.
This is the theory behind Hopfield neural networks. The reality is somewhat different: many factors complicate the recognition process. The network provides garbled output if it is provided too many training templates, or if the network has too few or too many neurons. If two training templates are very similar, the network tends to produce an amalgam of them as output. In practice, these factors are avoided by carefully customizing the network for a particular task.
This application is a general-purpose implementation of a Hopfield neural network. The application allows the user to choose a network size, draw training templates for the network to absorb, and then ask the network to recognize particular input patterns. The results will likely reflect the difficulties mentioned above. The application has the capability of saving or restoring the neural network, as well as any particular training pattern.
Installation Instructions: Nothing unusual - simply run the enclosed executable. Note that the application relies on a couple of XML schema definition (.XSD) files in the Schema Files folder located with the executable - don't rename or edit them.
Operation Instructions:
The use of the Hopfield network consists of three steps: creating the network, providing some template patterns, and using the network for analysis of new patterns.
Creating the network: Choose a height and width for the network. These parameters should match the size of the bitmap input patterns in pixels. You may also select a name for the network.
Training the network: The network is trained by providing a set of input templates. Each template is created by drawing a pattern in the "Input Pattern" box; clicking on various squares turns them on and off, and all pixels can be turned off by clicking the "Clear" button. The pattern may be saved, and previously designed patterns can be loaded (click the "Save" and "Load" buttons in the "Configure Input Pattern" group box.) Each pattern is added to the network by clicking the "Add Pattern as Template" button.
Using the network: Once the network is trained, the user may provide a new input pattern (either by drawing it, or by simply clicking the "Randomize" button to create a random pattern of pixels) and analyze it by clicking the "Analyze Pattern" buttons. The output pattern displays the closest match, based on the known templates. Although the network usually reaches a conclusion in one step, particular kinds of patterns may take several steps to resolve. Thus, clicking "Analyze Pattern (Full)" causes the network to run until it fully resolves the pattern; clicking "Analyze Pattern (Step)" causes the network to run exactly once for each pixel and display the results.
Finally, the trained network may be saved or loaded by clicking the "Save" and "Load" buttons in the "Configure Network" group box.
The network display: The nodes of the network are displayed at right. The application periodically cycles through every neuron (drawn in green) and shows its synaptic relationship with every other neuron in the network. Those that exert an excitatory influence on the selected neuron are colored red; those that exert an inhibitory influence are colored blue. Also, the total value of all neurons in the network can be displayed by clicking the "Analyze" button.
Comments: Experimenting with this generic Hopfield neural network is likely to be illustrative of the strengths and weaknesses of this type of neural network. The analysis step - where the "rubber meets the road" - is heavily dependent on many factors, as noted above. It is particularly noteworthy that any pattern may match either a template or its exact inverse - these output patterns appear equivalent to this kind of network.
Application History: This application was designed during an artificial intelligence class taught by Dr. Toshinori Munakata at Cleveland State University in Fall, 2004. It was not written or submitted as a class assignment, but merely as a study guide to understand a lecture topic. (Hence, the code may be a bit less organized than other programs written for class during this period.) Nevertheless, the application may be of interest to students of object-oriented code design, since it is written as a generic Hopfield neural network class (featuring smaller classes for neurons and synapses) and a front-end class for the simulator that operates on an embedded Hopfield neural-network object. Also, the application may be of interest to novices in XML, since it reads and writes data as XML and validates them against schema definition files.
Questions/Comments: Please contact David J. Stein, Esq. via email at djs10@po.cwru.edu.
Terms and Conditions of Use: Please see the enclosed "License.html" file for terms and conditions of use of this software package.