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
ControllerNet Class Reference

multi layer neural network with configurable activation functions and propagation and projection methods suitable for homeokinesis controller More...

#include <controllernet.h>

Inheritance diagram for ControllerNet:
Collaboration diagram for ControllerNet:

Public Member Functions

 ControllerNet (const std::vector< Layer > &layers, bool useBypass=false)
 
virtual ~ControllerNet ()
 
virtual void init (unsigned int inputDim, unsigned int outputDim, double unit_map=0.0, double rand=0.2, 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. More...
 
virtual const matrix::Matrix processX (const matrix::Matrix &input, const matrix::Matrix &injection, unsigned int injectInLayer)
 like process just with the opportunity to overwrite the activation of a specific layer More...
 
virtual void damp (double damping)
 damps the weights and the biases by multiplying (1-damping) More...
 
virtual const matrix::Matrixresponse () const
 response matrix of neural network (for current activation, see process)

\[ J_ij = \frac{\partial y_i}{\partial x_j} \]

\[ J = G_n' W_n G_{n-1}' W_{n-1} ... G_1' W_1 \]

with $W_n$ is the weight matrix of layer n and $ G'$ is a diagonal matrix with $ G'_ii = g'_i $ as values on the diagonal. More...

 
virtual matrix::Matrix responsePart (int from, int to) const
 like response, just that only a range of layers is considered The Bypass is not considered here. More...
 
virtual const matrix::MatrixresponseLinear () const
 linear response matrix of neural network

\[ R = W_n W_{n-1} ... W_1 \]

with $W_n$ is the weight matrix of layer n. More...

 
virtual const matrix::Matrix backpropagation (const matrix::Matrix &error, matrix::Matrices *errors=0, matrix::Matrices *zetas=0) const
 backpropagation of vector error through network. More...
 
virtual const matrix::Matrix backpropagationX (const matrix::Matrix &error, matrix::Matrices *errors=0, matrix::Matrices *zetas=0, int startWithLayer=-1) const
 like backpropagation but with special features: we can start from any layer and the bypass-discounting can be used (see disseration Georg Martius) WARNING: the errors and zetas above the `startWithLayer' are undefined More...
 
virtual const matrix::Matrix backprojection (const matrix::Matrix &error, matrix::Matrices *errors=0, matrix::Matrices *zetas=0) const
 backprojection of vector error through network. More...
 
virtual const matrix::Matrix forwardpropagation (const matrix::Matrix &error, matrix::Matrices *errors=0, matrix::Matrices *zetas=0) const
 forwardpropagation of vector error through network. More...
 
virtual const matrix::Matrix forwardprojection (const matrix::Matrix &error, matrix::Matrices *errors=0, matrix::Matrices *zetas=0) const
 forwardprojection of vector error through network. 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 (int layer) const
 returns activation of the given 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 (int to_layer) const
 weight matrix 0 connects input with the first hidden layer Negative values count from the end (-1 is the last layer) More...
 
virtual matrix::MatrixgetWeights (int to_layer)
 weight matrix 0 connects input with the first hidden layer Negative values count from the end (-1 is the last layer) More...
 
virtual const matrix::MatrixgetByPass () const
 
virtual matrix::MatrixgetByPass ()
 
virtual const matrix::MatrixgetBias (int of_layer) const
 Note: layers 0 is the first hidden layer Negative values count from the end (-1 is the last layer) More...
 
virtual matrix::MatrixgetBias (int of_layer)
 Note: layers 0 is the first hidden layer Negative values count from the end (-1 is the last 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...
 
- 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 getName () const
 return the name of the object 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...
 

Protected Member Functions

virtual void calcResponseIntern ()
 
- 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
 

Protected Attributes

std::vector< Layerlayers
 
std::vector< matrix::Matrixweights
 
std::vector< matrix::Matrixbias
 
bool useBypass
 
matrix::Matrix bypassWeights
 
matrix::Matrix input
 
matrix::Matrices y
 
matrix::Matrices z
 
matrix::Matrices gp
 
matrix::Matrix L
 
matrix::Matrix R
 
double lambda
 
bool initialised
 

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
 
- 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...
 

Detailed Description

multi layer neural network with configurable activation functions and propagation and projection methods suitable for homeokinesis controller

Constructor & Destructor Documentation

ControllerNet ( const std::vector< Layer > &  layers,
bool  useBypass = false 
)
Parameters
layersLayer description (the input layer is not specified (always linear))
useBypassif true, then a connection from input to output layer is included
virtual ~ControllerNet ( )
inlinevirtual

Member Function Documentation

const Matrix backprojection ( const matrix::Matrix error,
matrix::Matrices errors = 0,
matrix::Matrices zetas = 0 
) const
virtual

backprojection of vector error through network.

The storage for the intermediate values (errors, zetas) do not need to be given. The errors(layerwise) are at the output of the neurons (index 0 is at the input level, output of layer 0 has index 1 and so on) The zetas(layerwise) are the values inside the neurons that arise when backprojecting the error signal. (zeta[0] is at layer 0)

Returns
errors[0] (result of backprojecting)
const Matrix backpropagation ( const matrix::Matrix error,
matrix::Matrices errors = 0,
matrix::Matrices zetas = 0 
) const
virtual

backpropagation of vector error through network.

The storage for the intermediate values (errors, zetas) do not need to be given. The errors(layerwise) are at the output of the neurons (index 0 is at the input level, output of layer 0 has index 1 and so on) The zetas(layerwise) are the values inside the neurons that arise when backpropagating the error signal. (zeta[0] is at layer 0)

Returns
errors[0] (result of backpropagation)
const Matrix backpropagationX ( const matrix::Matrix error,
matrix::Matrices errors = 0,
matrix::Matrices zetas = 0,
int  startWithLayer = -1 
) const
virtual

like backpropagation but with special features: we can start from any layer and the bypass-discounting can be used (see disseration Georg Martius) WARNING: the errors and zetas above the `startWithLayer' are undefined

Parameters
startWithLayerthe error is clamped at this layer and the processing starts there (-1: output layer)
See Also
backpropagation
void calcResponseIntern ( )
protectedvirtual
void damp ( double  damping)
virtual

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

const Matrix forwardprojection ( const matrix::Matrix error,
matrix::Matrices errors = 0,
matrix::Matrices zetas = 0 
) const
virtual

forwardprojection of vector error through network.

The storage for the intermediate values (errors, zetas) do not need to be given. The errors(layerwise) are at the output of the neurons (index 0 is at the input level = error, output of layer 0 has index 1 and so on) The zetas(layerwise) are the values inside the neurons that arise when forwardprojecting the error signal. (zeta[0] is at layer 0)

Returns
errors[layernum] (result of forwardprojection)
const Matrix forwardpropagation ( const matrix::Matrix error,
matrix::Matrices errors = 0,
matrix::Matrices zetas = 0 
) const
virtual

forwardpropagation of vector error through network.

The storage for the intermediate values (errors, zetas) do not need to be given. The errors(layerwise) are at the output of the neurons (index 0 is at the input level = error, output of layer 0 has index 1 and so on) The zetas(layerwise) are the values inside the neurons that arise when forwardpropagate the error signal. (zeta[0] is at layer 0)

Returns
errors[layernum] (result of forwardpropagation)
virtual const matrix::Matrix& getBias ( int  of_layer) const
inlinevirtual

Note: layers 0 is the first hidden layer Negative values count from the end (-1 is the last layer)

virtual matrix::Matrix& getBias ( int  of_layer)
inlinevirtual

Note: layers 0 is the first hidden layer Negative values count from the end (-1 is the last layer)

virtual const matrix::Matrix& getByPass ( ) const
inlinevirtual
virtual matrix::Matrix& getByPass ( )
inlinevirtual
virtual unsigned int getInputDim ( ) const
inlinevirtual

returns the number of input neurons

virtual const Layer& getLayer ( unsigned int  layer) const
inlinevirtual

layers 0 is the first hidden layer

virtual Layer& getLayer ( unsigned int  layer)
inlinevirtual

layers 0 is the first hidden layer

virtual unsigned int getLayerNum ( ) const
inlinevirtual
virtual const matrix::Matrix& getLayerOutput ( int  layer) const
inlinevirtual

returns activation of the given layer.

Layer 0 is the first hidden layer. Negative values count from the end (-1 is the last layer)

virtual unsigned int getOutputDim ( ) const
inlinevirtual

returns the number of output neurons

virtual const matrix::Matrix& getWeights ( int  to_layer) const
inlinevirtual

weight matrix 0 connects input with the first hidden layer Negative values count from the end (-1 is the last layer)

virtual matrix::Matrix& getWeights ( int  to_layer)
inlinevirtual

weight matrix 0 connects input with the first hidden layer Negative values count from the end (-1 is the last layer)

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

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

The dimensionality of the ouputlayer is automatically adjusted.

Parameters
unit_mapdefines the approximate response of the network after initialisation (if unit_map=1 the weights are unit matrices).
randGenpointer to random generator, if 0 an new one is used
const Matrix process ( const matrix::Matrix input)
virtual

passive processing of the input.

This has to be done before calling reponse, and the back/forward propagation/projection functions. The activations and the response matrix are stored internally.

const Matrix processX ( const matrix::Matrix input,
const matrix::Matrix injection,
unsigned int  injectInLayer 
)
virtual

like process just with the opportunity to overwrite the activation of a specific layer

Parameters
injectionsthe input that is clamped at layer injectInLayer
injectInLayerthe injection is clamped at this layer
const Matrix & response ( ) const
virtual

response matrix of neural network (for current activation, see process)

\[ J_ij = \frac{\partial y_i}{\partial x_j} \]

\[ J = G_n' W_n G_{n-1}' W_{n-1} ... G_1' W_1 \]

with $W_n$ is the weight matrix of layer n and $ G'$ is a diagonal matrix with $ G'_ii = g'_i $ as values on the diagonal.

const Matrix & responseLinear ( ) const
virtual

linear response matrix of neural network

\[ R = W_n W_{n-1} ... W_1 \]

with $W_n$ is the weight matrix of layer n.

Matrix responsePart ( int  from,
int  to 
) const
virtual

like response, just that only a range of layers is considered The Bypass is not considered here.

Parameters
fromindex of layer to start: -1 at input, 0 first hidden layer ...
toindex of layer to stop: -1: last layer, 0 first hidden layer ...
bool restore ( FILE *  f)

restores the layer binary from file stream

bool store ( FILE *  f) const

stores the layer binary into file stream

bool write ( FILE *  f) const

writes the layer ASCII into file stream (not in the storable interface)

Member Data Documentation

std::vector<matrix::Matrix> bias
protected
matrix::Matrix bypassWeights
protected
matrix::Matrices gp
protected
bool initialised
protected
matrix::Matrix input
protected
matrix::Matrix L
protected
double lambda
protected
std::vector<Layer> layers
protected
matrix::Matrix R
protected
bool useBypass
protected
std::vector<matrix::Matrix> weights
protected
matrix::Matrices y
protected
matrix::Matrices z
protected

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