At the forefront of Artificial Intelligence
  Home Articles Reviews Interviews JDK Glossary Features Discussion Search
Home » Articles » Neural Networks » Applications

Applying Kohonen Networks

This article will extend our introductory look at Kohonen networks by looking how to apply them. We will focus on two applications: a simple mapping of colours and a less trivial example looking at how to analyze images.

Colours

Colour cube The Kohonen network's most powerful feature is its vector quantisation. Kohonen networks can greatly reduce multi-dimensional data, allowing for easier visualization and processing. As a trivial example, let us look at how we would visualize colours on a two- dimensional plane. Colour is normally 3-dimensional, represented as red, green and blue components (shown right).

Representing this on two dimensions is harder to do, but we can teach a Kohonen network to self-organize across the RGB space. We can take two approaches, either by presenting a set number of colours repeatedly or by presenting a randomly selected colour.

Each Kohonen node has three weights, one for each colour component. Weights are normalized to be between 0.0 and 1.0. To visualize the network, we can multiply each of the weights by 255 to give us the colour the node fires for. Here are two screenshots of the Kohonen demonstration applet, showing the initial colour spread and the colours after the training algorithm:

Random colour Colour data set

The circles in the images show the exact neuron that fires for each of the 16 colours the network is trained on. To watch the applet yourself, click on the image above and select "Colour dataset" from the demonstration options. For something a little more ambitious, instead of limiting the network training instances to 16 set colours, we can randomly select a colour every time we train the network. The following image shows this:

Random colour All colours

Again, you may view this example yourself by clicking on the picture above and selecting "Random colours" from the demonstrations. As a indication of regions, the applet still draws the circles of the neurons that fire for the colour dataset. You can see that the regions are much less distinct, but the network can directly represent a larger number of colours.

Image Analysis

While the colour example is a good example of the Kohonen network's vector quantisation, it is rather contrived. I was inspired by Casey Chesnut's article to write a slightly more ambitious example program: a simple image analysis program.

I chose pictures of some of my favourite cars, since many automotive images are quite similar in their features and presentation. After downloading about 200 images (and turning them into thumbnails of about 200x150 pixels each), I used the Generation5 JDK to create a Kohonen network with 80-feature input vector from each image.

Each image has its histogram mean and standard deviations (for each colour component) calculated and added to the feature vector. The image is then run through a Sobel edge detector, and has its histogram calculated. The mean and standard deviation of this histogram is also added, making a total of 8 features. The image is then broken up into 9 subregions, which has the same features calculated and added to the feature vector, making a total of 80 features.

The Kohonen network is then trained on these 200-odd training vectors. I took a similar route to Casey, by making the size of the network relatively small (about 6x6) to force multiple images to be mapped on to the same node, helping to find similar images.

Visualizing the network is a little harder than the colour case, since image data itself isn't stored (features of images are). Therefore, to visualize the image, the program runs each training vector through the Kohonen network to see which neuron fires. The associated image is then rendered in that position. Remember though that the network can be deliberately "constricted" to force similar images to fire the same neuron, so the program renders up to four images per neuron.

Below is example output from the program. The central image is the output from the program, with certain areas blown up:

Kohonen mapping similar images

Anti-clockwise from the top-left: images with a strong white background group together, similar images of a red Jaguar XJ220 group together (strangely, along with an image of an SLR), these two pictures of a yellow BMW M3 are from different image sets but group together nicely nonetheless, these three similar images of an M6 despite being from different angles, and finally not all associations seem immediately obvious (Subura Impreza rally car and Ferrari Modena showroom?)!

While the results aren't perfect, you can see how the network can find easily arrange itself across highly multidimensional data. The network is also extremely quick in learning. Remember, the Generation5 JDK is not optimized for speed and is implemented in Java—nevertheless, 200 images were loaded, analyzed in 80 different ways, and the Kohonen network was trained over 1000 iterations in both phases in less than 15 seconds on a 2.8 Ghz machine.

Classifying New Images

While grouping similar images is interesting, it is even more interesting to see how the network classifies new images. The example program also has a method to take a new image and find any similar images using the network. It does this by creating a feature vector for the new image, presenting it to the network, then looping through the training examples to find any images that fire the same neuron. For example, given this new image of a black BMW M6:

Example image

The network finds 9 similar images, 8 of which are shown below. You can see how the network is picking up on the strong black background present in the images:

Similar images

Source code: I will make the source code available soon, once I have cleaned it up. I will hopefully put a GUI on top of it, to make the process a little more interactive.

Conclusion

Kohonen networks are an excellent method of reducing the dimensionality of data, and can find relationships within feature vectors without any sort of supervised training, making them extremely fun to play with. Readers interested in playing more should check out the Generation5 JDK which provides an extremely easy method of creating and training your own Kohonen networks. I'd also recommend Casey's article, since he took this idea much further and had much better results.

Submitted: 27/12/2004

Article content copyright © James Matthews, 2004.
 Article Toolbar
Print
BibTeX entry

Search

Latest News
- New Generation5 Design! (09/04/2007)
- Happy New Year 2007 (02/01/2007)
- Where has Generation5 Gone?! (04/11/2005)
- NeuroEvolving Robotic Operatives (NERO) (25/06/2005)
- Senior Next-Gen Console Programmer at Infinity Ward (25/06/2005)

What's New?
- An Introduction to Hough Transforms (06/01/2008)
- Kohonen-based Image Analysis using the Generation5 JDK (12/12/2007)
- Back-propagation for the Uninitiated (10/04/2007)
- Perceptrons (09/04/2007)
- Modelling Bacteria using the Generation5 JDK (01/04/2007)


All content copyright © 1998-2007, Generation5 unless otherwise noted.
- Privacy Policy - Legal - Terms of Use -