Class Kohonen

  • All Implemented Interfaces:
    java.io.Serializable

    public class Kohonen
    extends UnsupervisedLearning
    Kohonen's Self-organizative Maps or SOM or Kohonen. This maps are one of the most important unsupervised neural networks of the history. The most important feature of the kohonen's maps is the possibility of transform any multidimensional space into a R^2 space, providing a highly precise clustering method. One of the most famous examples for the kohonen's maps is the transform the RGB color cube into a plane where the reds, greens, blues, etc are clustered in a very similar way of the any color picker utility.
    See Also:
    Serialized Form
    • Constructor Detail

      • Kohonen

        public Kohonen​(int[] nperlayer,
                       double neighborhood,
                       int[] neighboursX,
                       int[] neighboursY)
        Constructor. Creates a kohonen's map with nperlayer[0] inputs, nperlayer[1] rows and nperlayer[2] columns. Additional set the initial size of the neighborhood and the way in the neighbors are connected.
        Parameters:
        nperlayer - Number of neurons (input, rows and columns)
        neighborhood - Initial size of the neighborhood
        neighboursX - neighbors along the X-axis
        neighboursY - neighbors along the Y-axis
      • Kohonen

        public Kohonen​(int[] nperlayer,
                       double neighborhood,
                       int[] neighboursX,
                       int[] neighboursY,
                       java.util.Random rand)
        Constructor. Creates a kohonen's map with nperlayer[0] inputs, nperlayer[1] rows and nperlayer[2] columns. Additional set the initial size of the neighborhood and the way in the neighbors are connected.
        Parameters:
        nperlayer - Number of neurons (input, rows and columns)
        neighborhood - Initial size of the neighborhood
        neighboursX - neighbors along the X-axis as deltas from origin eg. +1, 0, -1, 2
        neighboursY - neighbors along the Y-axis as deltas from origin eg. +1, 0, -1, 2
        rand - Random generator used for creating matrices
      • Kohonen

        public Kohonen​(int[] nperlayer,
                       double neighborhood)
        Constructor. Creates a kohonen's map using the standard neighborhood (up, down, left, right). Alias of Kohonen(nperlayer, _neighborhood, new int[]{0,0,1,-1}, new int[]{-1,1,0,0});
        Parameters:
        nperlayer - Number of neurons (input, rows and columns)
        neighborhood - Initial size of the neighborhood
      • Kohonen

        public Kohonen​(int[] nperlayer,
                       double neighborhood,
                       java.util.Random random)
        Constructor. Creates a kohonen's map using the standard neighborhood (up, down, left, right). Alias of Kohonen(nperlayer, _neighborhood, new int[]{0,0,1,-1}, new int[]{-1,1,0,0});
        Parameters:
        nperlayer - Number of neurons (input, rows and columns)
        neighborhood - Initial size of the neighborhood
        random - Random generator used for creating matrices
    • Method Detail

      • train

        public void train​(Column[] patterns,
                          double alpha,
                          int epochs,
                          int offset,
                          int length)
        Train the map. The answers are omitted for the training process but are necessary for the labeling of the map.
        Specified by:
        train in class UnsupervisedLearning
        Parameters:
        patterns - The patterns to be learned.
        alpha - The learning rate.
        epochs - The maximum number of iterations
        offset - The first pattern position
        length - How many patterns will be used.
      • simulate

        public Column simulate​(Column pattern)
        Description copied from class: NeuralNetwork
        Calculates the output for the pattern.
        Specified by:
        simulate in class NeuralNetwork
        Parameters:
        pattern - Pattern to use as input.
        Returns:
        The output for the neural network.
      • simulate

        public void simulate​(Column pattern,
                             Column result)
        Description copied from class: NeuralNetwork
        Calculates the output for the pattern and left the result in result.
        Specified by:
        simulate in class NeuralNetwork
        Parameters:
        pattern - Pattern to use as input.
        result - The output for the input.
      • getPrototypeAt

        public Column getPrototypeAt​(int i,
                                     int j)
      • getMap

        public int[][] getMap()
        Returns:
        The label map.
      • expandMap

        public void expandMap​(Column[] patterns,
                              Column[] answers,
                              int offset,
                              int length)
        Label the output for the patterns and expand the results through the neighbors until the map is completely fill. NOTE: The expansion isn't an standard process but is very helpful to avoid unknown answers.
        Parameters:
        patterns - The patterns to label
        answers - The expected answer for the patterns
        offset - The initial pattern position
        length - How many patterns to label.