Robotsystem of the Robot Group Leipzig: feedforwardnn.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages
- Examples

- Search for |

- File List
- File Members

# feedforwardnn.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: feedforwardnn.h,v $
    00026  *   Revision 1.11  2008/05/30 11:57:12  martius
    00027  *   do processing of inputs in learning function if network is not
    00028  *    activated with this input before (was a very probable mistake)
    00029  *
    00030  *   Revision 1.10  2007/12/11 14:43:53  martius
    00031  *   tanhr and tanhc as regularised versions of tanh
    00032  *
    00033  *   Revision 1.9  2007/06/08 15:45:24  martius
    00034  *   cosmetics
    00035  *
    00036  *   Revision 1.8  2007/04/03 11:22:37  martius
    00037  *   inverse of actfuns
    00038  *
    00039  *   Revision 1.7  2007/02/23 09:40:45  der
    00040  *   regularisation used from regularisation.h
    00041  *
    00042  *   Revision 1.6  2007/02/20 15:41:06  martius
    00043  *   big model stuff, elman and co
    00044  *
    00045  *   Revision 1.5  2006/07/20 17:14:34  martius
    00046  *   removed std namespace from matrix.h
    00047  *   storable interface
    00048  *   abstract model and invertablemodel as superclasses for networks
    00049  *
    00050  *   Revision 1.4  2006/07/18 14:49:48  martius
    00051  *   invertable networks provide the linear response function (jacobian)
    00052  *
    00053  *                                                                 *
    00054  ***************************************************************************/
    00055 #ifndef __FEEDFORWARDNN_H
    00056 #define __FEEDFORWARDNN_H
    00057
    00058 #include "invertablemodel.h"
    00059 #include "controller_misc.h"
    00060 #include "regularisation.h"
    00061
    00062 #include <cmath>
    00063
    00064 /// activation function type: input: membrane potential
    00065 typedef double (*ActivationFunction) (double);
    00066 /** inverse of Activation function with respect to some membrane potential
    00067     and a certain output error.
    00068  */
    00069 typedef double (*InvActivationFunction) (double, double);
    00070
    00071 /// abstract class (interface) for feed forward rate based neural networks
    00072 class FeedForwardNN : public InvertableModel {
    00073  public:
    00074   FeedForwardNN() {}
    00075   FeedForwardNN(const std::string& name, const std::string& revision)
    00076     : InvertableModel(name, revision){};
    00077   virtual ~FeedForwardNN(){};
    00078
    00079   /// damps the weights and the biases by multiplying (1-damping)
    00080   virtual void damp(double damping) =0 ;
    00081
    00082   /******** Activation functions and there derivative
    00083             and inversion with certain output shift (regularised) */
    00084   static double linear(double z)   { return z;}
    00085   static double dlinear(double )   { return 1;}
    00086   static double invlinear(double z, double xsi) { return xsi;}
    00087
    00088   static double tanh(double z)     { return ::tanh(z); }
    00089   static double dtanh(double z)    { double k = ::tanh(z); return 1-k*k; }
    00090   static double invtanh(double z, double xsi) { return g_s_inv_expand2(z,xsi)*xsi;}
    00091
    00092   // clipped tanh
    00093   static double tanhc(double z)     { return ::tanh(z); }
    00094   static double dtanhc(double z) { double k = ::tanh(clip(z, -3.0, 3.0)); return 1-k*k; }
    00095
    00096   // regularised tanh
    00097   static double tanhr(double z)     { return ::tanh(z); }
    00098   static double dtanhr(double z) { double k = tanh(z); return 1.01-k*k; }
    00099   //  static double dtanhr(double z) { return 1/(1+z*z); }
    00100
    00101
    00102   static double sigmoid(double z)  { return 1/(1+exp(-z)); }
    00103   static double dsigmoid(double z) { double k = sigmoid(clip(z, -3.0, 3.0)); return k*(1-k); }
    00104   static double invsigmoid(double z, double xsi) { return 1/(0.01+dsigmoid(z))*xsi;}
    00105 };
    00106
    00107
    00108 #endif