“Neural gases” are artificial neural networks for vector quantization. They can learn probability distributions or topologies in general. They were first introduced in 1991 by Thomas Martinez and Klaus Schulten, who are researchers in the field of neuroinformatics. Fast convergence (especially when you are learning a non-static probability distribution as it is the case here) is crucial for applications of vector quantization. As you can see, readability of seconds is an issue. This -of course- can be improved.
The neural gas algorithm is detailed in the original paper1. In this post, I want to give a short explanation based on this clock.
The (euclidian) topologies which are learned in this case are digits, as displayed by digital clocks using a seven-segment LED display. In my code those segments are implemented as simple lines. Every digit is made up of 2-dimensional codebook vectors . These vectors are visualized as the little dots you can see whirling around in the above clock. Here, the codebook vectors are initialized deterministically (Halton sequence). Then, a data vector (i.e. a point situated on one of the line segments of the digit) is chosen randomly. In the following, every single one of the codebook vectors is adapted to .
So, how does this adaptation process work exactly?
After a random point located on a digit is chosen, the distance to is determined for all codebook vectors . Next, they are sorted accordingly in ascending order, such that for is the codebook vector nearest to . For adaptation is (cf. 1):
where increases nonlinearly.
The new position of a “particle” (codebook vector) is computed by adding its old position to a vector pointing from the old position to the data vector weighted by some time-dependent factors (i.e. functions). In detail:
and decay over time:
(A python-version can be found here)