## [mdp-toolkit-users] Problem with growing neural gas

 [mdp-toolkit-users] Problem with growing neural gas From: Vinícius Melo - 2014-04-04 22:02:44 Attachments: Message as HTML ```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() ```

 [mdp-toolkit-users] Problem with growing neural gas From: Vinícius Melo - 2014-04-04 22:02:44 Attachments: Message as HTML ```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() ```
 Re: [mdp-toolkit-users] Problem with growing neural gas From: Pietro Berkes - 2014-04-08 14:37:01 Attachments: Message as HTML ```Dear Vinicius, the growing neural gas algorithm is defined to work on static distributions (see http://web.cs.swarthmore.edu/~meeden/DevelopmentalRobotics/fritzke95.pdf). You would need to tweak it a little bit to work with changing distributions. Mainly, I think you would need to increase the age of all the edges, rather than just the ones close to the latest active node. Best, Pietro On Fri, Apr 4, 2014 at 11:02 PM, Vinícius Melo wrote: > 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() > > > > > > > > > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > mdp-toolkit-users mailing list > mdp-toolkit-users@... > https://lists.sourceforge.net/lists/listinfo/mdp-toolkit-users > > ```