📄 aureservoir.py
字号:
# This file was automatically generated by SWIG (http://www.swig.org).# Version 1.3.31## Don't modify this file, modify the SWIG interface instead.# This file is compatible with both classic and new-style classes."""aureservoir is an open-source (L-GPL) C++ library for analogreservoir computing neural networks. The basic class is the ESN(Echo State Network) class, which can be used in single or doubleprecision (SingleESN, DoubleESN).Echo State Networks can be used with different initialization,training and simulation algorithms - which can be choosen at runtimefrom the definitions in the DATA section of the module documentation.For more info on ESNs see docstrings of DoubleESN or SingleESN.You can find autogenerated docstrings for most of the methods - formore detailed documentation and more information seehttp://aureservoir.sourceforge.net.2007-2008, byGeorg Holzmanngrh _at_ mur _dot_ athttp://grh.mur.at"""import _aureservoirimport newnew_instancemethod = new.instancemethodtry: _swig_property = propertyexcept NameError: pass # Python < 2.2 doesn't have 'property'.def _swig_setattr_nondynamic(self,class_type,name,value,static=1): if (name == "thisown"): return self.this.own(value) if (name == "this"): if type(value).__name__ == 'PySwigObject': self.__dict__[name] = value return method = class_type.__swig_setmethods__.get(name,None) if method: return method(self,value) if (not static) or hasattr(self,name): self.__dict__[name] = value else: raise AttributeError("You cannot add attributes to %s" % self)def _swig_setattr(self,class_type,name,value): return _swig_setattr_nondynamic(self,class_type,name,value,0)def _swig_getattr(self,class_type,name): if (name == "thisown"): return self.this.own() method = class_type.__swig_getmethods__.get(name,None) if method: return method(self) raise AttributeError,namedef _swig_repr(self): try: strthis = "proxy of " + self.this.__repr__() except: strthis = "" return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)import typestry: _object = types.ObjectType _newclass = 1except AttributeError: class _object : pass _newclass = 0del typesclass DoubleESN(_object): """ class for a basic Echo State Network This class implements a basic Echo State Network as described in articles by Herbert Jaeger on the following page: See: http://www.scholarpedia.org/article/Echo_State_Network The template argument T can be float or double. Single Precision (float) saves quite some computation time. The "echo state" approach looks at RNNs from a new angle. Large RNNs are interpreted as "reservoirs" of complex, excitable dynamics. Output units "tap" from this reservoir by linearly combining the desired output signal from the rich variety of excited reservoir signals. This idea leads to training algorithms where only the network-to-output connection weights have to be trained. This can be done with known, highly efficient linear regression algorithms. from See: http://www.faculty.iu-bremen.de/hjaeger/esn_research.html C++ includes: esn.h """ __swig_setmethods__ = {} __setattr__ = lambda self, name, value: _swig_setattr(self, DoubleESN, name, value) __swig_getmethods__ = {} __getattr__ = lambda self, name: _swig_getattr(self, DoubleESN, name) __repr__ = _swig_repr def __init__(self, *args): """ __init__(self) -> DoubleESN __init__(self, DoubleESN src) -> DoubleESN Copy Constructor. """ this = _aureservoir.new_DoubleESN(*args) try: self.this.append(this) except: self.this = this __swig_destroy__ = _aureservoir.delete_DoubleESN __del__ = lambda self : None; def init(*args): """ init(self) throw ( AUExcept) Initialization Algorithm for an Echo State Network See: class InitBase """ return _aureservoir.DoubleESN_init(*args) def resetState(*args): """ resetState(self) resets the internal state vector x of the reservoir to zero """ return _aureservoir.DoubleESN_resetState(*args) def adapt(*args): """ adapt(self, double inmtx) -> double throw ( AUExcept) C-style Reservoir Adaptation Algorithm Interface (data will be copied into a FLENS matrix) At the moment this is only the Gaussian-IP reservoir adaptation method for tanh neurons. See: "Adapting reservoirs to get Gaussian distributions" by David Verstraeten, Benjamin Schrauwen and Dirk Stroobandt Parameters: ----------- inmtx: matrix of input values (inputs x timesteps), the reservoir will be adapted by this number of timesteps. mean value of differences between all parameters before and after adaptation, can be used to see if learning still makes an progress. """ return _aureservoir.DoubleESN_adapt(*args) def train(*args): """ train(self, double inmtx, double outmtx, int washout) throw ( AUExcept) C-style Training Algorithm Interface (data will be copied into a FLENS matrix) See: class TrainBase Parameters: ----------- inmtx: input matrix in row major storage (usual C array) (inputs x timesteps) outmtx: output matrix in row major storage (outputs x timesteps) for teacher forcing washout: washout time in samples, used to get rid of the transient dynamics of the network starting state """ return _aureservoir.DoubleESN_train(*args) def simulate(*args): """ simulate(self, double inmtx, double outmtx) throw ( AUExcept) C-style Simulation Algorithm Interface with some additional error checking. (data will be copied into a FLENS matrix) See: class SimBase Parameters: ----------- inmtx: input matrix in row major storage (usual C array) (inputs x timesteps) outmtx: output matrix in row major storage (outputs x timesteps), Data must be already allocated! """ return _aureservoir.DoubleESN_simulate(*args) def simulateStep(*args): """ simulateStep(self, double invec, double outvec) throw ( AUExcept) C-style Simulation Algorithm Interface, for single step simulation See: class SimBase """ return _aureservoir.DoubleESN_simulateStep(*args) def setBPCutoff(*args): """ setBPCutoff(self, double f1vec, double f2vec) throw ( AUExcept) Set lowpass/highpass cutoff frequencies for bandpass style neurons " (C-style Interface). Parameters: ----------- f1: vector with lowpass cutoff for all neurons (size = neurons) f2: vector with highpass cutoffs (size = neurons) """ return _aureservoir.DoubleESN_setBPCutoff(*args) def setIIRCoeff(*args): """ setIIRCoeff(self, double bmtx, double amtx, int series=1) setIIRCoeff(self, double bmtx, double amtx) throw ( AUExcept) sets the IIR-Filter coefficients, like Matlabs filter object. Parameters: ----------- B: matrix with numerator coefficient vectors (m x nb) m ... nr of parallel filters (neurons) nb ... nr of filter coefficients A: matrix with denominator coefficient vectors (m x na) m ... nr of parallel filters (neurons) na ... nr of filter coefficients seris: nr of serial IIR filters, e.g. if series=2 the coefficients B and A will be divided in its half and calculated with 2 serial IIR filters """ return _aureservoir.DoubleESN_setIIRCoeff(*args) def post(*args): """ post(self) posts current parameters to stdout """ return _aureservoir.DoubleESN_post(*args) def getSize(*args): """ getSize(self) -> int reservoir size (nr of neurons) """ return _aureservoir.DoubleESN_getSize(*args) def getInputs(*args): """ getInputs(self) -> int nr of inputs to the reservoir """ return _aureservoir.DoubleESN_getInputs(*args) def getOutputs(*args): """ getOutputs(self) -> int nr of outputs from the reservoir """ return _aureservoir.DoubleESN_getOutputs(*args) def getNoise(*args): """ getNoise(self) -> double current noise level """ return _aureservoir.DoubleESN_getNoise(*args) def getInitParam(*args): """ getInitParam(self, InitParameter key) -> double returns an initialization parametern from the parameter map Parameters: ----------- key: the requested parameter the value of the parameter """ return _aureservoir.DoubleESN_getInitParam(*args) def getInitAlgorithm(*args): """ getInitAlgorithm(self) -> int initialization algorithm """ return _aureservoir.DoubleESN_getInitAlgorithm(*args) def getTrainAlgorithm(*args): """ getTrainAlgorithm(self) -> int training algorithm """ return _aureservoir.DoubleESN_getTrainAlgorithm(*args) def getSimAlgorithm(*args): """ getSimAlgorithm(self) -> int simulation algorithm """ return _aureservoir.DoubleESN_getSimAlgorithm(*args) def getReservoirAct(*args): """ getReservoirAct(self) -> int reservoir activation function """ return _aureservoir.DoubleESN_getReservoirAct(*args) def getOutputAct(*args): """ getOutputAct(self) -> int output activation function """ return _aureservoir.DoubleESN_getOutputAct(*args) def getWin(*args): """ getWin(self, double mtx) get pointer to input weight matrix data and dimensions (neurons x inputs) WARNING: This data is in fortran style column major storage ! """ return _aureservoir.DoubleESN_getWin(*args) def getWback(*args): """ getWback(self, double mtx) get pointer to feedback weight matrix data and dimensions (neurons x outputs) WARNING: This data is in fortran style column major storage ! """ return _aureservoir.DoubleESN_getWback(*args) def getWout(*args): """ getWout(self, double mtx) get pointer to output weight matrix data and dimensions (outputs x neurons+inputs) WARNING: This data is in fortran style column major storage ! """ return _aureservoir.DoubleESN_getWout(*args) def getX(*args): """ getX(self, double vec) get pointer to internal state vector x data and length """ return _aureservoir.DoubleESN_getX(*args) def getW(*args): """ getW(self, double wmtx) throw ( AUExcept) Copies data of the sparse reservoir weight matrix into a dense C-style matrix. Memory of the C array must be allocated before! Parameters: ----------- wmtx: pointer to matrix of size (neurons_ x neurons_) """ return _aureservoir.DoubleESN_getW(*args)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -