Package mdp :: Package nodes :: Class GrowingNeuralGasNode
[hide private]
[frames] | no frames]

Class GrowingNeuralGasNode


Learn the topological structure of the input data by building a
corresponding graph approximation.

More information about the Growing Neural Gas algorithm can be found in
B. Fritzke, A Growing Neural Gas Network Learns Topologies, in G. Tesauro,
D. S. Touretzky, and T. K. Leen (editors), Advances in Neural Information
Processing Systems 7, pages 625-632. MIT Press, Cambridge MA, 1995.

A java implementation is available at:
http://www.neuroinformatik.ruhr-uni-bochum.de/ini/VDM/research/gsn/DemoGNG/GNG.html

Attributes and methods of interest:
graph -- The corresponding Graph object

Nested Classes [hide private]
    Inherited from Node
  __metaclass__
This Metaclass is meant to overwrite doc strings of methods like execute, stop_training, inverse with the ones defined in the corresponding private methods _execute, _stop_training, _inverse, etc...
Instance Methods [hide private]
 
__init__(self, start_poss=None, eps_b=0.2, eps_n=0.006, max_age=50, lambda_=100, alpha=0.5, d=0.995, max_nodes=2147483647, input_dim=None, dtype=None)
Growing Neural Gas algorithm.
 
_add_edge(self, from_, to_)
 
_add_node(self, pos)
 
_get_nearest_nodes(self, x)
Return the two nodes in the graph that are nearest to x and their squared distances.
 
_get_supported_dtypes(self)
Return the list of dtypes supported by this node.
 
_insert_new_node(self)
Insert a new node in the graph where it is more necessary (i.e.
 
_move_node(self, node, x, eps)
Move a node by eps in the direction x.
 
_remove_old_edges(self, edges)
Remove all edges older than the maximal age.
 
_set_input_dim(self, n)
 
_train(self, input)
 
get_nodes_position(self)
 
nearest_neighbor(self, input)
Assign each point in the input data to the nearest node in the graph.

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

    Inherited from Node
 
__add__(self, other)
 
__call__(self, x, *args, **kargs)
Calling an instance of Node is equivalent to call its 'execute' method.
 
__repr__(self)
repr(x)
 
__str__(self)
str(x)
 
_check_input(self, x)
 
_check_output(self, y)
 
_check_train_args(self, x, *args, **kwargs)
 
_execute(self, x)
 
_get_train_seq(self)
 
_if_training_stop_training(self)
 
_inverse(self, x)
 
_pre_execution_checks(self, x)
This method contains all pre-execution checks.
 
_pre_inversion_checks(self, y)
This method contains all pre-inversion checks.
 
_refcast(self, x)
Helper function to cast arrays to the internal dtype.
 
_set_dtype(self, t)
 
_set_output_dim(self, n)
 
_stop_training(self, *args, **kwargs)
 
copy(self, protocol=-1)
Return a deep copy of the node.
 
execute(self, x, *args, **kargs)
Process the data contained in 'x'.
 
get_current_train_phase(self)
Return the index of the current training phase.
 
get_dtype(self)
Return dtype.
 
get_input_dim(self)
Return input dimensions.
 
get_output_dim(self)
Return output dimensions.
 
get_remaining_train_phase(self)
Return the number of training phases still to accomplish.
 
get_supported_dtypes(self)
Return dtypes supported by the node as a list of numpy.dtype objects.
 
inverse(self, y, *args, **kargs)
Invert 'y'.
 
is_invertible(self)
Return True if the node can be inverted, False otherwise.
 
is_trainable(self)
Return True if the node can be trained, False otherwise.
 
is_training(self)
Return True if the node is in the training phase, False otherwise.
 
save(self, filename, protocol=-1)
Save a pickled serialization of the node to 'filename'.
 
set_dtype(self, t)
Set internal structures' dtype.
 
set_input_dim(self, n)
Set input dimensions.
 
set_output_dim(self, n)
Set output dimensions.
 
stop_training(self, *args, **kwargs)
Stop the training phase.
 
train(self, x, *args, **kwargs)
Update the internal structures according to the input data 'x'.
Properties [hide private]

Inherited from object: __class__

    Inherited from Node
  _train_seq
List of tuples: [(training-phase1, stop-training-phase1), (training-phase2, stop_training-phase2), ...
  dtype
dtype
  input_dim
Input dimensions
  output_dim
Output dimensions
  supported_dtypes
Supported dtypes
Method Details [hide private]

__init__(self, start_poss=None, eps_b=0.2, eps_n=0.006, max_age=50, lambda_=100, alpha=0.5, d=0.995, max_nodes=2147483647, input_dim=None, dtype=None)
(Constructor)

 
Growing Neural Gas algorithm.

Input arguments:
start_pos -- sequence of two arrays containing the position of the
             first two nodes in the GNG graph. In unspecified, the
             initial nodes are chosen with a random position generated
             from a gaussian distribution with zero mean and unit
             variance.

eps_b     -- coefficient of movement of the nearest node to a new
             data point. Typical values are 0 < eps_b << 1 .
             Default: 0.2
             
eps_n     -- coefficient of movement of the neighbours of the nearest
             node to a new data point. Typical values are
             0 < eps_n << eps_b .
             Default: 0.006

max_age   -- remove an edge after 'max_age' updates. Typical values are
             10 < max_age < lambda .
             Default: 50

lambda_   -- insert a new node after 'lambda_' steps. Typical values
             are O(100).
             Default: 100

alpha     -- when a new node is inserted, multiply the error of the
             nodes from which it generated by 0<alpha<1. A typical
             value is 0.5.
             Default: 0.5

d         -- each step the error of the nodes are multiplied by 0<d<1.
             Typical values are close to 1.
             Default: 0.995

max_nodes -- maximal number of nodes in the graph.
             Default: 2^31 - 1 

Overrides: object.__init__

_add_edge(self, from_, to_)

 

_add_node(self, pos)

 

_get_nearest_nodes(self, x)

 
Return the two nodes in the graph that are nearest to x and their
squared distances. (Return ([node1, node2], [dist1, dist2])

_get_supported_dtypes(self)

 
Return the list of dtypes supported by this node.

Overrides: Node._get_supported_dtypes

_insert_new_node(self)

 
Insert a new node in the graph where it is more necessary (i.e.
where the error is the largest).

_move_node(self, node, x, eps)

 
Move a node by eps in the direction x.

_remove_old_edges(self, edges)

 
Remove all edges older than the maximal age.

_set_input_dim(self, n)

 
Overrides: Node._set_input_dim

_train(self, input)

 
Overrides: Node._train

get_nodes_position(self)

 

nearest_neighbor(self, input)

 
Assign each point in the input data to the nearest node in
the graph. Return the list of the nearest node instances, and
the list of distances.
Executing this function will close the training phase if
necessary.