Hi,

I am testing GNG with the code below, based on the original sample code from http://mdp-toolkit.sourceforge.net/code/examples/gng/gng.html

The idea is to cluster using a set of points and then change the points so gng adapts to the new set. But, it is not working correctly. Neurons are not dying then gng is not adapting to the new sample.

How can I solve this?

Thanks.

Vinícius



# -*- coding: utf-8 -*-

# Generated by codesnippet sphinx extension on 2012-10-04


import mdp

import numpy as np

from time import sleep

import matplotlib.pylab as pyl

import matplotlib.pyplot as plt

import matplotlib.animation as animation

from PyQt4.QtGui import QApplication


def circumference_distr(center, radius, n):

"""Return n random points uniformly distributed on a circumference."""

phi = uniform(0, 2*mdp.numx.pi, (n,1))

x = radius*mdp.numx.cos(phi)+center[0]

y = radius*mdp.numx.sin(phi)+center[1]

return mdp.numx.concatenate((x,y), axis=1)



N = 30


cf1 = circumference_distr([6,-0.5], 2, N)

cf2 = circumference_distr([3,-2], 0.3, N)


x = cf1



gng = mdp.nodes.GrowingNeuralGasNode(max_nodes=10, max_age=20, lambda_=40, eps_b=.1, eps_n=1e-2)


fig1 = plt.figure()


plt.ion()

plt.hold(True)


for i in range(0,120,1):

gng.train(x)


fig1.clear()


nodes = gng.get_nodes_position()


plt.scatter(nodes[:,0], nodes[:,1], s=50, marker="x")

plt.scatter(x[:,0], x[:,1], marker="o", s=5, linewidths=2, c="none")

if i > 30: x = cf2

QApplication.processEvents()

sleep(0.001)


gng.stop_training()