51 Layer(
int inputSize,
int outputSize,
const std::string &activationFunction =
"relu")
52 : inputSize(inputSize), outputSize(outputSize), activationFunction(activationFunction)
55 W = Eigen::MatrixXd::Random(outputSize, inputSize) * 0.5;
56 b = Eigen::VectorXd::Random(outputSize) * 0.5;
93 void updateWeights(
const Eigen::MatrixXd &dW,
const Eigen::VectorXd &db,
double learningRate)
95 W -= learningRate * dW;
96 b -= learningRate * db;
108 std::pair<Eigen::MatrixXd, Eigen::MatrixXd>
forward(
const Eigen::MatrixXd &input);
121 Eigen::MatrixXd
backward(
const Eigen::MatrixXd &nextW,
const Eigen::MatrixXd &nextdZ,
const Eigen::MatrixXd &currZ);
137 std::string activationFunction;
Represents a single layer in a neural network.
Definition Layer.h:38
std::pair< Eigen::MatrixXd, Eigen::MatrixXd > forward(const Eigen::MatrixXd &input)
Forward pass through the layer.
Definition Layer.cpp:25
Eigen::MatrixXd backward(const Eigen::MatrixXd &nextW, const Eigen::MatrixXd &nextdZ, const Eigen::MatrixXd &currZ)
Backward pass through the layer.
Definition Layer.cpp:64
void updateWeights(const Eigen::MatrixXd &dW, const Eigen::VectorXd &db, double learningRate)
Update weights and biases.
Definition Layer.h:93
Eigen::MatrixXd getWeights() const
Getters for weights.
Definition Layer.h:66
Layer(int inputSize, int outputSize, const std::string &activationFunction="relu")
Constructor for the Layer class.
Definition Layer.h:51
Eigen::VectorXd getBiases() const
Getters for biases.
Definition Layer.h:78
Namespace for the FlexNN neural network library.