-
Notifications
You must be signed in to change notification settings - Fork 0
/
fc_layer_sp.h
executable file
·59 lines (46 loc) · 1.99 KB
/
fc_layer_sp.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
48
49
50
51
52
53
54
55
56
57
58
/******************************************************
*
* FEEDFORWARD LAYER WITH SOFTPLUS ACTIVATION
* FUNCTION
*
******************************************************/
/*!
* \brief Feedforward layer with softplus activation function.
*/
#ifndef FC_LAYER_SP_H
#define FC_LAYER_SP_H
//STD libs
#include<vector>
#include<omp.h>
//Eigen libs
#include"Eigen/Dense"
//Neural network libs
#include"activation_functions.h"
#include"layer.h"
class fc_layer_sp : public layer
{
public:
//ctors
/**Default constructor. */
fc_layer_sp( ) : layer() { };
/**Initializes a feedforward layer with softplus activation function given a matrix of weights and a vector of biases. */
fc_layer_sp(const std::vector<std::vector<double>> &weights_, const std::vector<double> &biases_);
/**Initializes a feedforward layer with softplus activation function given a matrix of weights and a vector of biases. */
fc_layer_sp(const Eigen::MatrixXd &weights_, const Eigen::VectorXd &biases_);
/**Initializes a feedforward layer with softplus activation function given a matrix of weights and a vector of biases. */
fc_layer_sp(const Eigen::MatrixXd &weights_, const std::vector<double> &biases_);
//dtor
/**Default deconstructor. */
~fc_layer_sp(){ };
//Computes the output of the layer given an input
/**Computes the output of the layer given an Eigen::VectorXd as input. */
Eigen::VectorXd predict(const Eigen::VectorXd & input) override;
/**Computes the outputs of the layer given a vector<Eigen::VectorXd> as input. */
std::vector<Eigen::VectorXd> predict_batch(const std::vector<Eigen::VectorXd> & input) override;
//Jacobians
/**Computes the Jacobian matrix with respect to the input variables. The Jacobian is computer in reduced form. */
Eigen::MatrixXd compute_partial_derivatives_wrt_inputs(Eigen::VectorXd &input);
/**Computes the Jacobian matrix with respect to weights and biases. */
Eigen::MatrixXd compute_partial_derivatives_wrt_weights_biases(Eigen::VectorXd &input);
};
#endif /* FC_layer_sp_H */