Lab 5: Analysing trained networks

Today, you will first install the programme 'R', which is a free software environoment for statistical computing and graphics. R is great for doing statistics, but it is especially wonderful for exploring data visually: something that is of far more value than the generation of meaningless t-tests and ANOVAs. You can get R from this website. Download it and install it in a convenient location on your machine.

It will be to your advantage to learn a bit about R, and to become familiar with its many strengths. But we do not have time to make you experts in this lab. Any R code you need will be provided here. But if there is demand, I am happy to provide further training in using R to anyone who wants. You can also find many self-paced tutorials on the web. The Documentation section of the R website is a good place to start.

Last week, you trained networks using the "duoPart.pat" set of patterns. These are all possible 4-bit vectors, bar two (<0,1,0,0> & <0,1,0,1>). The network was trained to classify these into two classes: those with exactly two "on" bits, and all the others. Today we will use hierarchical clustering to examine the solutions the network found.

# Lets read in the activations  We store them in a variable called "acts"
acts <- read.table("activations.dat")

# Now calculate all pairwise Euclidean distances
d <- dist(acts, method="euclidean")

# Use those to calculate hierarchical clusters
fit <- hclust(d, method="ward.D2")

# Display the results

If you do this on the input patterns (here you go), you get the figure below, in which you can see that every pattern is like every other pattern. At the hidden layer, though, this should look very different.

Do this for a network that generalizes, and one that does not generalize. Can you see from the cluster plot why one works and one doesn't?

In order to interpret the tree you have generated, draw up a table (pen and paper). Make 2 columns, one headed by "1" and one headed by "0". Go to the list of patterns (Lab 4), and make a note of which patterns should produce an output of 1 (that's Patterns 4, 6, 7 etc) and which should produce an output of 0. You might also note which of the patterns that generate a 0 have less than two units on, and which have more.

Now, using your table, inspect the cluster diagram you got. Does it make sense? How many groups are there? Did this network "understand" the problem in the same way you did? Did it identify two classes, or more? How do patterns 5 and 6 fare? Try your best to interpret the cluster diagram as one way of representing the solution that the network found.

A little practice with R

Here are two short tutorials that introduce you gently to R. Work through them at your own pace. The exercise at the end of the first one is entirely optional.

  1. R Tutorial 1 (pdf)
  2. R Tutorial 2 (pdf)

If you like cluster analysis, you might like to try out some further methods. R has lots. Details here.