-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNNLayer.hpp
More file actions
55 lines (36 loc) · 1.18 KB
/
NNLayer.hpp
File metadata and controls
55 lines (36 loc) · 1.18 KB
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
48
49
50
51
52
53
54
55
#ifndef NNLAYER_HPP
#define NNLAYER_HPP
#include <iostream>
#include <eigen3/Eigen/Eigen>
float f_activation(float x);
float f_activation_d(float x);
class NNLayer {
private:
int input_size;
int output_size;
float learning_rate;
std::string f_act = "none";
Eigen::MatrixXf* pWeights;
Eigen::RowVectorXf* pQValues;
Eigen::RowVectorXf* pQValuesU;
Eigen::RowVectorXf* pInput;
// ADAM Optimizer
Eigen::MatrixXf* m;
Eigen::MatrixXf* v;
float beta_1 = 0.9;
float beta_2 = 0.999;
int time = 1;
float adam_epsilon = 0.00000001;
bool bDebug;
public:
NNLayer(int input_size, int output_size, std::string activation = "none", float lr = 0.001, bool bDebug = false);
~NNLayer();
void debug_mode(bool bdbg = false);
Eigen::RowVectorXf* forward(Eigen::RowVectorXf& input);
void update_weights(Eigen::MatrixXf& gradient);
Eigen::RowVectorXf* backward(Eigen::RowVectorXf& gradient_from_above);
void set_weights(Eigen::MatrixXf* pWeights1);
Eigen::MatrixXf* get_weights();
void update_time();
};
#endif