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

Class XSFANode


Perform Non-linear Blind Source Separation using Slow Feature Analysis. This node is designed to iteratively extract statistically independent sources from (in principle) arbitrary invertible nonlinear mixtures. The method relies on temporal correlations in the sources and consists of a combination of nonlinear SFA and a projection algorithm. More details can be found in the reference given below (once it's published).

The node has multiple training phases. The number of training phases depends on the number of sources that must be extracted. The recommended way of training this node is through a container flow:

>>> flow = mdp.Flow([XSFANode()])
>>> flow.train(x)

doing so will automatically train all training phases. The argument x to the Flow.train method can be an array or a list of iterables (see the section about Iterators in the MDP tutorial for more info). If the number of training samples is large, you may run into memory problems: use data iterators and chunk training to reduce memory usage.

If you need to debug training and/or execution of this node, the suggested approach is to use the capabilities of BiMDP. For example:

>>> flow = mdp.Flow([XSFANode()])
>>> tr_filename = bimdp.show_training(flow=flow, data_iterators=x)
>>> ex_filename, out = bimdp.show_execution(flow, x=x)

this will run training and execution with bimdp inspection. Snapshots of the internal flow state for each training phase and execution step will be opened in a web brower and presented as a slideshow.


Reference

Sprekeler, H., Zito, T., and Wiskott, L. (2009). An Extension of Slow Feature Analysis for Nonlinear Blind Source Separation. Journal of Machine Learning Research. http://cogprints.org/7056/1/SprekelerZitoWiskott-Cogprints-2010.pdf

Instance Methods [hide private]
 
__init__(self, basic_exp=None, intern_exp=None, svd=False, verbose=False, input_dim=None, output_dim=None, dtype=None)
Initializes an object of type 'XSFANode'.
 
_check_train_args(self, x)
 
_execute(self, x)
 
_get_source_extractor(self, dim, nsources)
 
_get_train_seq(self)
 
_initialize_internal_flow(self)
 
_set_input_dim(self, n)
 
_stop_training(self)
 
_train(self, x)
 
execute(self, x)
Process the data contained in x.
 
stop_training(self)
Stop the training phase.
 
train(self, x)
Update the internal structures according to the input data x.

Inherited from unreachable.newobject: __long__, __native__, __nonzero__, __unicode__, next

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

    Inherited from Node
 
__add__(self, other)
 
__call__(self, x, *args, **kwargs)
Calling an instance of Node is equivalent to calling its execute method.
 
__repr__(self)
repr(x)
 
__str__(self)
str(x)
 
_check_input(self, x)
 
_check_output(self, y)
 
_get_supported_dtypes(self)
Return the list of dtypes supported by this node.
 
_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)
 
copy(self, protocol=None)
Return a deep copy of the node.
 
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.
 
has_multiple_training_phases(self)
Return True if the node has multiple training phases.
 
inverse(self, y, *args, **kwargs)
Invert y.
 
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. If filename is None, return a string.
 
set_dtype(self, t)
Set internal structures' dtype.
 
set_input_dim(self, n)
Set input dimensions.
 
set_output_dim(self, n)
Set output dimensions.
Static Methods [hide private]
 
is_invertible()
Return True if the node can be inverted, False otherwise.
    Inherited from Node
 
is_trainable()
Return True if the node can be trained, False otherwise.
Properties [hide private]
  flow
Read-only internal flow property.

Inherited from object: __class__

    Inherited from Node
  _train_seq
List of tuples:
  dtype
dtype
  input_dim
Input dimensions
  output_dim
Output dimensions
  supported_dtypes
Supported dtypes
Method Details [hide private]

__init__(self, basic_exp=None, intern_exp=None, svd=False, verbose=False, input_dim=None, output_dim=None, dtype=None)
(Constructor)

 
Initializes an object of type 'XSFANode'.
Parameters:
  • basic_exp (tuple) - A tuple (node, args, kwargs) defining the node used for the basic nonlinear expansion. It is assumed that the mixture is linearly invertible after this expansion. The higher the complexity of the nonlinearity, the higher are the chances of inverting the unknown mixture. On the other hand, high complexity of the nonlinear expansion increases the danger of numeric instabilities, which can cause singularities in the simulation or errors in the source estimation. The trade-off has to be evaluated carefully. Default: (mdp.nodes.PolynomialExpansionNode, (2, ), {})
  • intern_exp (tuple) - A tuple (node, args, kwargs) defining the node used for the internal nonlinear expansion of the estimated sources to be removed from the input space. The same trade-off as for basic_exp is valid here. Default: (mdp.nodes.PolynomialExpansionNode, (10, ), {})
  • svd (bool) - Enable Singular Value Decomposition for normalization and regularization. Use it if the node complains about singular covariance matrices. Default: False
  • verbose (bool) - Show some progress during training. Default: False
  • input_dim (int) - Dimensionality of the input. Default is None.
  • output_dim (int) - Dimensionality of the output. Default is None.
  • dtype (numpy.dtype or str) - Datatype of the input. Default is None.
Overrides: object.__init__

_check_train_args(self, x)

 
Overrides: Node._check_train_args

_execute(self, x)

 
Overrides: Node._execute

_get_source_extractor(self, dim, nsources)

 

_get_train_seq(self)

 
Overrides: Node._get_train_seq

_initialize_internal_flow(self)

 

_set_input_dim(self, n)

 
Overrides: Node._set_input_dim

_stop_training(self)

 
Overrides: Node._stop_training

_train(self, x)

 
Overrides: Node._train

execute(self, x)

 

Process the data contained in x.

If the object is still in the training phase, the function stop_training will be called. x is a matrix having different variables on different columns and observations on the rows.

By default, subclasses should overwrite _execute to implement their execution phase. The docstring of the _execute method overwrites this docstring.

Overrides: Node.execute

is_invertible()
Static Method

 
Return True if the node can be inverted, False otherwise.
Overrides: Node.is_invertible
(inherited documentation)

stop_training(self)

 

Stop the training phase.

By default, subclasses should overwrite _stop_training to implement this functionality. The docstring of the _stop_training method overwrites this docstring.

Overrides: Node.stop_training

train(self, x)

 

Update the internal structures according to the input data x.

x is a matrix having different variables on different columns and observations on the rows.

By default, subclasses should overwrite _train to implement their training phase. The docstring of the _train method overwrites this docstring.

Note: a subclass supporting multiple training phases should implement the same signature for all the training phases and document the meaning of the arguments in the _train method doc-string. Having consistent signatures is a requirement to use the node in a flow.

Overrides: Node.train

Property Details [hide private]

flow

Read-only internal flow property.
Get Method:
unreachable.flow(self) - Read-only internal flow property.