69 [[deprecated(
"use vector<FlexNN::Layers::Layer> with FlexNN::Activations")]]
80 void train(
const Eigen::MatrixXd& input,
const Eigen::VectorXd& target,
81 double learningRate,
int epochs);
86 double accuracy(
const Eigen::MatrixXd& X,
const Eigen::VectorXd& Y);
91 Eigen::MatrixXd
predict(
const Eigen::MatrixXd& input) {
92 auto outputs = forward(input);
93 return outputs.back();
99 const std::vector<Layers::Layer>&
layers() const noexcept {
return layers_; }
100 std::vector<Layers::Layer>&
layers() noexcept {
return layers_; }
104 std::vector<Layers::Layer> layers_;
110 std::vector<Eigen::MatrixXd> forward(
const Eigen::MatrixXd& input);
117 std::vector<Eigen::MatrixXd> backward(
118 const std::vector<Eigen::MatrixXd>& outputs,
119 const Eigen::MatrixXd& target);
124 void updateWeights(
const std::vector<Eigen::MatrixXd>& gradients,
125 double learningRate);
Public activation enum and helpers for FlexNN.
Header file for the Layer class in the FlexNN neural network library.
Type-erased wrapper for FlexNN::Layers — heterogeneous stack without inheritance.
Linear stack of heterogeneous layers (vector<Layers::Layer>).
Definition FlexNN.h:47
NeuralNetwork(const std::vector< Layers::Layer > &layers)
Construct from new modular layers (preferred).
Definition FlexNN.h:56
void train(const Eigen::MatrixXd &input, const Eigen::VectorXd &target, double learningRate, int epochs)
Train the network on (X, Y) with SGD.
Definition FlexNN.cpp:54
const std::vector< Layers::Layer > & layers() const noexcept
Direct access to layers (for tests / ModelIO).
Definition FlexNN.h:99
double accuracy(const Eigen::MatrixXd &X, const Eigen::VectorXd &Y)
Accuracy on (X, Y) — argmax per column.
Definition FlexNN.cpp:70
NeuralNetwork(std::vector< Layers::Layer > &&layers)
Definition FlexNN.h:57
std::vector< Layers::Layer > & layers() noexcept
Definition FlexNN.h:100
Eigen::MatrixXd predict(const Eigen::MatrixXd &input)
Predict — forward pass, returns activation of last layer.
Definition FlexNN.h:91
Namespace for the FlexNN neural network library.
Definition Activation.hpp:31