Commit a593c2bc authored by Michael Zbyszyński's avatar Michael Zbyszyński
Browse files

fixing references to default phrase in XMM

parent 58ff6a2f
......@@ -56,6 +56,12 @@ bool machineLearning<seriesClassification>::train(const trainingData &newTrainin
return seriesClassification::trainLabel(seriesSet);
}
///Generic train
template <class MachineLearningModule>
bool machineLearning<MachineLearningModule>::train(const trainingData &newTrainingData) {
return MachineLearningModule::train(newTrainingData);
}
template<>
std::string machineLearning<classification>::run(const std::vector<double> &inputVector, const std::string &label) {
int classIndex = classification::run(inputVector)[0];
......
......@@ -3,17 +3,16 @@
#include "machineLearning.h"
static bool trainingData2xmmTrainingSet(const rapidmix::trainingData& data, xmm::TrainingSet& set) {
if (data.trainingSet.size() <= 1) {
// no recorded phrase (only default one)
if (data.trainingSet.size() < 1) {
return false;
}
if (data.trainingSet.size() > 1 && data.trainingSet[1].elements.size() == 0) {
if (data.trainingSet.size() > 0 && data.trainingSet[0].elements.size() == 0) {
// empty recorded phrase
return false;
}
rapidmix::trainingData::element el = data.trainingSet[1].elements[0];
rapidmix::trainingData::element el = data.trainingSet[0].elements[0];
int dimIn = static_cast<int>(el.input.size());
int dimOut = static_cast<int>(el.output.size());
......@@ -43,9 +42,7 @@ static bool trainingData2xmmTrainingSet(const rapidmix::trainingData& data, xmm:
set.clear();
//for (auto &phrase : data.trainingSet) {
// changed to look starting from index 1
// because phrase at index 0 is for unordered elements
for (int i = 1; i < data.trainingSet.size(); ++i) {
for (int i = 0; i < data.trainingSet.size(); ++i) {
const rapidmix::trainingData::phrase &phrase = data.trainingSet[i];
xp.clear();
xp.label.set(phrase.label);
......@@ -193,6 +190,8 @@ std::vector<double> rapidXmmHmr::run(const std::vector<double>& inputVector) {
///// generic train method and forward declaration of specialized templates
///////////////////////////////////////////////////////////////////////////
//I wonder why this can't be defined in machineLearning.cpp? -MZ
template <class MachineLearningModule>
bool rapidmix::machineLearning<MachineLearningModule>::train(const trainingData &newTrainingData) {
return MachineLearningModule::train(newTrainingData);
......
Markdown is supported
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