iCub-main
IFixedSizeLearner.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_IFIXEDSIZELEARNER__
20 #define LM_IFIXEDSIZELEARNER__
21 
23 
24 
25 namespace iCub {
26 namespace learningmachine {
27 
45 protected:
49  unsigned int domainSize;
50 
54  unsigned int coDomainSize;
55 
62  virtual bool checkDomainSize(const yarp::sig::Vector& input);
63 
70  virtual bool checkCoDomainSize(const yarp::sig::Vector& output);
71 
79  void validateDomainSizes(const yarp::sig::Vector& input, const yarp::sig::Vector& output);
80 
81  /*
82  * Inherited from IMachineLearner.
83  */
84  virtual void writeBottle(yarp::os::Bottle& bot) const;
85 
86  /*
87  * Inherited from IMachineLearner.
88  */
89  virtual void readBottle(yarp::os::Bottle& bot);
90 
91 public:
98  IFixedSizeLearner(unsigned int dom = 1, unsigned int cod = 1) : domainSize(dom), coDomainSize(cod) { }
99 
100  /*
101  * Inherited from IMachineLearner.
102  */
103  virtual void feedSample(const yarp::sig::Vector& input, const yarp::sig::Vector& output);
104 
105  /*
106  * Inherited from IMachineLearner.
107  */
108  virtual void train();
109 
115  unsigned int getDomainSize() const { return this->domainSize; }
116 
122  unsigned int getCoDomainSize() const { return this->coDomainSize; }
123 
129  virtual void setDomainSize(unsigned int size) { this->domainSize = size; }
130 
136  virtual void setCoDomainSize(unsigned int size) {this->coDomainSize = size; }
137 
138  /*
139  * Inherited from IMachineLearner.
140  */
141  virtual std::string getInfo();
142 
143  /*
144  * Inherited from IMachineLearner.
145  */
146  virtual std::string getConfigHelp();
147 
148  /*
149  * Inherited from IConfig.
150  */
151  virtual bool configure(yarp::os::Searchable& config);
152 
153 };
154 
155 } // learningmachine
156 } // iCub
157 
158 #endif
iCub::learningmachine::IFixedSizeLearner::train
virtual void train()
Train the learning machine on the examples that have been supplied so far.
Definition: IFixedSizeLearner.cpp:32
iCub
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.
Definition: emotionInterface.h:17
iCub::learningmachine::IFixedSizeLearner::getDomainSize
unsigned int getDomainSize() const
Returns the size (dimensionality) of the input domain.
Definition: IFixedSizeLearner.h:115
IMachineLearner.h
iCub::learningmachine::IMachineLearner
Definition: IMachineLearner.h:89
iCub::learningmachine::IFixedSizeLearner::writeBottle
virtual void writeBottle(yarp::os::Bottle &bot) const
Writes a serialization of the machine into a bottle.
Definition: IFixedSizeLearner.cpp:68
iCub::learningmachine::IFixedSizeLearner::validateDomainSizes
void validateDomainSizes(const yarp::sig::Vector &input, const yarp::sig::Vector &output)
Validates whether the input and output are of the desired dimensionality.
Definition: IFixedSizeLearner.cpp:59
iCub::learningmachine::IFixedSizeLearner::setDomainSize
virtual void setDomainSize(unsigned int size)
Mutator for the domain size.
Definition: IFixedSizeLearner.h:129
iCub::learningmachine::IFixedSizeLearner::getCoDomainSize
unsigned int getCoDomainSize() const
Returns the size (dimensionality) of the output domain (codomain).
Definition: IFixedSizeLearner.h:122
iCub::learningmachine::IFixedSizeLearner::domainSize
unsigned int domainSize
The dimensionality of the input domain.
Definition: IFixedSizeLearner.h:49
iCub::learningmachine::IFixedSizeLearner::checkDomainSize
virtual bool checkDomainSize(const yarp::sig::Vector &input)
Checks whether the input is of the desired dimensionality.
Definition: IFixedSizeLearner.cpp:51
iCub::learningmachine::IFixedSizeLearner::checkCoDomainSize
virtual bool checkCoDomainSize(const yarp::sig::Vector &output)
Checks whether the output is of the desired dimensionality.
Definition: IFixedSizeLearner.cpp:55
iCub::learningmachine::IFixedSizeLearner::feedSample
virtual void feedSample(const yarp::sig::Vector &input, const yarp::sig::Vector &output)
Provide the learning machine with an example of the desired mapping.
Definition: IFixedSizeLearner.cpp:28
iCub::learningmachine::IFixedSizeLearner::getInfo
virtual std::string getInfo()
Asks the learning machine to return a string containing information on its operation so far.
Definition: IFixedSizeLearner.cpp:78
iCub::learningmachine::IFixedSizeLearner::configure
virtual bool configure(yarp::os::Searchable &config)
Definition: IFixedSizeLearner.cpp:35
string
string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}") include_directories($
Definition: CMakeLists.txt:9
iCub::learningmachine::IFixedSizeLearner::setCoDomainSize
virtual void setCoDomainSize(unsigned int size)
Mutator for the codomain size.
Definition: IFixedSizeLearner.h:136
iCub::learningmachine::IFixedSizeLearner::IFixedSizeLearner
IFixedSizeLearner(unsigned int dom=1, unsigned int cod=1)
Constructor.
Definition: IFixedSizeLearner.h:98
iCub::learningmachine::IFixedSizeLearner
Definition: IFixedSizeLearner.h:44
iCub::learningmachine::IFixedSizeLearner::coDomainSize
unsigned int coDomainSize
The dimensionality of the output domain (codomain).
Definition: IFixedSizeLearner.h:54
iCub::learningmachine::IFixedSizeLearner::readBottle
virtual void readBottle(yarp::os::Bottle &bot)
Unserializes a machine from a bottle.
Definition: IFixedSizeLearner.cpp:73
iCub::learningmachine::IFixedSizeLearner::getConfigHelp
virtual std::string getConfigHelp()
Asks the learning machine to return a string containing the list of configuration options that it sup...
Definition: IFixedSizeLearner.cpp:86