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

Class GSFANode


This node implements "Graph-Based SFA (GSFA)", which is the main component of hierarchical GSFA (HGSFA).

For further information, see: Escalante-B A.-N., Wiskott L, "How to solve classification and regression problems on high-dimensional data with a supervised extension of Slow Feature Analysis". Journal of Machine Learning Research 14:3683-3719, 2013

Instance Methods [hide private]
 
__init__(self, input_dim=None, output_dim=None, dtype=None, block_size=None, train_mode=None, verbose=False)
Initializes the GSFA node, which is a subclass of the SFA node.
 
_execute(self, x, n=None)
Compute the output of the slowest functions.
 
_inverse(self, y)
This function uses a pseudoinverse of the matrix sf to approximate an inverse to the transformation.
 
_set_range(self)
 
_stop_training(self, debug=False, verbose=None)
 
_train(self, x, block_size=None, train_mode=None, node_weights=None, edge_weights=None, verbose=None)
This is the main training function of GSFA.
 
execute(self, x, n=None)
Compute the output of the slowest functions. If 'n' is an integer, then use the first 'n' slowest components.
 
inverse(self, y)
This function uses a pseudoinverse of the matrix sf to approximate an inverse to the transformation.
 
stop_training(self, debug=False, verbose=None)
Stop the training phase.
 
train(self, x, block_size=None, train_mode=None, node_weights=None, edge_weights=None, verbose=None)
This is the main training function of GSFA.

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)
 
_check_train_args(self, x, *args, **kwargs)
 
_get_supported_dtypes(self)
Return the list of dtypes supported by this node.
 
_get_train_seq(self)
 
_if_training_stop_training(self)
 
_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_input_dim(self, n)
 
_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.
 
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]
    Inherited from Node
 
is_invertible()
Return True if the node can be inverted, False otherwise.
 
is_trainable()
Return True if the node can be trained, False otherwise.
Properties [hide private]

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, input_dim=None, output_dim=None, dtype=None, block_size=None, train_mode=None, verbose=False)
(Constructor)

 

Initializes the GSFA node, which is a subclass of the SFA node.

The parameters block_size and train_mode are not necessary and it is recommended to skip them here and provide them as parameters to the train method. See the _train method for details.

Overrides: object.__init__

_execute(self, x, n=None)

 
Compute the output of the slowest functions.
If 'n' is an integer, then use the first 'n' slowest components.

Overrides: Node._execute

_inverse(self, y)

 
This function uses a pseudoinverse of the matrix sf to approximate
an inverse to the transformation.

Overrides: Node._inverse

_set_range(self)

 

_stop_training(self, debug=False, verbose=None)

 
Overrides: Node._stop_training

_train(self, x, block_size=None, train_mode=None, node_weights=None, edge_weights=None, verbose=None)

 
This is the main training function of GSFA.

x: training data (each sample is a row)

The semantics of the remaining parameters depends on the training mode
(train_mode) parameter in order to train as in standard SFA:
    set train_mode="regular" (the scale of the features should be
    corrected afterwards)
in order to train using the clustered graph:
    set train_mode="clustered". The cluster size is given by block_size
    (integer). Variable cluster sizes are possible if block_size is a
    list of integers. Samples belonging to the same class should be
    adjacent.
in order to train for classification:
    set train_mode=("classification", labels, weight), where labels is
     an array with the class information and weight is a scalar value
     (e.g., 1.0).
in order to train for regression:
    set train_mode=("serial_regression#", labels, weight), where # is
    an integer that specifies the block size used by a serial graph,
    labels is an array with the label information and weight is a
    scalar value.
in order to train using a graph without edges:
    set train_mode="unlabeled".
in order to train using the serial graph:
    set train_mode="serial", and use block_size (integer) to specify
    the group size.
in order to train using the mixed graph:
    set train_mode="mixed", and use block_size (integer) to specify
    the group size.
in order to train using an arbitrary user-provided graph:
    set train_mode="graph", specify the node_weights (numpy 1D array),
    and the edge_weights (numpy 2D array).

Overrides: Node._train

execute(self, x, n=None)

 
Compute the output of the slowest functions. If 'n' is an integer, then use the first 'n' slowest components.
Overrides: Node.execute

inverse(self, y)

 
This function uses a pseudoinverse of the matrix sf to approximate an inverse to the transformation.
Overrides: Node.inverse

stop_training(self, debug=False, verbose=None)

 

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, block_size=None, train_mode=None, node_weights=None, edge_weights=None, verbose=None)

 
This is the main training function of GSFA.

x: training data (each sample is a row)

The semantics of the remaining parameters depends on the training mode
(train_mode) parameter in order to train as in standard SFA:
    set train_mode="regular" (the scale of the features should be
    corrected afterwards)
in order to train using the clustered graph:
    set train_mode="clustered". The cluster size is given by block_size
    (integer). Variable cluster sizes are possible if block_size is a
    list of integers. Samples belonging to the same class should be
    adjacent.
in order to train for classification:
    set train_mode=("classification", labels, weight), where labels is
     an array with the class information and weight is a scalar value
     (e.g., 1.0).
in order to train for regression:
    set train_mode=("serial_regression#", labels, weight), where # is
    an integer that specifies the block size used by a serial graph,
    labels is an array with the label information and weight is a
    scalar value.
in order to train using a graph without edges:
    set train_mode="unlabeled".
in order to train using the serial graph:
    set train_mode="serial", and use block_size (integer) to specify
    the group size.
in order to train using the mixed graph:
    set train_mode="mixed", and use block_size (integer) to specify
    the group size.
in order to train using an arbitrary user-provided graph:
    set train_mode="graph", specify the node_weights (numpy 1D array),
    and the edge_weights (numpy 2D array).

Overrides: Node.train