This is a simple implementation of a neural network from scratch.
This project is a basic, feedforward neural network built using only NumPy and Pandas.
The network is designed for classification tasks, such as recognizing handwritten digits from the MNIST dataset (input size 784 for 28x28 images, output size 10 for digits 0-9).
Follow these steps to set up the environment and run script:
Install the project dependencies from pyproject.toml and activate the virtual environment.
uv sync
source .venv/bin/activatepython NN.py-
Initialize the Network:
# nn.py nn = NeuralNetwork(input_layer_size=784, hidden_layer_sizes=(16, 16), output_layer_size=10)
-
Load Data:
# Make sure 'train.csv' is in the same directory nn.get_training_data('train.csv')
-
Perform a Forward Pass:
# Get the network's output for the 20th sample in the dataset predicted_output, actual_output = nn.forward_propagation(20) print("Predicted Output:", predicted_output)
- Implement the backpropagation algorithm to calculate gradients for weights and biases.
- Complete the
trainingmethod to iterate over the dataset and update weights. - Implement the
predictionmethod for making predictions on new data.