Package smile.vq

Class NeuralGas

java.lang.Object
smile.vq.NeuralGas
All Implemented Interfaces:
Serializable, VectorQuantizer

public class NeuralGas extends Object implements VectorQuantizer
Neural Gas soft competitive learning algorithm. Neural Gas is inspired by the Self-Organizing Map (SOM) for finding optimal data representations based on feature vectors. The algorithm was coined "Neural Gas" because of the dynamics of the feature vectors during the adaptation process, which distribute themselves like a gas within the data space. Although it is mainly applied where data compression or vector quantization is an issue, it is also used for cluster analysis as a robustly converging alternative to k-means. A prominent extension is the Growing Neural Gas.

Compared to SOM, Neural Gas has no topology of a fixed dimensionality (in fact, no topology at all). For each input signal during learning, Neural Gas sorts the neurons of the network according to the distance of their reference vectors to the input signal. Based on this "rank order", neurons are adapted based on the adaptation strength that are decreased according to a fixed schedule.

The adaptation step of the Neural Gas can be interpreted as gradient descent on a cost function. By adapting not only the closest feature vector but all of them with a step size decreasing with increasing distance order, compared to k-means, a much more robust convergence of the algorithm can be achieved.

References

  1. Thomas Martinetz and Klaus Schulten. A "neural gas" network learns topologies. Artificial Neural Networks, 397-402, 1991.
  2. T. Martinetz, S. Berkovich, and K. Schulten. "Neural-gas" Network for Vector Quantization and its Application to Time-Series Prediction. IEEE Trans. on Neural Networks, 4(4):558-569, 1993.
  3. T. Martinetz and K. Schulten. Topology representing networks. Neural Networks, 7(3):507-522, 1994.
See Also:
  • Constructor Details

    • NeuralGas

      public NeuralGas(double[][] neurons, TimeFunction alpha, TimeFunction theta, TimeFunction lifetime)
      Constructor.
      Parameters:
      neurons - the initial neurons.
      alpha - the learning rate function.
      theta - the neighborhood function.
      lifetime - the neuron connection lifetime, usually the number of iterations for one or two epochs.
  • Method Details

    • seed

      public static double[][] seed(int k, double[][] samples)
      Selects random samples as initial neurons of Neural Gas.
      Parameters:
      k - the number of neurons.
      samples - some samples to select initial weight vectors.
      Returns:
      the initial neurons.
    • neurons

      public double[][] neurons()
      Returns the neurons.
      Returns:
      the neurons.
    • network

      public Graph network()
      Returns the network of neurons.
      Returns:
      the network of neurons.
    • update

      public void update(double[] x)
      Description copied from interface: VectorQuantizer
      Update the codebook with a new observation.
      Specified by:
      update in interface VectorQuantizer
      Parameters:
      x - a new observation.
    • quantize

      public double[] quantize(double[] x)
      Description copied from interface: VectorQuantizer
      Quantize a new observation. Returns Optional.empty if the observation is noise.
      Specified by:
      quantize in interface VectorQuantizer
      Parameters:
      x - a new observation.
      Returns:
      the quantized vector.