Expands the input samples by applying to them one or more functions provided.
The functions to be applied are specified by a list [f_0, ..., f_k], where
f_i, for 0 <= i <= k, denotes a particular function.
The input data given to these functions is a two-dimensional array and
the output is another two-dimensional array. The dimensionality of the output
should depend only on the dimensionality of the input.
Given a two-dimensional input array x, the output of the node
is then [f_0(x), ..., f_k(x)], that is, the concatenation of each one of
the computed arrays f_i(x).
This node has been designed to facilitate nonlinear, fixed but arbitrary
transformations of the data samples within MDP flows.
Original code contributed by Alberto Escalante.
Example
>>> import mdp
>>> from mdp import numx
>>> def identity(x): return x
>>> def u3(x): return numx.absolute(x)**3
>>> def norm2(x):
>>> return ((x**2).sum(axis=1)**0.5).reshape((-1,1))
>>> x = numx.array([[-2., 2.], [0.2, 0.3], [0.6, 1.2]])
>>> gen = mdp.nodes.GeneralExpansionNode(funcs=[identity, u3, norm2])
>>> print(gen.execute(x))
>>> [[-2. 2. 8. 8. 2.82842712]
>>> [ 0.2 0.3 0.008 0.027 0.36055513]
>>> [ 0.6 1.2 0.216 1.728 1.34164079]]
|
__init__(self,
funcs,
input_dim=None,
dtype=None)
Initializes an object of type 'GeneralExpansionNode'. |
|
|
|
|
|
execute(self,
x)
Process the data contained in x . |
|
|
int
|
expanded_dim(self,
n)
The expanded dim is computed by directly applying the expansion
functions f_i to a zero input of dimension n. |
|
|
list
|
output_sizes(self,
n)
Return the individual output sizes of each expansion function
when the input has lenght n. |
|
|
numpy.ndarray
|
pseudo_inverse(self,
x,
use_hint=None)
Calculate a pseudo inverse of the expansion using
scipy.optimize. |
|
|
Inherited from unreachable._ExpansionNode (private):
_set_input_dim ,
_set_output_dim
Inherited from unreachable.newobject :
__long__ ,
__native__ ,
__nonzero__ ,
__unicode__ ,
next
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__sizeof__ ,
__subclasshook__
|
|
|
|
__call__(self,
x,
*args,
**kwargs)
Calling an instance of Node is equivalent to calling
its execute method. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_refcast(self,
x)
Helper function to cast arrays to the internal dtype. |
|
|
|
|
|
|
|
|
|
copy(self,
protocol=None)
Return a deep copy of the node. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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. |
|
|
|
|
|
|
|
|
|
train(self,
x,
*args,
**kwargs)
Update the internal structures according to the input data x . |
|
|