https://github.com/jkosla/neural_network_from_scratch_numpy
Neural Network From Scratch in Python | Build a simple neural network from scratch using pure Python and NumPy. Learn about forward propagation, backpropagation, and training with gradient descent. Accompanies my Medium article.
https://github.com/jkosla/neural_network_from_scratch_numpy
ai aritificial-intelligence medium nerual-networks numpy python3 tutorial
Last synced: 10 months ago
JSON representation
Neural Network From Scratch in Python | Build a simple neural network from scratch using pure Python and NumPy. Learn about forward propagation, backpropagation, and training with gradient descent. Accompanies my Medium article.
- Host: GitHub
- URL: https://github.com/jkosla/neural_network_from_scratch_numpy
- Owner: jkosla
- Created: 2025-03-31T10:01:36.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-03-31T10:25:56.000Z (10 months ago)
- Last Synced: 2025-03-31T11:23:37.695Z (10 months ago)
- Topics: ai, aritificial-intelligence, medium, nerual-networks, numpy, python3, tutorial
- Language: Jupyter Notebook
- Homepage: https://medium.com/@jkosla/introduction-to-neural-networks-building-a-neural-network-from-scratch-in-python-with-d7b84b2b64b7
- Size: 410 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🧠Neural Network From Scratch in Python
This repository contains the full implementation of a **simple neural network built from scratch** in Python, as demonstrated in my [Medium article]().
---
## 📖 Overview
In this project, we build a **fully connected neural network** from scratch without using deep learning libraries like PyTorch or TensorFlow. The implementation includes:
- **Forward Propagation**
- **Backpropagation**
- **Training with Gradient Descent**
- **Evaluation & Accuracy Calculation**
The code is designed to be simple and educational, demonstrating the core concepts of neural networks. Perfect for beginners who want to understand how neural networks work under the hood!
---
## 📂 Files
- `simple_nn.py` — Implementation of the neural network.
- `train.py` — Training script with evaluation functions.
- `dataset.py` — Helper functions for data processing and evaluation.
---
## 💡 Getting Started
### Requirements
- Python 3.x
- NumPy
Install dependencies:
```bash
pip install numpy
pip install matplotlib
```
## Usage:
```python
%matplotlib inline
from dataset import visualize_classification, XORDataset
import matplotlib.pyplot as plt
from simple_nn import SimpleClassifier, GradientDescent
from train_nn import train_model, eval_model, create_data_loader
```
```python
num_inputs = 2
num_hidden = 4
num_outputs = 1
train_dataset = XORDataset(size=2500)
test_dataset = XORDataset(size=500)
train_data_loader = create_data_loader(train_dataset)
test_data_loader = create_data_loader(test_dataset)
model = SimpleClassifier(num_inputs, num_hidden, num_outputs)
optimizer = GradientDescent(lr=0.01)
```
```python
_ = visualize_classification(model, test_dataset.data, test_dataset.label)
```

```python
train_model(model, train_data_loader, optimizer)
eval_model(model, test_data_loader)
_ = visualize_classification(model, test_dataset.data, test_dataset.label)
```
Model Accuracy: 100.00%
