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
layer.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2011 LpzRobots development team *
3  * Georg Martius <georg dot martius at web dot de> *
4  * Frank Guettler <guettler at informatik dot uni-leipzig dot de *
5  * Frank Hesse <frank at nld dot ds dot mpg dot de> *
6  * Ralf Der <ralfder at mis dot mpg dot de> *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the *
20  * Free Software Foundation, Inc., *
21  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
22  * *
23  ***************************************************************************/
24 #ifndef __NETWORKLAYER_H
25 #define __NETWORKLAYER_H
26 
27 #include <vector>
28 
29 #include "feedforwardnn.h"
30 
31 class Layer : public Storeable {
32 public:
33  /** constructor for Layer.
34  The derivative and inverse of activation function is derived automatically.
35  @param size number neurons
36  @param factor_bias size of bias neuron , if 0 no bias is used
37  @param actfun activation function. see also FeedForwardNN
38  */
39  Layer(int size, double factor_bias=0.1,
41 
42  /** obsolete, use the other constructor for Layer.
43  @param size number neurons
44  @param factor_bias size of bias neuron , if 0 no bias is used
45  @param actfun activation function. see also FeedForwardNN
46  @param dactfun derivative of activation function (should be consistent with actfun)
47  */
48  Layer(int size, double factor_bias,
51  fprintf(stderr, "%s %s\n", "Layer::Layer(): this contructor is obsolete! ",
52  "Please use the one without dactfun now!\n");
53  exit(1);
54  }
55 
56  /***STOREABLE ******/
57  /// stores the layer binary into file stream
58  bool store(FILE* f) const;
59  /// restores the layer binary from file stream
60  bool restore(FILE* f);
61 
62  /// sets the activation function of the layer
64 
65  int size;
66  double factor_bias;
67  ActivationFunction actfun; ///< callback activation function
68  ActivationFunction dactfun; ///< first derivative of the activation function
69  InvActivationFunction invactfun; ///< inversion of activation function
70 
71  // prints the Layer data-structure
72  friend std::ostream& operator<<(std::ostream& , const Layer&);
73 };
74 
75 #endif
Interface for objects, that can be stored and restored to/from a file stream (binary).
Definition: storeable.h:33
Definition: layer.h:31
double factor_bias
Definition: layer.h:66
Layer(int size, double factor_bias, ActivationFunction actfun, ActivationFunction dactfun)
obsolete, use the other constructor for Layer.
Definition: layer.h:48
bool restore(FILE *f)
restores the layer binary from file stream
Definition: layer.cpp:82
double(* InvActivationFunction)(double, double)
inverse of Activation function with respect to some membrane potential and a certain output error...
Definition: feedforwardnn.h:38
InvActivationFunction invactfun
inversion of activation function
Definition: layer.h:69
Layer(int size, double factor_bias=0.1, ActivationFunction actfun=FeedForwardNN::linear)
constructor for Layer.
Definition: layer.cpp:48
void setActFun(ActivationFunction actfun)
sets the activation function of the layer
Definition: layer.cpp:54
ActivationFunction actfun
callback activation function
Definition: layer.h:67
double(* ActivationFunction)(double)
activation function type: input: membrane potential
Definition: feedforwardnn.h:34
static double linear(double z)
Definition: feedforwardnn.h:54
friend std::ostream & operator<<(std::ostream &, const Layer &)
Definition: layer.cpp:105
ActivationFunction dactfun
first derivative of the activation function
Definition: layer.h:68
int size
Definition: layer.h:65
bool store(FILE *f) const
stores the layer binary into file stream
Definition: layer.cpp:77