A simple 2-layered neural network implemented from scratch using NumPy. This project demonstrates the core concepts of neural networks, including forward propagation, backpropagation, and gradient descent. It's designed for educational purposes and can classify non-linear datasets like spirals.
- 2-Layer Neural Network: One hidden layer with ReLU activation and an output layer with softmax activation.
- Kaiming Initialization: Weights initialized using Kaiming initialization for better convergence.
- Regularization: L2 regularization to prevent overfitting.
- Visualization: Plots decision boundaries and dataset for intuitive understanding.
- Accuracy Tracking: Monitors training accuracy and loss over epochs.
- Python
- NumPy: For numerical computations.
- Matplotlib: For data visualization.
- Clone the repository:
git clone https://github.com/aliii-codes/NeuralNetworkFromScratch.git cd NeuralNetworkFromScratch - Install required dependencies:
pip install numpy matplotlib
- Run the neural network on a synthetic spiral dataset:
python neural_net.py
- The script will train the network and save the decision boundary plot as
spiral_classification.png.
NeuralNetworkFromScratch/
│
├── neural_net.py # Main neural network implementation
├── utils.py # Utility functions for dataset creation and plotting
└── test.ipynb # Jupyter notebook for testing and experimentation
This project is licensed under the MIT License. See the LICENSE file for details.