Homework 3: Hopfield networks

Due Wednesday, 2009-04-01

Download these eleven Python modules and one data file. You will edit network.py, adding new classes. In addition, you will make a minor edit to thing.py. Unless you make other changes to other modules, you only need to submit network.py.

How the program starts off

In the world this time, there is only one critter, an instance of the class Anemone, which continually executes the action turn_move in order to explore its world. It has six feelers (an instance of the Feel class) and a binary smell sensor, which doesn't respond to intensity but detects the type of smell. In addition there are nine instances of the class Plasmoid, each of which has a "texture" (indicated by its color) and "odor" (indicated by its shape). The anemone can distinguish the three textures and two odors that plasmoids have, so its binary sensory input vector consists of twenty numbers (+1 or -1 for this assignment), three for each of the six feelers and two for the smell sensor.

The anemone has a neural network, which you can see by clicking on it. This starts out as the default neural network but will change once you have implemented Hopfield networks and uncommented Anemone.set_network().

There are seven "special" sensory patterns which are (for some reason) significant for the anemone, and, when learning is turned on ("Learn" is selected in the "Learn/Evolve" menu), it checks to see if its sensory input matches any of these patterns (within a tolerance that is associated with each of the patterns). If it is, it should store the current input in its Hopfield net. If it is not, or if learning is not turned on, it just runs its Hopfield net. The idea is that once the special patterns are learned, the anemone can use its Hopfield net to help it interpret input patterns. Note that the textures and odors are assigned randomly to the nine plasmoids when they are created, so which of the special sensory patterns end up being detected will vary from run to run.

What you have to do

  1. Implement Hopfield nets.

    A Hopfield network really has only one layer, but, to remain compatible with the other kinds of neural networks in biomorph, we will treat it as though it has an input layer, which is clamped to the sensory input, and an output layer, the same size as the input layer. When the network is running (as opposed to learning), the sensory input is also applied to the output layer, which is then allowed to settle. When the network is learning, the sensory input is again applied to the output layer, and the weights are adjusted (no settling takes place).

    You will need to create a subclass of Network called HopfieldNetwork. It must at least assign the attribute has_bias to False. You can see in Anemone.set_network that the constructor for HopfieldNetwork only requires a name and a number of units.

    Once you have implemented Hopfield networks, you need to uncomment Anemone.set_network().

  2. Observe what states the network settles into after it has been exposed to several of the special sensory patterns. In what ways does the network function as a proper content-addressable memory? In what ways does it fail?

Home

Calendar

Coursework

Notes

Code


IU | INFO | CSCI

Contact instructor