Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "Threshold_Func.h"
- #include <Eigen/Dense>
- #include <EigenRand/EigenRand>
- #include <utility>
- namespace network {
- class Layer {
- public:
- using MatrixXd = Eigen::MatrixXd;
- using VectorXd = Eigen::VectorXd;
- Layer(Threshold_Id id, int rows, int columns);
- MatrixXd apply(const MatrixXd &x) const; // vector of values
- MatrixXd derive(const MatrixXd &vec)
- const; // vec is a matrix of y_i = (Ax + b)_i - result of apply
- MatrixXd gradA(const VectorXd &x, const VectorXd &u,
- const VectorXd &vec) const; // u is a gradient vector
- MatrixXd gradb(const VectorXd &u, const VectorXd &vec) const;
- VectorXd gradx(const VectorXd &u, const VectorXd &vec) const;
- void apply_gradA(const MatrixXd &grad, double step);
- void apply_gradb(const VectorXd &grad, double step);
- private:
- static MatrixXd getNormal(int rows, int columns);
- static inline Eigen::Rand::Vmt19937_64 urng = 1;
- Threshold_Func threshold_func_;
- MatrixXd A_;
- MatrixXd b_;
- };
- } // namespace network
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement