def __init__(self, n, d, real_dtype="d", integer_dtype="l"): """ Input arguments: n -- Number of maxima and minima to remember d -- Minimum gap between two hits real_dtype -- dtype of sequence items integer_dtype -- dtype of sequence indices Note: be careful with dtypes! """ self.n = int(n) self.d = int(d) self.iM = numx.zeros((n, ), dtype=integer_dtype) self.im = numx.zeros((n, ), dtype=integer_dtype) real_dtype = numx.dtype(real_dtype) if real_dtype in mdp.utils.get_dtypes('AllInteger'): max_num = numx.iinfo(real_dtype).max min_num = numx.iinfo(real_dtype).min else: max_num = numx.finfo(real_dtype).max min_num = numx.finfo(real_dtype).min self.M = numx.array([min_num]*n, dtype=real_dtype) self.m = numx.array([max_num]*n, dtype=real_dtype) self.lM = 0 self.lm = 0
def __init__(self, n, d, real_dtype="d", integer_dtype="l"): """Initializes an object of type 'OneDimensionalHitParade'. :param n: Number of maxima and minima to remember. :type n: int :param d: Minimum gap between two hits. :type d: int :param real_dtype: Datatype of sequence items :type real_dtype: numpy.dtype or str :param integer_dtype: Datatype of sequence indices :type integer_dtype: numpy.dtype or str """ self.n = int(n) self.d = int(d) self.iM = numx.zeros((n, ), dtype=integer_dtype) self.im = numx.zeros((n, ), dtype=integer_dtype) real_dtype = numx.dtype(real_dtype) if real_dtype in mdp.utils.get_dtypes('AllInteger'): max_num = numx.iinfo(real_dtype).max min_num = numx.iinfo(real_dtype).min else: max_num = numx.finfo(real_dtype).max min_num = numx.finfo(real_dtype).min self.M = numx.array([min_num]*n, dtype=real_dtype) self.m = numx.array([max_num]*n, dtype=real_dtype) self.lM = 0 self.lm = 0
def __init__(self, n, d, real_dtype="d", integer_dtype="l"): """Initializes an object of type 'OneDimensionalHitParade'. :param n: Number of maxima and minima to remember. :type n: int :param d: Minimum gap between two hits. :type d: int :param real_dtype: Datatype of sequence items :type real_dtype: numpy.dtype or str :param integer_dtype: Datatype of sequence indices :type integer_dtype: numpy.dtype or str """ self.n = int(n) self.d = int(d) self.iM = numx.zeros((n, ), dtype=integer_dtype) self.im = numx.zeros((n, ), dtype=integer_dtype) real_dtype = numx.dtype(real_dtype) if real_dtype in mdp.utils.get_dtypes('AllInteger'): max_num = numx.iinfo(real_dtype).max min_num = numx.iinfo(real_dtype).min else: max_num = numx.finfo(real_dtype).max min_num = numx.finfo(real_dtype).min self.M = numx.array([min_num] * n, dtype=real_dtype) self.m = numx.array([max_num] * n, dtype=real_dtype) self.lM = 0 self.lm = 0
def _assert_eigenvalues_real_and_positive(w, dtype): tol = numx.finfo(dtype.type).eps * 100 if abs(w.imag).max() > tol: err = "Some eigenvalues have significant imaginary part: %s " % str(w) raise mdp.SymeigException(err)
from past.utils import old_div __docformat__ = "restructuredtext en" import sys as _sys import mdp from mdp import Node, NodeException, numx, numx_rand from mdp.nodes import WhiteningNode from mdp.utils import (DelayCovarianceMatrix, MultipleCovarianceMatrices, rotate, mult) # TODO: support floats of size different than 64-bit; will need to change SQRT_EPS_D # rename often used functions sum, cos, sin, PI = numx.sum, numx.cos, numx.sin, numx.pi SQRT_EPS_D = numx.sqrt(numx.finfo('d').eps) def _triu(m, k=0): """ returns the elements on and above the k-th diagonal of m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main diagonal.""" N = m.shape[0] M = m.shape[1] x = numx.greater_equal(numx.subtract.outer(numx.arange(N), numx.arange(M)),1-k) out = (1-x)*m return out ############# class ISFANode(Node): """ Perform Independent Slow Feature Analysis on the input data.
from past.utils import old_div __docformat__ = "restructuredtext en" import sys as _sys import mdp from mdp import Node, NodeException, numx, numx_rand from mdp.nodes import WhiteningNode from mdp.utils import (DelayCovarianceMatrix, MultipleCovarianceMatrices, rotate, mult) # Licensed under the BSD License, see Copyright file for details. # TODO: support floats of size different than 64-bit; will need to change SQRT_EPS_D # rename often used functions sum, cos, sin, PI = numx.sum, numx.cos, numx.sin, numx.pi SQRT_EPS_D = numx.sqrt(numx.finfo('d').eps) def _triu(m, k=0): """Reduces a matrix to a triangular part. :param m: A Matrix. :param k: Index of diagonal. :type k: int :return: Elements on and above the k-th diagonal of m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main diagonal. """ N = m.shape[0] M = m.shape[1] x = numx.greater_equal(numx.subtract.outer(numx.arange(N),
__docformat__ = "restructuredtext en" import sys as _sys import mdp from mdp import Node, NodeException, numx, numx_rand from mdp.nodes import WhiteningNode from mdp.utils import DelayCovarianceMatrix, MultipleCovarianceMatrices, rotate, mult # TODO: support floats of size different than 64-bit; will need to change SQRT_EPS_D # rename often used functions sum, cos, sin, PI = numx.sum, numx.cos, numx.sin, numx.pi SQRT_EPS_D = numx.sqrt(numx.finfo("d").eps) def _triu(m, k=0): """ returns the elements on and above the k-th diagonal of m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main diagonal.""" N = m.shape[0] M = m.shape[1] x = numx.greater_equal(numx.subtract.outer(numx.arange(N), numx.arange(M)), 1 - k) out = (1 - x) * m return out ############# class ISFANode(Node): """ Perform Independent Slow Feature Analysis on the input data.