Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Elman Class Reference

Multilayer Neural Network with context neurons (after Elman and Jordan) Example of 2 hidden layer network with both, elman and jordan context units. More...

#include <elman.h>

Inheritance diagram for Elman:
Collaboration diagram for Elman:

Public Member Functions

 Elman (double eps, const std::vector< Layer > &layers, bool useElman, bool useJordan=false, bool useBypass=false)
 
virtual ~Elman ()
 
virtual void init (unsigned int inputDim, unsigned int outputDim, double unit_map=0.0, RandGen *randGen=0)
 initialisation of the network with the given number of input and output units More...
 
virtual const matrix::Matrix process (const matrix::Matrix &input)
 passive processing of the input (this will be different for every input, since it is a recurrent network) More...
 
virtual const matrix::Matrix learn (const matrix::Matrix &input, const matrix::Matrix &nom_output, double learnRateFactor=1)
 performs learning and returns the network output before learning More...
 
virtual NetUpdate weightIncrement (const matrix::Matrix &xsi)
 determines the weight and bias updates More...
 
virtual NetUpdate weightIncrementBlocked (const matrix::Matrix &xsi_, int blockedlayer, int blockfrom, int blockto)
 like weightIncrement but with blocked backprop flow for some neurons. More...
 
virtual void updateWeights (const NetUpdate &updates)
 applies the weight increments to the weight (and bias) matrices with the learningrate and the learnRateFactor More...
 
void damp (double damping)
 damps the weights and the biases by multiplying (1-damping) More...
 
bool store (FILE *f) const
 stores the layer binary into file stream More...
 
bool restore (FILE *f)
 restores the layer binary from file stream More...
 
virtual paramkey getName () const
 return the name of the object More...
 
virtual iparamkeylist getInternalParamNames () const
 The list of the names of all internal parameters given by getInternalParams(). More...
 
virtual iparamvallist getInternalParams () const
 
virtual ilayerlist getStructuralLayers () const
 Specifies which parameter vector forms a structural layer (in terms of a neural network) The ordering is important. More...
 
virtual iconnectionlist getStructuralConnections () const
 Specifies which parameter matrix forms a connection between layers (in terms of a neural network) The orderning is not important. More...
 
- Public Member Functions inherited from MultiLayerFFNN
 MultiLayerFFNN (double eps, const std::vector< Layer > &layers, bool useBypass=false, bool someInternalParams=true)
 
virtual ~MultiLayerFFNN ()
 
virtual const matrix::Matrix response (const matrix::Matrix &input) const
 response matrix of neural network at given input More...
 
virtual const matrix::Matrix inversion (const matrix::Matrix &input, const matrix::Matrix &xsi) const
 calculates the input shift v to a given output shift xsi via pseudo inversion. More...
 
virtual unsigned int getInputDim () const
 returns the number of input neurons More...
 
virtual unsigned int getOutputDim () const
 returns the number of output neurons More...
 
virtual const matrix::MatrixgetLayerOutput (unsigned int layer) const
 returns activation of the given layer. Layer 0 is the first hidden layer More...
 
virtual unsigned int getLayerNum () const
 
virtual const LayergetLayer (unsigned int layer) const
 layers 0 is the first hidden layer More...
 
virtual LayergetLayer (unsigned int layer)
 layers 0 is the first hidden layer More...
 
virtual const matrix::MatrixgetWeights (unsigned int to_layer) const
 weight matrix 0 connects input with the first hidden layer More...
 
virtual matrix::MatrixgetWeights (unsigned int to_layer)
 weight matrix 0 connects input with the first hidden layer More...
 
virtual const matrix::MatrixgetBias (unsigned int of_layer) const
 Note: layers 0 is the first hidden layer. More...
 
virtual matrix::MatrixgetBias (unsigned int of_layer)
 Note: layers 0 is the first hidden layer. More...
 
bool store (FILE *f) const
 stores the layer binary into file stream More...
 
bool restore (FILE *f)
 restores the layer binary from file stream More...
 
bool write (FILE *f) const
 writes the layer ASCII into file stream (not in the storable interface) More...
 
virtual void setSomeInternalParams (bool someInternalParams)
 
virtual std::vector
< ActivationFunction
setActivationFunction (ActivationFunction actfun)
 sets the activation function (and derivative and inversion too) for ALL layers! More...
 
virtual void setActivationFunctions (std::vector< ActivationFunction > actfunList)
 sets the activation functions (and derivative and inversion too) for all layers. More...
 
- Public Member Functions inherited from FeedForwardNN
 FeedForwardNN (const std::string &name, const std::string &revision)
 
virtual ~FeedForwardNN ()
 
- Public Member Functions inherited from InvertableModel
 InvertableModel (const std::string &name, const std::string &revision)
 
virtual ~InvertableModel ()
 
- Public Member Functions inherited from AbstractModel
 AbstractModel (const std::string &name, const std::string &revision)
 
virtual ~AbstractModel ()
 
- Public Member Functions inherited from Configurable
 Configurable ()
 
 Configurable (const std::string &name, const std::string &revision)
 intialise with name and revision (use "$ID$") More...
 
virtual ~Configurable ()
 
virtual void notifyOnChange (const paramkey &key)
 Is called when a parameter was changes via setParam(). More...
 
virtual void addParameter (const paramkey &key, paramval *val, paramval minBound, paramval maxBound, const paramdescr &descr=paramdescr())
 This is the new style for adding configurable parameters. More...
 
virtual void addParameter (const paramkey &key, paramval *val, const paramdescr &descr=paramdescr())
 See addParameter(const paramkey& key, paramval* val, paramval minBound, paramval maxBound, const paramdescr& descr) More...
 
virtual void addParameter (const paramkey &key, parambool *val, const paramdescr &descr=paramdescr())
 See addParameter(const paramkey& key, paramval* val) but for bool values. More...
 
virtual void addParameter (const paramkey &key, paramint *val, paramint minBound, paramint maxBound, const paramdescr &descr=paramdescr())
 See addParameter(const paramkey& key, paramval* val) but for int values. More...
 
virtual void addParameter (const paramkey &key, paramint *val, const paramdescr &descr=paramdescr())
 
virtual void addParameterDef (const paramkey &key, paramval *val, paramval def, paramval minBound, paramval maxBound, const paramdescr &descr=paramdescr())
 This function is only provided for convenience. More...
 
virtual void addParameterDef (const paramkey &key, paramval *val, paramval def, const paramdescr &descr=paramdescr())
 
virtual void addParameterDef (const paramkey &key, parambool *val, parambool def, const paramdescr &descr=paramdescr())
 See addParameterDef(const paramkey&, paramval*, paramval) More...
 
virtual void addParameterDef (const paramkey &key, paramint *val, paramint def, paramint minBound, paramint maxBound, const paramdescr &descr=paramdescr())
 See addParameterDef(const paramkey&, paramval*, paramval) More...
 
virtual void addParameterDef (const paramkey &key, paramint *val, paramint def, const paramdescr &descr=paramdescr())
 
virtual void setParamDescr (const paramkey &key, const paramdescr &descr, bool traverseChildren=true)
 sets a description for the given parameter More...
 
int getId () const
 return the id of the configurable objects, which is created by random on initialisation More...
 
virtual paramkey getRevision () const
 returns the revision of the object More...
 
virtual void setName (const paramkey &name, bool callSetNameOfInspectable=true)
 Sets the name of the configurable. More...
 
virtual void setRevision (const paramkey &revision)
 sets the revision Hint: { return "$ID$"; } More...
 
virtual paramval getParam (const paramkey &key, bool traverseChildren=true) const
 returns the value of the requested parameter or 0 (+ error message to stderr) if unknown. More...
 
virtual bool hasParam (const paramkey &key, bool traverseChildren=true) const
 Returns if the requested parameter is part of the configurable or their children. More...
 
virtual bool setParam (const paramkey &key, paramval val, bool traverseChildren=true)
 sets the value of the given parameter or does nothing if unknown. More...
 
virtual void setParamBounds (const paramkey &key, paramval minBound, paramval maxBound, bool traverseChildren=true)
 Sets the bounds (minBound and maxBound) of the given parameter. More...
 
virtual void setParamBounds (const paramkey &key, paramint minBound, paramint maxBound, bool traverseChildren=true)
 
virtual void setParamBounds (const paramkey &key, paramvalBounds bounds, bool traverseChildren=true)
 
virtual void setParamBounds (const paramkey &key, paramintBounds bounds, bool traverseChildren=true)
 
virtual paramlist getParamList () const
 The list of all parameters with there value as allocated lists. More...
 
virtual std::list< paramkeygetAllParamNames (bool traverseChildren=true)
 returns all names that are configureable More...
 
virtual parammap getParamValMap () const
 
virtual paramintmap getParamIntMap () const
 
virtual paramboolmap getParamBoolMap () const
 
virtual paramdescr getParamDescr (const paramkey &key, bool traverseChildren=true) const
 returns the description for the given parameter More...
 
virtual paramvalBounds getParamvalBounds (const paramkey &key, bool traverseChildren=true) const
 
virtual paramintBounds getParamintBounds (const paramkey &key, bool traverseChildren=true) const
 
virtual bool hasParamDescr (const paramkey &key, bool traverseChildren=true) const
 
virtual bool hasParamvalBounds (const paramkey &key, bool traverseChildren=true) const
 
virtual bool hasParamintBounds (const paramkey &key, bool traverseChildren=true) const
 
virtual bool storeCfg (const char *filenamestem, const std::list< std::string > &comments=std::list< std::string >())
 stores the key values paires into the file : filenamestem.cfg including the comments given in the list More...
 
virtual bool restoreCfg (const char *filenamestem)
 restores the key values paires from the file : filenamestem.cfg More...
 
void print (FILE *f, const char *prefix, int columns=90, bool traverseChildren=true) const
 prints the keys, values and descriptions to the file. Each line is prefixed More...
 
bool parse (FILE *f, const char *prefix=0, bool traverseChildren=true)
 parses the configuration from the given file More...
 
virtual void addConfigurable (Configurable *conf)
 Adds a configurable as a child object. More...
 
virtual void removeConfigurable (Configurable *conf)
 Removes a configurable as a child object. More...
 
virtual const configurableListgetConfigurables () const
 Returns the list containing all configurable children. More...
 
virtual void configurableChanged ()
 Indicates that the configurable itself or the configurable children attached to this configurable have changed. More...
 
- Public Member Functions inherited from BackCaller
 BackCaller ()
 
virtual ~BackCaller ()
 
virtual void addCallbackable (Callbackable *callbackableInstance, CallbackableType type=BackCaller::DEFAULT_CALLBACKABLE_TYPE)
 Adds a Callbackable instance to this caller instance. More...
 
virtual void removeCallbackable (Callbackable *callbackableInstance, CallbackableType type=BackCaller::DEFAULT_CALLBACKABLE_TYPE)
 Removes a Callbackable instance from this caller instance. More...
 
virtual void removeAllCallbackables (CallbackableType type)
 Removes all Callbackable instances from this caller instance. More...
 
virtual void callBack (CallbackableType type=BackCaller::DEFAULT_CALLBACKABLE_TYPE)
 Calls all registered callbackable classes of the determined type. More...
 
virtual void callBackQMP (CallbackableType type=BackCaller::DEFAULT_CALLBACKABLE_TYPE)
 Calls all registered callbackable classes of the determined type. More...
 
- Public Member Functions inherited from Storeable
virtual ~Storeable ()
 
bool storeToFile (const char *filename) const
 Provided for convenience. More...
 
bool restoreFromFile (const char *filename)
 Provided for convenience. More...
 
- Public Member Functions inherited from Inspectable
 Inspectable (const iparamkey &name="")
 TYPEDEFS END. More...
 
virtual ~Inspectable ()
 
virtual iparamvalptrlist getInternalParamsPtr () const
 be careful: matrices will be ignored More...
 
virtual void addInspectableValue (const iparamkey &key, iparamval const *val, const std::string &descr=std::string())
 This is the new style for adding inspectable values. More...
 
virtual void addInspectableMatrix (const iparamkey &key, const matrix::Matrix *m, bool only4x4AndDiag=true, const std::string &descr=std::string())
 This is the new style for adding inspectable values. More...
 
virtual void addInspectableDescription (const iparamkey &key, const std::string &descr)
 adds a description for the given parameter using info-lines The line will start (appart from the #I) with a D for description followed by the key end then followed by the string. More...
 
virtual void addInfoLine (std::string infoLine)
 Adds an info line to this inspectable instance. More...
 
virtual void addInfoLines (std::list< std::string > infoLineList)
 Adds a bunch of infolines with addInfoLine to this inspectable instance. More...
 
virtual void removeInfoLines ()
 Removes all infolines from this inspectable instance. More...
 
virtual const infoLinesListgetInfoLines () const
 Returns all infolines added to this inspectable instance. More...
 
virtual void addInspectable (Inspectable *insp)
 Adds an inspectable as a child object. More...
 
virtual void removeInspectable (Inspectable *insp)
 Removes an inspectable as a child object. More...
 
virtual void setNameOfInspectable (const iparamkey &name)
 set the name of the inspectable More...
 
virtual const iparamkey getNameOfInspectable () const
 return the name of the inspectable, getName() would conflict with Configurable::getName() too often More...
 
virtual const inspectableListgetInspectables () const
 Returns the list containing all inspectable children. More...
 

Protected Attributes

matrix::Matrix elmanWeights
 
matrix::Matrix elmanContext
 
matrix::Matrix jordanWeights
 
matrix::Matrix jordanContext
 
bool useElman
 
bool useJordan
 
- Protected Attributes inherited from MultiLayerFFNN
std::vector< Layerlayers
 
std::vector< matrix::Matrixweights
 
std::vector< matrix::Matrixbias
 
std::vector< matrix::Matrixsmallids
 
bool useBypass
 
matrix::Matrix bypassWeights
 
bool someInternalParams
 
matrix::Matrix input
 
std::vector< matrix::Matrixys
 
std::vector< matrix::Matrixzs
 
double lambda
 
bool initialised
 
- Protected Attributes inherited from Inspectable
iparamkey name
 
iparampairlist mapOfValues
 
imatrixpairlist mapOfMatrices
 
infoLinesList infoLineStringList
 

Additional Inherited Members

- Public Types inherited from Configurable
typedef std::string paramkey
 
typedef std::string paramdescr
 
typedef double paramval
 
typedef std::list< std::pair
< paramkey, paramval > > 
paramlist
 
typedef std::map< paramkey,
paramval * > 
parammap
 
typedef bool parambool
 
typedef std::list< std::pair
< paramkey, parambool > > 
paramboollist
 
typedef std::map< paramkey,
parambool * > 
paramboolmap
 
typedef int paramint
 
typedef std::list< std::pair
< paramkey, paramint > > 
paramintlist
 
typedef std::map< paramkey,
paramint * > 
paramintmap
 
typedef std::map< paramkey,
paramdescr
paramdescrmap
 
typedef std::pair< paramval,
paramval
paramvalBounds
 
typedef std::map< paramkey,
paramvalBounds
paramvalBoundsMap
 
typedef std::pair< paramint,
paramint
paramintBounds
 
typedef std::map< paramkey,
paramintBounds
paramintBoundsMap
 
typedef std::pair< paramkey,
paramval * > 
paramvalpair
 
typedef std::pair< paramkey,
parambool * > 
paramboolpair
 
typedef std::pair< paramkey,
paramint * > 
paramintpair
 
typedef std::vector
< Configurable * > 
configurableList
 
- Public Types inherited from BackCaller
typedef unsigned long CallbackableType
 
- Public Types inherited from Inspectable
typedef std::string iparamkey
 
typedef double iparamval
 
typedef std::pair< iparamkey,
iparamval const * > 
iparampair
 
typedef std::pair< iparamkey,
std::pair< const
matrix::Matrix *, bool > > 
imatrixpair
 
typedef std::list< iparamkeyiparamkeylist
 
typedef std::list< std::string > infoLinesList
 
typedef std::list< iparamvaliparamvallist
 
typedef std::list< iparamval
const * > 
iparamvalptrlist
 
typedef std::list< iparampairiparampairlist
 
typedef std::list< imatrixpairimatrixpairlist
 
typedef struct Inspectable::ILayer ILayer
 
typedef struct
Inspectable::IConnection 
IConnection
 
typedef std::list< ILayerilayerlist
 
typedef std::list< IConnectioniconnectionlist
 
typedef std::list< const
Inspectable * > 
inspectableList
 
- Static Public Member Functions inherited from FeedForwardNN
static double linear (double z)
 
static double dlinear (double)
 
static double invlinear (double z, double xsi)
 
static double tanh (double z)
 
static double dtanh (double z)
 
static double invtanh (double z, double xsi)
 
static double tanhc (double z)
 
static double dtanhc (double z)
 
static double tanhr (double z)
 
static double dtanhr (double z)
 
static double sigmoid (double z)
 
static double dsigmoid (double z)
 
static double invsigmoid (double z, double xsi)
 
- Public Attributes inherited from MultiLayerFFNN
double eps
 learning rate More...
 
- Static Public Attributes inherited from Configurable
static const CallbackableType CALLBACK_CONFIGURABLE_CHANGED = 11
 
- Static Public Attributes inherited from BackCaller
static const CallbackableType DEFAULT_CALLBACKABLE_TYPE = 0
 This is the default Callbackable type. More...
 
- Protected Member Functions inherited from Configurable
void copyParameters (const Configurable &, bool traverseChildren=true)
 copies the internal params of the given configurable More...
 
void printdescr (FILE *f, const char *prefix, const paramkey &key, int columns, int indent) const
 

Detailed Description

Multilayer Neural Network with context neurons (after Elman and Jordan) Example of 2 hidden layer network with both, elman and jordan context units.

Precondition
{ +–<--—O O O | | | | | H H H
| H H H --—>--—+ 1:1 fixed connections (time delayed) | >->-/| | |-<-< | | / / / | | | \ \ \ | | J J J I I I E E E | +-^-^-^ ^-^-^–<–+ }

Constructor & Destructor Documentation

Elman ( double  eps,
const std::vector< Layer > &  layers,
bool  useElman,
bool  useJordan = false,
bool  useBypass = false 
)
inline
Parameters
epslearning rate
layersLayer description (the input layer is not specified (always linear))
lambdaself-recurrent feedback strength of context neurons
virtual ~Elman ( )
inlinevirtual

Member Function Documentation

void damp ( double  damping)
virtual

damps the weights and the biases by multiplying (1-damping)

Reimplemented from MultiLayerFFNN.

Inspectable::iparamkeylist getInternalParamNames ( ) const
virtual

The list of the names of all internal parameters given by getInternalParams().

The naming convention is "v[i]" for vectors and "A[i][j]" for matrices, where i, j start at 0.

Returns
: list of keys

Reimplemented from MultiLayerFFNN.

Inspectable::iparamvallist getInternalParams ( ) const
virtual
Returns
: list of values

Reimplemented from MultiLayerFFNN.

virtual paramkey getName ( ) const
inlinevirtual

return the name of the object

Reimplemented from Configurable.

Inspectable::iconnectionlist getStructuralConnections ( ) const
virtual

Specifies which parameter matrix forms a connection between layers (in terms of a neural network) The orderning is not important.

Returns
: list of layer names with dimension

Reimplemented from MultiLayerFFNN.

Inspectable::ilayerlist getStructuralLayers ( ) const
virtual

Specifies which parameter vector forms a structural layer (in terms of a neural network) The ordering is important.

The first entry is the input layer and so on.

Returns
: list of layer names with dimension

Reimplemented from MultiLayerFFNN.

void init ( unsigned int  inputDim,
unsigned int  outputDim,
double  unit_map = 0.0,
RandGen randGen = 0 
)
virtual

initialisation of the network with the given number of input and output units

Reimplemented from MultiLayerFFNN.

const Matrix learn ( const matrix::Matrix input,
const matrix::Matrix nom_output,
double  learnRateFactor = 1 
)
virtual

performs learning and returns the network output before learning

Reimplemented from MultiLayerFFNN.

const Matrix process ( const matrix::Matrix input)
virtual

passive processing of the input (this will be different for every input, since it is a recurrent network)

Reimplemented from MultiLayerFFNN.

bool restore ( FILE *  f)
virtual

restores the layer binary from file stream

Implements Storeable.

bool store ( FILE *  f) const
virtual

stores the layer binary into file stream

Implements Storeable.

void updateWeights ( const NetUpdate updates)
virtual

applies the weight increments to the weight (and bias) matrices with the learningrate and the learnRateFactor

NetUpdate weightIncrement ( const matrix::Matrix xsi)
virtual

determines the weight and bias updates

NetUpdate weightIncrementBlocked ( const matrix::Matrix xsi_,
int  blockedlayer,
int  blockfrom,
int  blockto 
)
virtual

like weightIncrement but with blocked backprop flow for some neurons.

Parameters
blockedlayerindex of layer with blocked neurons
blockfromindex of neuron in blockedlayer to start blocking
blocktoindex of neuron in blockedlayer to end blocking (if -1 then to end) (not included)

Member Data Documentation

matrix::Matrix elmanContext
protected
matrix::Matrix elmanWeights
protected
matrix::Matrix jordanContext
protected
matrix::Matrix jordanWeights
protected
bool useElman
protected
bool useJordan
protected

The documentation for this class was generated from the following files: