iCub-main
DummyLearner.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 
20 #ifndef LM_DUMMYLEARNER__
21 #define LM_DUMMYLEARNER__
22 
23 #include <vector>
24 #include <sstream>
25 
27 
28 
29 namespace iCub {
30 namespace learningmachine {
31 
32 std::string printVector(const yarp::sig::Vector& v);
45 private:
49  int sampleCount;
50 
54  int trainCount;
55 
59  std::vector<yarp::sig::Vector> inputs;
60 
64  std::vector<yarp::sig::Vector> outputs;
65 
66 
67 public:
71  DummyLearner(unsigned int dom = 1, unsigned int cod = 1) : sampleCount(0), trainCount(0) {
72  this->setName("Dummy");
73  inputs.resize(0);
74  outputs.resize(0);
75  this->setDomainSize(dom);
76  this->setCoDomainSize(cod);
77  }
78 
82  virtual ~DummyLearner() { }
83 
84  /*
85  * Inherited from IMachineLearner.
86  */
87  virtual void feedSample(const yarp::sig::Vector& input, const yarp::sig::Vector& output);
88 
89  /*
90  * Inherited from IMachineLearner.
91  */
92  virtual void train();
93 
94  /*
95  * Inherited from IMachineLearner.
96  */
97  Prediction predict(const yarp::sig::Vector& input);
98 
99  /*
100  * Inherited from IMachineLearner.
101  */
102  void reset();
103 
104  /*
105  * Inherited from IMachineLearner.
106  */
108  return new DummyLearner(*this);
109  }
110 
111  /*
112  * Inherited from IMachineLearner.
113  */
115 
116  /*
117  * Inherited from IMachineLearner.
118  */
119  virtual void writeBottle(yarp::os::Bottle& bot) const;
120 
121  /*
122  * Inherited from IMachineLearner.
123  */
124  virtual void readBottle(yarp::os::Bottle& bot);
125 
126 };
127 
128 } // learningmachine
129 } // iCub
130 #endif
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::DummyLearner::writeBottle
virtual void writeBottle(yarp::os::Bottle &bot) const
Writes a serialization of the machine into a bottle.
Definition: DummyLearner.cpp:83
iCub::learningmachine::DummyLearner::reset
void reset()
Forget everything and start over.
Definition: DummyLearner.cpp:67
iCub::learningmachine::DummyLearner::clone
DummyLearner * clone()
Asks the learning machine to return a clone of its type.
Definition: DummyLearner.h:107
iCub::learningmachine::printVector
std::string printVector(const yarp::sig::Vector &v)
Definition: DummyLearner.cpp:30
iCub::learningmachine::IFixedSizeLearner::setDomainSize
virtual void setDomainSize(unsigned int size)
Mutator for the domain size.
Definition: IFixedSizeLearner.h:129
iCub::learningmachine::DummyLearner::train
virtual void train()
Train the learning machine on the examples that have been supplied so far.
Definition: DummyLearner.cpp:51
iCub::learningmachine::DummyLearner::~DummyLearner
virtual ~DummyLearner()
Destructor (empty).
Definition: DummyLearner.h:82
iCub::learningmachine::DummyLearner::DummyLearner
DummyLearner(unsigned int dom=1, unsigned int cod=1)
Constructor.
Definition: DummyLearner.h:71
IFixedSizeLearner.h
string
string(REPLACE "-rdynamic" "" CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}") include_directories($
Definition: CMakeLists.txt:9
iCub::learningmachine::Prediction
Definition: Prediction.h:44
iCub::learningmachine::DummyLearner::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: DummyLearner.cpp:41
iCub::learningmachine::IFixedSizeLearner::setCoDomainSize
virtual void setCoDomainSize(unsigned int size)
Mutator for the codomain size.
Definition: IFixedSizeLearner.h:136
iCub::learningmachine::DummyLearner
Definition: DummyLearner.h:44
iCub::learningmachine::DummyLearner::getInfo
std::string getInfo()
Asks the learning machine to return a string containing information on its operation so far.
Definition: DummyLearner.cpp:74
iCub::learningmachine::IFixedSizeLearner
Definition: IFixedSizeLearner.h:44
iCub::learningmachine::DummyLearner::readBottle
virtual void readBottle(yarp::os::Bottle &bot)
Unserializes a machine from a bottle.
Definition: DummyLearner.cpp:89
v
static int v
Definition: iCub_Sim.cpp:42
iCub::learningmachine::IMachineLearner::setName
void setName(const std::string &name)
Set the name of this machine learning technique.
Definition: IMachineLearner.h:237
iCub::learningmachine::DummyLearner::predict
Prediction predict(const yarp::sig::Vector &input)
Ask the learning machine to predict the output for a given input.
Definition: DummyLearner.cpp:56