Skip to content
Snippets Groups Projects
Commit 6622b16c authored by Francisco Bernardo's avatar Francisco Bernardo
Browse files

changes to rapidGVF

parent 53707b37
Branches
Tags
No related merge requests found
......@@ -14,7 +14,7 @@
#include "classification.h"
#include "regression.h"
#include "rapidXmmTools.h"
//#include "gvf.h"
#include "rapidGVF.h"
// forward declaration
namespace rapidmix { class trainingData; }
......@@ -58,11 +58,9 @@ typedef machineLearning<xmmGmmTool> xmmStaticClassification;
typedef machineLearning<xmmGmrTool> xmmStaticRegression;
typedef machineLearning<xmmHmmTool> xmmTemporalClassification;
typedef machineLearning<xmmHmrTool> xmmTemporalRegression;
//*/
/*
typedef machineLearning<GVF> gvf;
//*/
typedef machineLearning<rapidGVF> gvfTemporalVariation;
RAPIDMIX_END_NAMESPACE
......
......@@ -5,92 +5,97 @@
// Copyright © 2017 Goldsmiths. All rights reserved.
//
#include "gvf.h"
#include "rapidGVF.h"
#include "trainingData.h"
namespace rapidmix {
rapidGVF::rapidGVF()
{
}
rapidGVF::~rapidGVF()
{
bool trainingData2GVF (const trainingData &newTrainingData, std::vector<std::vector<float>> &trainingSet) {
if (newTrainingData.trainingSet.size() <= 1) {
// no recorded phrase (only default one)
return false;
}
if (newTrainingData.trainingSet.size() > 1 && newTrainingData.trainingSet[1].elements.size() == 0) {
// empty recorded phrase
return false;
}
for (int h = 0; h < newTrainingData.trainingSet.size(); ++h) { //Go through every phrase
for (int i = 0; i < newTrainingData.trainingSet[h].elements.size(); ++i) { //...and every element
// trainingExample tempExample;
// tempExample.input = newTrainingData.trainingSet[h].elements[i].input;
//
// if (newTrainingData.trainingSet[h].elements[i].output.size() > 0) {
// tempExample.output = newTrainingData.trainingSet[h].elements[i].output;
// } else {
// std::unordered_map<std::string, int>::const_iterator mappedLabel = newTrainingData.labels.find(newTrainingData.trainingSet[h].label);
// tempExample.output.push_back(double(mappedLabel->second));
// }
// trainingSet.push_back(tempExample);
}
}
return true;
};
}
bool rapidGVF::trainingData2GVF(const rapidmix::trainingData &newTrainingData, std::vector<std::vector<float>> &trainingSet) {
template<>
bool machineLearning<GVF>::train(const trainingData &newTrainingData) {
//
// std::vector<trainingExample> trainingSet;
//
// trainingData2GVF(newTrainingData, trainingSet);
//
// g
//
// return GVF::train(trainingSet);
//
//
//
// vector<vector<float>> trainingData;
//
// for (vector<vector<vector<float>>>::iterator trainingGesture = trainingData.begin(); trainingGesture != trainingData.end(); trainingGesture++)
// {
// currentGesture.clear();
// for (vector<vector<float>>::iterator frame = (*trainingGesture).begin(); frame != (*trainingGesture).end(); frame++)
// {
// Fill the template
// currentGesture.addObservation(*frame);
// }
// Add the template at the end of the gesture
// gvf->addGestureTemplate(currentGesture);
// }
//
return true;
if (newTrainingData.trainingSet.size() <= 1) {
// no recorded phrase (only default one)
return false;
}
template<>
std::vector<double> machineLearning<GVF>::process(const std::vector<double> &inputVector) {
if (newTrainingData.trainingSet.size() > 1 && newTrainingData.trainingSet[1].elements.size() == 0) {
// empty recorded phrase
return false;
}
for (int h = 0; h < newTrainingData.trainingSet.size(); ++h) { //Go through every phrase
return std::vector<double>();
for (int i = 0; i < newTrainingData.trainingSet[h].elements.size(); ++i) { //...and every element
// trainingExample tempExample;
// tempExample.input = newTrainingData.trainingSet[h].elements[i].input;
//
// if (newTrainingData.trainingSet[h].elements[i].output.size() > 0) {
// tempExample.output = newTrainingData.trainingSet[h].elements[i].output;
// } else {
// std::unordered_map<std::string, int>::const_iterator mappedLabel = newTrainingData.labels.find(newTrainingData.trainingSet[h].label);
// tempExample.output.push_back(double(mappedLabel->second));
// }
// trainingSet.push_back(tempExample);
}
}
// template<>
// bool machineLearning<GVF>::reset() {
//
// return true;
// }
//
return true;
};
bool rapidGVF::train(const rapidmix::trainingData &newTrainingData) {
//
// std::vector<trainingExample> trainingSet;
//
// trainingData2GVF(newTrainingData, trainingSet);
//
// g
//
// return GVF::train(trainingSet);
//
//
//
// vector<vector<float>> trainingData;
//
// for (vector<vector<vector<float>>>::iterator trainingGesture = trainingData.begin(); trainingGesture != trainingData.end(); trainingGesture++)
// {
// currentGesture.clear();
// for (vector<vector<float>>::iterator frame = (*trainingGesture).begin(); frame != (*trainingGesture).end(); frame++)
// {
// Fill the template
// currentGesture.addObservation(*frame);
// }
// Add the template at the end of the gesture
// gvf->addGestureTemplate(currentGesture);
// }
//
return true;
}
std::vector<double> rapidGVF::process(const std::vector<double> &inputVector){
template class rapidmix::machineLearning<GVF>;
return vector<double>();
}
......@@ -5,31 +5,29 @@
// Copyright © 2017 Goldsmiths. All rights reserved.
//
#ifndef gvf_h
#define gvf_h
#ifndef rapidGVF_h
#define rapidGVF_h
#include <vector>
#include <string>
#include "GVF.h"
#include "trainingData.h"
#include "machineLearning.h"
namespace rapidmix {
// typedef machineLearning<GVF> gvf;
bool trainingData2GVF (const trainingData &newTrainingData, vector<vector<float>> &trainingSet);
namespace rapidmix { class trainingData; }
class rapidGVF {
template<>
bool machineLearning<GVF>::train(const trainingData &newTrainingData);
rapidGVF();
~rapidGVF();
template<>
std::vector<double> machineLearning<GVF>::process(const std::vector<double> &inputVector);
bool train(const rapidmix::trainingData &newTrainingData);
template<>
bool machineLearning<GVF>::reset();
bool trainingData2GVF(const rapidmix::trainingData &newTrainingData, std::vector<std::vector<float>> &trainingSet);
}
std::vector<double> process(const std::vector<double> &inputVector);
};
#endif
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment