Homework 5: Simple recurrent networks

Due Friday, 2009-05-01

Download these eleven Python modules and one data file. You will edit network.py, adding a new class. 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 and thing.py.

The world

The world this time is populated by four instances each of the classes MWren (purple) and FWren (dark green). The MWrens are like male birds; they sit in one place and sing a constant song that's hard-wired into them. The FWrens are the female birds that move around as they listen to and learn to recognize the songs.

Each of the two songs consists of a sequence of sounds (instances of the class Sound), which are repeated over and over again. There are four different sounds, represented by different methods in the MWren class and different text on the screen.

The FWrens hear any song that is sung within their hearing radius (which you can see if you select "Show senses"). Their hearing sensor represents a sound input locally; that is, there is a separate input unit for each of the four different sounds.

The goal of the FWrens is to learn to predict the next sound they will hear. They do this using their built-in simple recurrent networks, which you have to implement.

What you have to do

  1. Implement simple recurrent networks (Elman nets). You can see what the constructor for an SRN should do by looking at the commented out code in FWren.set_network.
  2. Uncomment FWren.set_network. You can see what an FWren's network looks like by clicking on it. The targets for each output unit (when these are provided) appear above the horizontal line.
  3. The FWRens' SRNs should be trained to predict the next sound they hear. This means that they have to wait till the time step after a sound is heard (when the next sound appears) to train on that sound and that they have to save the last sound. When there is no sound input at all, that is, when the FWren is far from any MWren, the network should not be trained at all. Edit FWren.step to train the SRN, using the method Critter.run_network. You will have to pass a target to this method. Note that Critter.run_network returns the error, and if you increment the FWren's error attribute with this value and also increment the trials attribute, you will see statistics about how well the FWren is learning after each run.
  4. If you have implemented SRNs correctly, the FWrens should become familiar with the two songs after about 25,000 time steps, when the mean error will have dropped to about 0.12. Observe how the SRNs behave when the FWrens approach an MWren, get exposed to its song for awhile, and then move away. Describe and explain the extent to which they succeed in solving the prediction task in these different situations.

Home

Calendar

Coursework

Notes

Code


IU | INFO | CSCI

Contact instructor