Robotsystem from Robot Group Leipzig: inspectable.h Source File

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

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