iCub-main
RandomFeature.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007-2011 RobotCub Consortium, European Commission FP6 Project IST-004370
3  * author: Arjan Gijsberts
4  * email: arjan.gijsberts@iit.it
5  * website: www.robotcub.org
6  * Permission is granted to copy, distribute, and/or modify this program
7  * under the terms of the GNU General Public License, version 2 or any
8  * later version published by the Free Software Foundation.
9  *
10  * A copy of the license can be found at
11  * http://www.robotcub.org/icub/license/gpl.txt
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
16  * Public License for more details
17  */
18 
19 #ifndef LM_RANDOMFEATURE__
20 #define LM_RANDOMFEATURE__
21 
22 #include <yarp/sig/Matrix.h>
23 
25 
26 namespace iCub {
27 namespace learningmachine {
28 
29 
46 protected:
50  double gamma;
51 
55  yarp::sig::Matrix W;
56 
60  yarp::sig::Vector b;
61 
62  /*
63  * Inherited from ITransformer.
64  */
65  virtual void writeBottle(yarp::os::Bottle& bot) const;
66 
67  /*
68  * Inherited from ITransformer.
69  */
70  virtual void readBottle(yarp::os::Bottle& bot);
71 
72 public:
80  RandomFeature(unsigned int dom = 1, unsigned int cod = 1, double gamma = 1.);
81 
85  virtual ~RandomFeature() { }
86 
87  /*
88  * Inherited from ITransformer.
89  */
90  virtual RandomFeature* clone() {
91  return new RandomFeature(*this);
92  }
93 
94  /*
95  * Inherited from ITransformer.
96  */
97  virtual yarp::sig::Vector transform(const yarp::sig::Vector& input);
98 
99  /*
100  * Inherited from ITransformer.
101  */
102  virtual std::string getInfo();
103 
104  /*
105  * Inherited from ITransformer.
106  */
107  virtual std::string getConfigHelp();
108 
109  /*
110  * Inherited from ITransformer.
111  */
112  virtual void setDomainSize(unsigned int size);
113 
114  /*
115  * Inherited from IFixedSizeTransformer.
116  */
117  virtual void setCoDomainSize(unsigned int size);
118 
119  /*
120  * Inherited from ITransformer.
121  */
122  virtual void reset();
123 
124  /*
125  * Inherited from ITransformer.
126  */
127  virtual bool configure(yarp::os::Searchable &config);
128 
134  virtual double getGamma() const {
135  return this->gamma;
136  }
137 
143  virtual void setGamma(double g) {
144  this->gamma = g;
145  // rebuild projection matrix
146  this->reset();
147  }
148 
149 };
150 
151 
152 } // learningmachine
153 } // iCub
154 
155 #endif
An generalized interface for an ITransformer with a fixed domain and codomain size.
Implementation of Random Feature preprocessing.
Definition: RandomFeature.h:45
RandomFeature(unsigned int dom=1, unsigned int cod=1, double gamma=1.)
Constructor.
double gamma
Gamma parameter, analoguous to same parameter in RBF kernel.
Definition: RandomFeature.h:50
virtual void readBottle(yarp::os::Bottle &bot)
Unserializes a transformer from a bottle.
virtual bool configure(yarp::os::Searchable &config)
virtual RandomFeature * clone()
Asks the transformer to return a new object of its type.
Definition: RandomFeature.h:90
virtual std::string getConfigHelp()
Asks the transformer to return a string containing the list of configuration options that it supports...
yarp::sig::Matrix W
Projection matrix W.
Definition: RandomFeature.h:55
virtual ~RandomFeature()
Destructor (empty).
Definition: RandomFeature.h:85
virtual yarp::sig::Vector transform(const yarp::sig::Vector &input)
Transforms an input vector.
yarp::sig::Vector b
Bias vector b.
Definition: RandomFeature.h:60
virtual void reset()
Forget everything and start over.
virtual void setCoDomainSize(unsigned int size)
Mutator for the codomain size.
virtual void setDomainSize(unsigned int size)
Mutator for the domain size.
virtual std::string getInfo()
Asks the transformer to return a string containing statistics on its operation so far.
virtual void setGamma(double g)
Mutator for the gamma parameter.
virtual void writeBottle(yarp::os::Bottle &bot) const
Writes a serialization of the transformer into a bottle.
virtual double getGamma() const
Accessor for the gamma parameter.
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.