-
Notifications
You must be signed in to change notification settings - Fork 0
/
perceptron.h
47 lines (44 loc) · 1.41 KB
/
perceptron.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
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef PERCEPTRON_H
#define PERCEPTRON_H
#include <vector>
class Network {
/*
Unit Perceptron Network
*/
public:
Network();
int perceptron(
const std::vector<float>& x, // input vector
const std::vector<float>& w, // weights
const float& b // bias
);
void train(
const std::vector<std::vector<float>>& x, // i input vectors
const std::vector<int>& t, // i outputs
const float b, // bias
const float r // learning rate
);
void test(
std::vector<std::vector<float>>& x // i input vectors
);
std::vector<int> get_output();
std::vector<float> get_network();
void show_output();
void show_network();
private:
float bias;
std::vector<int> results;
std::vector<float> network;
std::vector<float> update(
const std::vector<float>& xi, // ith unput array
std::vector<float>& w, // current network
const int& ti, // target value
const int& ai, // output of ith array
const float& r // learning rate
);
std::vector<int> output(
const std::vector<std::vector<float>>& x, // i input arrays
const std::vector<float>& w // current netork
);
};
#endif