-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOutputTarget.cpp
More file actions
44 lines (36 loc) · 787 Bytes
/
OutputTarget.cpp
File metadata and controls
44 lines (36 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* OutputTarget.cpp
*
* Created on: Jun 23, 2016
* Author: trabucco
*/
#include "OutputTarget.h"
OutputTarget::OutputTarget(int n, int c) {
nodes = n;
classes = c;
for (int i = 0; i < c; i++) {
vector<double> temp;
for (int j = 0; j < n; j++) {
if (i == j) temp.push_back(1.0);
else temp.push_back(-1.0);
} classifiers.push_back(temp);
}
}
OutputTarget::~OutputTarget() {
}
vector<double> OutputTarget::getOutputFromTarget(int c) {
return classifiers[c];
}
int OutputTarget::getTargetFromOutput(vector<double> output) {
for (int i = 0; i < classes; i++) {
bool matches = true;
for (int j = 0; j < nodes; j++) {
if (abs(output[j] - classifiers[i][j]) >= 1) {
matches = false;
break;
}
}
if (matches) return i;
}
return -1;
}