regularisation.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 * This file contains activation function and there derivatives in * 00026 * different regularised versions * 00027 * * 00028 * * 00029 * $Log: regularisation.h,v $ 00030 * Revision 1.3 2006/11/29 16:22:43 martius 00031 * name is a variable of configurable and is used as such 00032 * 00033 * Revision 1.2 2006/10/23 10:47:59 martius 00034 * g and derivatives and inverses 00035 * 00036 * Revision 1.1 2006/10/20 15:22:15 martius 00037 * regularisation terms for g 00038 * 00039 * Revision 1.2 2006/07/14 12:23:56 martius 00040 * selforg becomes HEAD 00041 * 00042 * Revision 1.1.2.1 2005/12/06 17:38:21 martius 00043 * *** empty log message *** 00044 * 00045 * * 00046 ***************************************************************************/ 00047 #ifndef __REGULARISATION_H 00048 #define __REGULARISATION_H 00049 00050 double inline sqr(double x) { 00051 return x*x; 00052 } 00053 00054 /// neuron transfer function 00055 double inline g(double z) 00056 { 00057 return tanh(z); 00058 }; 00059 00060 /// first dervative 00061 double inline g_s(double z) 00062 { 00063 double k=tanh(z); 00064 return 1.025 - k*k; 00065 // return 1/(1+z*z); // softer 00066 //return 1/(1+log(1+z*z)); // even softer 00067 }; 00068 00069 /// inverse of the first derivative 00070 double inline g_s_inv(double z) 00071 { 00072 double k=tanh(z); 00073 return 1/(1.025 - k*k); 00074 // return 1+z*z; // softer 00075 //return 1+log(1+z*z); // even softer 00076 }; 00077 00078 /** \f[ g'(z+xsi) = 1-(tanh(z+xsi))^2 \f] with additional clipping */ 00079 double inline g_s(double z, double xsi) { 00080 double Z = clip(z, -3.0, 3.0) + clip(xsi, -1.0, 1.0); 00081 double k=tanh(Z); // approximation with Mittelwertsatz 00082 return 1 - k*k; 00083 }; 00084 00085 /// an exact formula for g''/g', with clipped Z = z+xsi 00086 double inline g_ss_div_s(double z, double xsi) { 00087 // for consistency reasons we use the same clipped z as for g'. 00088 double Z = clip(z, -3.0, 3.0) + clip(xsi, -1.0, 1.0); 00089 // approximation with Mittelwertsatz (z is clipped) 00090 return -2*g(Z); 00091 }; 00092 00093 /** with \f[ g'(z) = 1-(g(z+\xsi))^2 \f] we get 00094 \f[\frac{\partial}{\partial z} \frac{1}{g'(Z)} = \frac{g''}{g'^2} \f] 00095 again with clipped Z 00096 */ 00097 double inline derive_g_s_inv_exact_clip(double z, double xsi){ 00098 double Z = clip(z, -3.0, 3.0) + clip(xsi, -1.0, 1.0); 00099 double k=tanh(Z); // approximation with Mittelwertsatz 00100 return -2*k/(1-k*k); 00101 } 00102 00103 /** \f[ g'(z) = 1-(z+\xsi)^2 \f] which is the series expansion to the second order 00104 */ 00105 double inline g_s_expand2(double z, double xsi){ 00106 return 1-sqr(z+xsi); 00107 } 00108 00109 /** \f[ \frac{1}{g'(z)} \approx 1+(z+\xsi)^2 \f] with geometric series approximation 00110 */ 00111 double inline g_s_inv_expand2(double z, double xsi){ 00112 return 1+sqr(z+xsi); 00113 } 00114 00115 /** with \f[ g'(z) = 1-(z+\xsi)^2 \f] which is the series expansion to the second order 00116 we get \f[ \frac{1}{g'(z)} \approx 1+(z+\xsi)^2 \f] and therewith 00117 \f[ \frac{\partial}{\partial z} \frac{1}{g'(Z)} 2(z+\xsi) \f] 00118 */ 00119 double inline derive_g_s_inv_expand2(double z, double xsi){ 00120 return 2*(z+xsi); 00121 } 00122 00123 00124 #endif 00125

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