seracio / kohonen

A basic implementation of a Kohonen map in JavaScript
MIT License
13 stars 5 forks source link

Is it possible to provide k.mapping() during training? #42

Closed Fil closed 7 years ago

Fil commented 8 years ago

I'm just trying out this library (thanks for sharing!), and would like to create a demonstrator of the algorithm.

For this I would like to be able to "pause" every few steps and display the current state of the system. log() seems to get the state of the neurons only.

Here's a (very simple and unfinished) demo http://bl.ocks.org/Fil/ae11126ae728cb2af627db6a3dfa756b

nmondon commented 8 years ago

That would be nice indeed! I think we can achieve this by overriding the training method or adding a trainingWithPause generator for instance... I'll give a try this week

    training(log = () => {
    }) {
        for (let i = 0; i < this.maxStep; i++) {
            // generate a random vector
            this.learn(this.generateLearningVector());
            log(this.neurons, this.step);
        }
    }
nmondon commented 7 years ago

I close the issue, as you can add a generator in a subclass to achieve this