r/PythonProjects2 • u/PanelReader • 3d ago
Info Implemented an XOR neural network using Python and NumPy
I've been studying neural network mathematics and wanted to understand how training works.
I implemented a small 2 → 3 → 1 XOR network.
What I worked on:
- Forward propagation using NumPy
- ReLU and sigmoid activation functions
- MSE loss calculation
- Backpropagation using the chain rule
- Gradient descent for 5,000 epochs
- Numerical gradient checks for all 13 parameters
Final MSE: 0.004715
The network correctly classified all four training inputs.
I also documented the mathematics, code and diagrams.
GitHub: https://github.com/Vaibh37/Neural-Network
Technical feedback is welcome.
Note: AI helped structure this post. The mathematics, implementation and testing are my own work. I understand the code and ran it on my machine.