Assignment 5: Regier model exercises
Assigned Thursday, March 1
Due Tuesday, March 13th, in class.

In this homework you will use Terry Regier's program to learn spatial relation terms. You should read the text through Chapter 6 before starting this exercise. If you get stuck at some point in the assignment read through the rest of the assignment before emailing anyone since the answer to what you seek might already be somewhere in the assignment.
Step 1. Getting started

If you have never used UNIX before, or are unsure about some of the basic commands, please see here.

To get started on the assignment, you will need to get and install a copy of the program in your directory. To do this you should:

  1. Log into a PC running Solaris in room 275 Soda. There is a bug that prevents certain output values from displaying properly on these machines, so we recommend logging in remotely from your own computer or from one of the machines in 273 Soda. However, there are probably scheduled lab times for other CS classes in that lab, so check the schedules posted on the second floor for times when you can be in those labs. (After 7PM is usually free for sure.)

    If you do want to log in remotely from a Windows computer, you'll need to use SSH or a similar secure login program, and a remote graphics client like Exceed (Berkeley students may download a full, licensed copy of Exceed from here: http://software-central.berkeley.edu/all/exceed They have to be either on campus or set up a proxy server; directions for the latter are here: http://proxy.lib.berkeley.edu/) (download a trial version of Exceed 2007 from here; instructions for use may be found here). (Another remote graphics client, a.k.a. X-server, that you can use is called Cygwin. You can get it here. The advantage is that it's "free software", so it's a full version, free. The catch is that it may be slightly harder to set up. Personally, this is what I use when I use MS Windows.) If you're using a UNIX-based computer, such as one running OSX, then you should use the X-server that came with your computer; I know for a fact that OSX has an X-server.

    The Regier program only runs on Solaris X86 machines, so you'll need to use either one of the Solaris machines in 275 Soda or one of the following: rhombus.cs, pentagon.cs, po.eecs, torus.cs.

    At this point, if you're in the lab, you may need to open a terminal window if there isn't one already there. If you don't know how to do this, ask someone for help. (A command like "xterm" or "Terminal" should be available in a menu that appears when you click on the desktop with the right mouse button.)

  2. Copy the file space.tar.gz to your directory (don't forget the period at the end):
    cp ~cs182/programs/space.tar.gz .
    (You may also download the file using the link above; save it in your current working directory.)

    Note: if at some point in the process you get a message saying that you are over the disk quota, you should erase some of your previous files from the account, such as the .netscape/cache files.

  3. Uncompress and install the program:
    gunzip space.tar.gz
    tar xvf space.tar
    (be patient -- this may take a little while)
  4. Type cd NonPunctate to get to the directory.
  5. (Optional) Type more ReadMe to read instructions and additional information on running the program. The essential ones are listed here.)

Step 2. Viewing scenes

Each spatial relation term corresponds to a spatial "concept". A concept is composed of a set of possible "scenes". When given a set of scenes that correspond to a concept (say the ABOVE concept), the program is able to learn to label appropriate scenes with the spatial term (ABOVE).

Note: You can type "q" on the window to quit displaying the scenes, or background it (e.g., by initially typing ./do see above & ).
Tip: If the command above doesn't work (e.g., it says Command not found), make sure you are in the correct directory.
Tip: If you get the error message "Exec file format error", it's probably because you're not logged into a machine running Solaris-x86. Use ssh to login to a machine that does run it. For example, type "ssh po.cs" and enter your password as usual, then change to the appropriate directory. Now it should work fine.
Tip: If nothing shows up in the graphics window, try resizing it.

You can use similar commands with other spatial relations terms. For example, the corresponding commands for IN are:

The training data sets for English spatial relations are located in the NonPunctate/Scenes/English/ directory; these include:
above below bigger enclose in left near on out overlap right smaller touch

Step 3. Training on scenes

The scenes you have just seen are used to train the program to recognize images corresponding to the different spatial terms. To train the program to learn the concept ABOVE, type

./do train above

The program should show how its network for ABOVE performs on the training patterns for ABOVE, with the error decreasing over a number of epochs. When prompted for the number of (additional) to continue training, if you are satisfied with the error (the number of bits wrong is low, and the error value is small) then you can stop the program by specifying "0" in response to the prompt:

Enter number of epochs to train: 0

If you are unsatisfied with the error and want to continue training, enter a number of epochs (say, 50) in response:

Enter number of epochs to train: 50

When you eventually enter "0", the program automatically displays the results of the training. The number at the bottom of each scene in the display tells you how strongly the program classifies the scene as belonging to the relevant concept. For instance, a value of "0.9999999" on a scene for ABOVE means that the system has classified that scene as a very good instance of ABOVE. A value of "0.0000001", on the other hand, indicates that the program has classified the scene as not ABOVE.

When you have looked at the trained data, type "ctrl-c" on the terminal. You will now see the trained data for the negative examples of the same concepts. Type "ctrl-c" again when you are done looking at these.

You will be asked if you want to save the weights. Answer yes by entering "1" in response to the following query:

Want to dump weights [0=>no, 1=>yes]? 1

At this point, the network has been trained to recognize ABOVE and can be tested on previously unseen scenes.


Step 4: Testing

Once you have trained the network and saved the weights of the training as explained in Part 3, you can test the network on unseen examples by typing:

./do test above

The program will display the results. Just as in the training case, the number at the bottom of each scene indicates how strongly the program classifies the scene as part of the relevant concept.


What to do and submit
  1. Attempt to train the program on the six following concepts:
    above bigger in left near out overlap
    For each of these concepts:
  2. Now consider the following concepts:
    into between within green alongside around
    Pick 4 out of these 6 concepts. Based on what you know about the features handled by the program, would you expect these concepts to be learnable given appropriate training examples? Would they be learnable by the dynamic version of the program? What additional features would be necessary to allow the system to learn?