iCub-main
Loading...
Searching...
No Matches
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
29namespace iCub {
30namespace learningmachine {
31
32std::string printVector(const yarp::sig::Vector& v);
45private:
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
67public:
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 */
114 std::string getInfo();
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
This dummy machine learner demonstrates how the IMachineLearner interface can be used in practice.
virtual void writeBottle(yarp::os::Bottle &bot) const
Writes a serialization of the machine into a bottle.
virtual ~DummyLearner()
Destructor (empty).
virtual void train()
Train the learning machine on the examples that have been supplied so far.
void reset()
Forget everything and start over.
std::string getInfo()
Asks the learning machine to return a string containing information on its operation so far.
virtual void feedSample(const yarp::sig::Vector &input, const yarp::sig::Vector &output)
Provide the learning machine with an example of the desired mapping.
DummyLearner * clone()
Asks the learning machine to return a clone of its type.
DummyLearner(unsigned int dom=1, unsigned int cod=1)
Constructor.
Prediction predict(const yarp::sig::Vector &input)
Ask the learning machine to predict the output for a given input.
virtual void readBottle(yarp::os::Bottle &bot)
Unserializes a machine from a bottle.
An generalized interface for a learning machine with a fixed domain and codomain size.
virtual void setCoDomainSize(unsigned int size)
Mutator for the codomain size.
virtual void setDomainSize(unsigned int size)
Mutator for the domain size.
void setName(const std::string &name)
Set the name of this machine learning technique.
A class that represents a prediction result.
Definition Prediction.h:44
std::string printVector(const yarp::sig::Vector &v)
This file contains the definition of unique IDs for the body parts and the skin parts of the robot.