Robotsystem from Robot Group Leipzig: onelayerffnn.cpp Source File

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

# onelayerffnn.cpp

Go to the documentation of this file.

    00001
    00002 #include "onelayerffnn.h"
    00003
    00004 using namespace matrix;
    00005
    00006 /// initialisation of the network with the given number of input and output units
    00007 void OneLayerFFNN::init(unsigned int inputDim, unsigned  int outputDim) {
    00008   weights.set(outputDim, inputDim);
    00009   bias.set(outputDim, 1);
    00010   initialised = true;
    00011 }
    00012
    00013 /// passive processing of the input
    00014 const Matrix OneLayerFFNN::process (const Matrix& input) const {
    00015   assert(initialised);
    00016   return (weights * input + bias).map(actfun);
    00017 }
    00018 /// performs learning and returns the network output before learning
    00019 const Matrix OneLayerFFNN::learn (const Matrix& input,
    00020                                   const Matrix& nom_output,
    00021                                   double learnRateFactor) {
    00022   assert(initialised);
    00023   double epsilon = eps*learnRateFactor;
    00024   const Matrix& z       = weights * input + bias;
    00025   const Matrix& g_prime = z.map(dactfun);
    00026   const Matrix& output  = z.map(actfun);
    00027   const Matrix& xsi     = nom_output - output;
    00028
    00029   weights += xsi.multrowwise(g_prime) * (input^T) * epsilon;
    00030   bias    += xsi.multrowwise(g_prime) * epsilon * factor_bias;
    00031   return output;
    00032 }
    00033