elman.h

Go to the documentation of this file.
00001 /*************************************************************************** 00002 * Copyright (C) 2005 by Robot Group Leipzig * 00003 * martius@informatik.uni-leipzig.de * 00004 * fhesse@informatik.uni-leipzig.de * 00005 * der@informatik.uni-leipzig.de * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 *************************************************************************** 00022 * * 00023 * DESCRIPTION * 00024 * * 00025 * $Log: elman.h,v $ 00026 * Revision 1.2 2006/11/29 16:22:43 martius 00027 * name is a variable of configurable and is used as such 00028 * 00029 * Revision 1.1 2006/07/27 15:22:31 martius 00030 * activations stored (processing must preceed learning and reponse calculation) 00031 * 00032 * 00033 * * 00034 ***************************************************************************/ 00035 #ifndef __ELMAN_H 00036 #define __ELMAN_H 00037 00038 #include <vector> 00039 00040 #include "multilayerffnn.h" 00041 00042 /** Multilayer Neural Network with context neurons (after Elman) 00043 Example of 2 hidden layer network 00044 O O O 00045 | | | 00046 H H H ----->-----+ 1:1 fixed connections (time delayed) 00047 | | |\-<-< __ | 00048 | | | \ \ \/ |l | l = lambda -> recurrent connection 00049 | | | C C C<-+ | 00050 | | | ^-^-^--<--+ 00051 H H H ----->-----+ 1:1 fixed connections (time delayed) 00052 | | |\-<-< __ | 00053 | | | \ \ \/ |l | l = lambda -> recurrent connection 00054 I I I C C C<-+ | 00055 ^-^-^--<--+ 00056 */ 00057 class Elman : public MultiLayerFFNN { 00058 public: 00059 /** 00060 @param eps learning rate 00061 @param layers Layer description (the input layer is not specified (always linear)) 00062 @param lambda self-recurrent feedback strength of context neurons 00063 */ 00064 Elman(double eps, const std::vector<Layer>& layers, double lambda) 00065 : MultiLayerFFNN(eps,layers), lambda(lambda) { 00066 00067 initialised = false; 00068 } 00069 virtual ~Elman(){ } 00070 00071 /// initialisation of the network with the given number of input and output units 00072 virtual void init(unsigned int inputDim, unsigned int outputDim, double unit_map = 0.0); 00073 00074 /** passive processing of the input 00075 (this will be different for every input, since it is a recurrent network) 00076 */ 00077 virtual const matrix::Matrix process (const matrix::Matrix& input); 00078 00079 /// performs learning and returns the network output before learning 00080 virtual const matrix::Matrix learn (const matrix::Matrix& input, 00081 const matrix::Matrix& nom_output, 00082 double learnRateFactor = 1); 00083 00084 /** \see InvertableModel::response 00085 */ 00086 /* Is implemented in multilayerfnn 00087 virtual const matrix::Matrix response(const matrix::Matrix& input) const; 00088 */ 00089 00090 /************** STOREABLE **********************************/ 00091 /// stores the layer binary into file stream 00092 bool store(FILE* f) const; 00093 /// restores the layer binary from file stream 00094 bool restore(FILE* f); 00095 00096 00097 /************** CONFIGURABLE INTERFACE ************************/ 00098 virtual paramkey getName() const { 00099 return std::string("elmanNN"); 00100 } 00101 00102 protected: 00103 std::vector<matrix::Matrix> contextweights; 00104 std::vector<matrix::Matrix> contexts; 00105 double lambda; 00106 00107 }; 00108 00109 #endif

Generated on Tue Jan 16 02:14:35 2007 for Robotsystem of the Robot Group Leipzig by doxygen 1.3.8