C++ Neural Networks and Fuzzy Logic
by Valluru B. Rao M&T Books, IDG Books Worldwide, Inc. ISBN: 1558515526 Pub Date: 06/01/95 |
Previous | Table of Contents | Next |
The flow of the program is very similar to the backpropagation simulator. The criterion for ending the simulation in the Kohonen program is the average winner distance. This is a Euclidean distance measure between the input vector and the winners weight vector. This distance is the square root of the sum of the squares of the differences between individual vector components between the two vectors.
Once you compile the program, you need to create an input file to try it. We will first use a very simple input file and examine the results.
Let us create an input file, input.dat, which contains only two arbitrary vectors:
0.4 0.98 0.1 0.2 | |
0.5 0.22 0.8 0.9 | |
The file contains two four-dimensional vectors. We expect to see output that contains a different winner neuron for each of these patterns. If this is the case, then the Kohonen map has assigned different categories for each of the input vectors, and, in the future, you can expect to get the same winner classification for vectors that are close to or equal to these vectors.
By running the Kohonen map program, you will see the following output (user input is italic):
Please enter initial values for: alpha (0.01-1.0), and the neighborhood size (integer between 0 and 50) separated by spaces, e.g. 0.3 5 0.3 5 Now enter the period, which is the number of cycles after which the values for alpha the neighborhood size are decremented choose an integer between 1 and 500 , e.g. 50 50 Please enter the maximum cycles for the simulation A cycle is one pass through the data set. Try a value of 500 to start with 500 Enter in the layer sizes separated by spaces. A Kohonen network has an input layer followed by a Kohonen (output) layer 4 10 done >average dist per cycle = 0.544275 <- >dist last cycle = 0.0827523 <- ->dist last cycle per pattern= 0.0413762 <- >total cycles = 11 <- >total patterns = 22 <-
The layer sizes are given as 4 for the input layer and 10 for the Kohonen layer. You should choose the size of the Kohonen layer to be larger than the number of distinct patterns that you think are in the input data set. One of the outputs reported on the screen is the distance for the last cycle per pattern. This value is listed as 0.04, which is less than the terminating value set at the top of the kohonen.cpp file of 0.05. The map converged on a solution. Let us look at the file, kohonen.dat, the output file, to see the mapping to winner indexes:
cycle pattern win index neigh_size avg_dist_per_pattern 0 0 1 5 100.000000 0 1 3 5 100.000000 1 2 1 5 0.304285 1 3 3 5 0.304285 2 4 1 5 0.568255 2 5 3 5 0.568255 3 6 1 5 0.542793 3 7 8 5 0.542793 4 8 1 5 0.502416 4 9 8 5 0.502416 5 10 1 5 0.351692 5 11 8 5 0.351692 6 12 1 5 0.246184 6 13 8 5 0.246184 7 14 1 5 0.172329 7 15 8 5 0.172329 8 16 1 5 0.120630 8 17 8 5 0.120630 9 18 1 5 0.084441 9 19 8 5 0.084441 10 20 1 5 0.059109 10 21 8 5 0.059109
In this example, the neighborhood size stays at its initial value of 5. In the first column you see the cycle number, and in the second the pattern number. Since there are two patterns per cycle, you see the cycle number repeated twice for each cycle.
The Kohonen map was able to find two distinct winner neurons for each of the patterns. One has winner index 1 and the other index 8.
Previous | Table of Contents | Next |