6 #ifndef NEURAL_NETWORK_H
7 #define NEURAL_NETWORK_H
9 #include "../linear_algebra/matrix.h"
10 #include "../linear_algebra/vector.h"
24 NeuralNetwork(
int input_size,
int hidden_size,
int output_size);
Represents a matrix with GPU-accelerated operations.
int get_rows() const
Get the number of rows in the matrix.
double * get_data() const
Get the raw data pointer of the matrix.
int get_cols() const
Get the number of columns in the matrix.
Represents a simple feedforward neural network with one hidden layer.
double * get_b1_data() const
Get the pointer to the b1 vector data.
void backward(const Matrix &X, const Matrix &Y)
Perform backward propagation through the network.
Matrix get_DW1() const
Get the DW1 matrix.
void update_params(double learning_rate)
Updates the network parameters based on computed gradients.
double get_accuracy(const Matrix &Y) const
Calculate the accuracy of predictions compared to true labels.
void forward(const Matrix &X)
Perform forward propagation through the network.
double get_db2() const
Get the db2 scalar.
int get_b1_size() const
Get the size of the b1 vector.
double * get_W2_data() const
Get the pointer to the W2 matrix data.
std::pair< int, int > get_Z1_dimensions() const
Get the dimensions of the Z1 matrix.
int get_b2_size() const
Get the size of the b2 vector.
double * get_b2_data() const
Get the pointer to the b2 vector data.
double * get_W1_data() const
Get the pointer to the W1 matrix data.
void initialize()
Initialize the neural network parameters.
double * get_A1_data() const
Get the pointer to the A1 matrix data (activation of hidden layer)
~NeuralNetwork()
Destroy the NeuralNetwork object.
double get_db1() const
Get the db1 scalar.
std::pair< int, int > get_W2_dimensions() const
Get the dimensions of the W2 matrix.
double * get_A_data() const
Get the pointer to the A matrix data (input matrix)
std::pair< int, int > get_A1_dimensions() const
Get the dimensions of the A1 matrix.
double * get_Z2_data() const
Get the pointer to the Z2 matrix data (pre-activation of output layer)
Vector get_predictions() const
Get predictions from the output layer (A2)
std::pair< int, int > get_W1_dimensions() const
Get the dimensions of the W1 matrix.
std::pair< int, int > get_Z2_dimensions() const
Get the dimensions of the Z2 matrix.
Matrix get_DW2() const
Get the DW2 matrix.
std::pair< int, int > get_A2_dimensions() const
Get the dimensions of the A2 matrix.
double * get_A2_data() const
Get the pointer to the A2 matrix data (activation of output layer)
double * get_Z1_data() const
Get the pointer to the Z1 matrix data (pre-activation of hidden layer)
void gradient_descent(const Matrix &X, const Matrix &Y, double learning_rate, int epochs)
Perform gradient descent to train the neural network.
std::pair< int, int > get_A_dimensions() const
Get the dimensions of the A matrix.
NeuralNetwork(int input_size, int hidden_size, int output_size)
Construct a new NeuralNetwork object.
Represents a vector with GPU-accelerated operations.
int get_rows() const
Get the number of elements in the vector.
double * get_data() const
Get the raw data pointer of the vector.