CUDA Networks
Functions
main.cu File Reference
#include <iostream>
#include "neural_network/neural_network.h"
Include dependency graph for main.cu:

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 4 of file main.cu.

4  {
5  try {
6  // Set parameters
7  int num_examples = 60000;
8  int input_size = 784;
9  int output_size = 10;
10  int hidden_size = 200; // Changed from 10 to 200
11  double learning_rate = 0.001;
12  int epochs = 200; // Changed from 1 to 200
13 
14  // Create input and output matrices
15  Matrix X_train(num_examples, input_size);
16  Matrix Y_train(num_examples, output_size);
17 
18  std::cout << "Reading training data..." << std::endl;
19  X_train.read_csv("data/X_train.csv");
20  Y_train.read_csv("data/Y_train.csv");
21 
22  // Transpose X_train and Y_train
23  std::cout << "Transposing matrices..." << std::endl;
24  Matrix X_train_transposed = X_train.transpose();
25  Matrix Y_train_transposed = Y_train.transpose();
26 
27  // Create neural network
28  std::cout << "Creating neural network..." << std::endl;
29  NeuralNetwork nn(input_size, hidden_size, output_size);
30 
31  // Perform gradient descent
32  std::cout << "Training neural network..." << std::endl;
33  nn.gradient_descent(X_train_transposed, Y_train_transposed, learning_rate, epochs);
34 
35  // Calculate final accuracy
36  double final_accuracy = nn.get_accuracy(Y_train_transposed);
37  std::cout << "Final training accuracy: " << final_accuracy << std::endl;
38 
39  std::cout << "Training completed successfully." << std::endl;
40  } catch (const std::exception& e) {
41  std::cerr << "Exception caught: " << e.what() << std::endl;
42  return 1;
43  }
44 
45  return 0;
46 }
Represents a matrix with GPU-accelerated operations.
Definition: matrix.h:18
Matrix transpose() const
Transposes the matrix and returns a new Matrix object.
Represents a simple feedforward neural network with one hidden layer.