-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlayer.h
More file actions
70 lines (48 loc) · 1.06 KB
/
Copy pathlayer.h
File metadata and controls
70 lines (48 loc) · 1.06 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef LAYER_H
#define LAYER_H
#include "common.h"
#include "utils.h"
#include "scenario.h"
enum Activation {
Sigmoid,
Tanh,
ReLU,
Softmax
};
struct LayerConfig {
int rows;
int cols;
Activation activation;
bool is_dropout = false;
bool is_dropgrad = false;
bool is_dropconnect = false;
bool is_enabled = false;
int epoch_count = 0;
};
class Layer {
public:
Layer(const LayerConfig& layerConfig);
virtual ~Layer();
virtual void feedforward(bool testing = false);
virtual void backpropagate();
virtual void update(float momentum, float learning_rate);
virtual void preEpoch(const int epoch);
virtual void report();
public:
Eigen::MatrixXf X;
Eigen::MatrixXf Y;
// to previous layer
Eigen::MatrixXf DY;
// from next layer
Eigen::MatrixXf D;
Eigen::MatrixXf W;
protected:
Eigen::MatrixXf W_change;
Eigen::VectorXf B;
float B_change;
Eigen::MatrixXf DW;
Eigen::MatrixXf m_gradient;
Eigen::MatrixXf(*activation)(Eigen::MatrixXf&);
Eigen::MatrixXf(*dactivation)(Eigen::MatrixXf&);
};
#endif