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 * $Log: inspectable.h,v $ 00023 * Revision 1.8 2006/07/20 17:14:34 martius 00024 * removed std namespace from matrix.h 00025 * storable interface 00026 * abstract model and invertablemodel as superclasses for networks 00027 * 00028 * Revision 1.7 2006/07/14 12:23:58 martius 00029 * selforg becomes HEAD 00030 * 00031 * Revision 1.5.6.1 2006/06/25 16:51:35 martius 00032 * configureable has name and revision 00033 * a robot is configureable by default 00034 * 00035 * Revision 1.5 2005/10/27 15:46:38 martius 00036 * inspectable interface is expanded to structural information for network visualiser 00037 * 00038 * Revision 1.4 2005/10/06 17:06:57 martius 00039 * switched to stl lists 00040 * 00041 * Revision 1.3 2005/09/11 11:20:01 martius 00042 * virtual destructor 00043 * 00044 * Revision 1.2 2005/08/06 20:47:54 martius 00045 * Commented 00046 * 00047 * Revision 1.1 2005/08/03 20:28:57 martius 00048 * inspectable interface 00049 * 00050 * * 00051 ***************************************************************************/ 00052 #ifndef __INSPECTABLE_H 00053 #define __INSPECTABLE_H 00054 00055 #include <list> 00056 #include <utility> 00057 #include <string> 00058 #include "stl_adds.h" 00059 00060 /** 00061 * Interface for inspectable objects. 00062 * That means that one can read out some internal parameters indentified by string keys 00063 */ 00064 class Inspectable { 00065 public: 00066 00067 typedef std::string iparamkey; 00068 typedef double iparamval; 00069 00070 typedef std::list<iparamkey> iparamkeylist; 00071 typedef std::list<iparamval> iparamvallist; 00072 00073 typedef struct ILayer{ 00074 ILayer(const std::string& vectorname, const std::string& biasname, 00075 int dimension, int rank, const std::string& layername) 00076 : vectorname(vectorname), biasname(biasname), 00077 dimension(dimension), rank(rank), layername(layername) {} 00078 std::string vectorname; //< prefix of the internal parameter vector e.g. "v" 00079 std::string biasname; //< prefix of the internal parameter vector used as bias for the neurons e.g. "h" 00080 int dimension; //< length of the vector (number of units) 00081 int rank; //< rank of the layer (0 are input layers) 00082 std::string layername; //< name of the layer as displayed by the visualiser 00083 }ILayer; 00084 00085 typedef struct IConnection{ 00086 IConnection(const std::string& matrixname, const std::string& vector1, const std::string& vector2) 00087 : matrixname(matrixname), vector1(vector1), vector2(vector2) {} 00088 std::string matrixname; //< matrix name is the prefix of the internal parameter matrix e.g. "A" 00089 std::string vector1; //< vectorname of input layer 00090 std::string vector2; //< vectorname of output layer 00091 }IConnection; 00092 00093 typedef std::list<ILayer> ilayerlist; 00094 typedef std::list<IConnection> iconnectionlist; 00095 00096 /// nice predicate function for finding a Layer with its vectorname 00097 struct matchName : public std::unary_function<ILayer, bool> { 00098 matchName(std::string name) : name(name) {} 00099 std::string name; 00100 bool operator()(ILayer l) { return l.vectorname == name; } 00101 }; 00102 00103 virtual ~Inspectable(){} 00104 /** The list of the names of all internal parameters given by getInternalParams(). 00105 The naming convention is "v[i]" for vectors 00106 and "A[i][j]" for matrices, where i, j start at 0. 00107 @return: list of keys 00108 */ 00109 virtual iparamkeylist getInternalParamNames() const = 0; 00110 /** @return: list of values 00111 */ 00112 virtual iparamvallist getInternalParams() const = 0; 00113 00114 /** Specifies which parameter vector forms a structural layer (in terms of a neural network) 00115 The ordering is important. The first entry is the input layer and so on. 00116 @return: list of layer names with dimension 00117 00118 */ 00119 virtual ilayerlist getStructuralLayers() const { return std::list<ILayer>();} 00120 /** Specifies which parameter matrix forms a connection between layers (in terms of a neural network) 00121 The orderning is not important. 00122 @return: list of layer names with dimension 00123 */ 00124 virtual iconnectionlist getStructuralConnections() const { return std::list<IConnection>();} 00125 00126 }; 00127 00128 #endif
1.4.7