javaneural-networkself-organizing-maps

Example Java code for Kohonen filter using apache.commons.math.ml


I am looking for any example code for implementing Kohonen SOM using the apache.commons.math3.neuralnet.sofm classes. To make the question less ambiguous, I'll share that I plan to explore using it to find anomalous features in image patches.
I've looked in the javadocs for ml.neuralnet.sofm.KohonenTrainingTask and the ml.neuralnet.Network that it uses, but as a beginner I find them confusing as there is little detail on the semantics of many of the parameters. The math4 docs are the same. So some example code could provide some insight.

Thus my question: is there any example code available?

There is a similar question on stack overflow but it is a couple of years old and no answer except for a broken link.

By the way, I am not locked in to apache.commons.math so if the answer is "no" that will be marked as correct. But in that case I would sincerely appreciate any insight into what alternative packages are in mainstream use for this purpose.


Solution

  • There is one source published at an ACCU Conference from 2006, written by the original authors of JKNNL (java kohonen neural network library). Although it does not directly tie into the apache commons library, it includes a self contained description of Kohonen filter which can shed light on the semantics used there.

    As no true JAVA example code exists, we can look to this documentation for insight as requested in the asked question.

    It can be thought of as an unsupervised classifier utilizing single layer NN in which the weights of each node are vectors that correspond to the center of a cluster (after classification).

    The feedback is applied to only the nearest node (in the winner take all method) and is a weighted average of the input and the current "weight" in the node

    weight[i] = (1-C)*weight[i] + C*input[i]
    

    where C is the learning rate parameter. When convergence is attained, each node will have its own set of weights and classification can be performed by finding the node for which the distance between the weights and the input vector are the smallest.