-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample_slp.h
35 lines (28 loc) · 880 Bytes
/
example_slp.h
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
#ifndef LIB_CPPDL_EXAMPLE_SLP_H
#define LIB_CPPDL_EXAMPLE_SLP_H
#include "src/slp/single_perceptron.h"
void ExampleSLP() {
const int data_nums = 4;
const int input_nums = 3;
float x[data_nums][input_nums] = {{1, 0, 0}, {1, 0, 1}, {1, 1, 0}, {1, 1, 1}};
float t[data_nums] = {0, 0, 0, 1};
float w[input_nums] = {-0.5, 0, 0};
float e = 0.1;
int epoch = 10;
float **input_x;
input_x = new float*[data_nums];
for (int i = 0; i < data_nums; i++) {
input_x[i] = new float[input_nums];
for (int j = 0; j < input_nums; j++) {
input_x[i][j] = x[i][j];
}
}
SLP slp(e, input_x, t, w, data_nums, input_nums, epoch);
slp.SLPProcess();
slp.TerminateProcess();
for (int i = 0; i < data_nums; i++) {
delete[] input_x[i];
}
delete [] input_x;
}
#endif //LIB_CPPDL_EXAMPLE_SLP_H