# indranramesh/dl-from-scratch architecture

> Architecture diagram of the GitHub repository indranramesh/dl-from-scratch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/indranramesh/dl-from-scratch
- Repository: https://github.com/indranramesh/dl-from-scratch

## Overview

This repository is a small learning exercise demonstrating binary classification with a single neuron. Its main workflow generates synthetic examples, computes a linear score, applies sigmoid, and evaluates binary cross-entropy; a NumPy script also contains a manual gradient-update loop. A separate PyTorch script demonstrates the same task with automatic differentiation. The excerpts show both implementations, but do not establish that one invokes the other. The NumPy loop does not recompute predictions after updating its parameters.

Main entry points: [`train_torch.py`](https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py) (Binary Cross-Entropy), [`forward_pass.py`](https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py) (Manual Gradients)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_numpy["NumPy Walkthrough"]
  node_np_script["NumPy Script<br/>[forward_pass.py]"]
  node_np_data["Synthetic Data<br/>[forward_pass.py]"]
  node_np_labels["Binary Labels<br/>[forward_pass.py]"]
  node_np_params["Initial Parameters<br/>[forward_pass.py]"]
  node_np_linear["Weighted Sum<br/>[forward_pass.py]"]
  node_np_sigmoid["Sigmoid<br/>[forward_pass.py]"]
  node_np_bce["Cross-Entropy Loss<br/>[forward_pass.py]"]
  node_np_gradient["Manual Gradients<br/>[forward_pass.py]"]
  node_np_update["Parameter Update<br/>[forward_pass.py]"]
end

subgraph group_torch["PyTorch Walkthrough"]
  node_torch_script["PyTorch Script<br/>[train_torch.py]"]
  node_torch_data["Synthetic Data<br/>[train_torch.py]"]
  node_torch_tensors["Input Tensors<br/>[train_torch.py]"]
  node_torch_params["Tracked Parameters<br/>[train_torch.py]"]
  node_torch_linear["Linear Score<br/>[train_torch.py]"]
  node_torch_sigmoid["Sigmoid<br/>[train_torch.py]"]
  node_torch_loss["Binary Cross-Entropy<br/>[train_torch.py]"]
  node_torch_backward["Autograd Backward<br/>[train_torch.py]"]
  node_torch_update["Parameter Update<br/>[train_torch.py]"]
  node_torch_report["Training Report<br/>[train_torch.py]"]
end

node_learner(("Learner"))

node_learner -.->|"runs"| node_np_script
node_np_script -->|"generates"| node_np_data
node_np_data -->|"derives"| node_np_labels
node_np_data -->|"multiplies"| node_np_linear
node_np_params -->|"weights"| node_np_linear
node_np_linear -->|"feeds"| node_np_sigmoid
node_np_sigmoid -->|"scores against"| node_np_bce
node_np_labels -->|"labels"| node_np_bce
node_np_bce -->|"reports loss"| node_np_gradient
node_np_sigmoid -->|"supplies predictions"| node_np_gradient
node_np_labels -->|"supplies targets"| node_np_gradient
node_np_gradient -->|"updates"| node_np_update
node_learner -.->|"runs"| node_torch_script
node_torch_script -->|"generates"| node_torch_data
node_torch_data -->|"converts"| node_torch_tensors
node_torch_tensors -->|"computes"| node_torch_linear
node_torch_params -->|"weights"| node_torch_linear
node_torch_linear -->|"feeds"| node_torch_sigmoid
node_torch_sigmoid -->|"scores against"| node_torch_loss
node_torch_tensors -->|"provides labels"| node_torch_loss
node_torch_loss -->|"backpropagates"| node_torch_backward
node_torch_backward -->|"updates gradients"| node_torch_update
node_torch_params -->|"receives updates"| node_torch_update
node_torch_update -->|"reports parameters"| node_torch_report
node_torch_loss -->|"logs loss"| node_torch_report

click node_np_script "https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py"
click node_np_data "https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py"
click node_np_labels "https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py"
click node_np_params "https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py"
click node_np_linear "https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py"
click node_np_sigmoid "https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py"
click node_np_bce "https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py"
click node_np_gradient "https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py"
click node_np_update "https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py"
click node_torch_script "https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py"
click node_torch_data "https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py"
click node_torch_tensors "https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py"
click node_torch_params "https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py"
click node_torch_linear "https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py"
click node_torch_sigmoid "https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py"
click node_torch_loss "https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py"
click node_torch_backward "https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py"
click node_torch_update "https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py"
click node_torch_report "https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_np_script,node_np_data,node_np_labels,node_np_params,node_np_linear,node_np_sigmoid,node_np_bce,node_np_gradient,node_np_update toneBlue
class node_torch_script,node_torch_data,node_torch_tensors,node_torch_params,node_torch_linear,node_torch_sigmoid,node_torch_loss,node_torch_backward,node_torch_update,node_torch_report toneAmber
class node_learner toneIndigo
```

## Components

### NumPy Walkthrough

- [NumPy Script](https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py): `forward_pass.py`
- [Synthetic Data](https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py): `forward_pass.py`
- [Binary Labels](https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py): `forward_pass.py`
- [Initial Parameters](https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py): `forward_pass.py`
- [Weighted Sum](https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py): `forward_pass.py`
- [Sigmoid](https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py): `forward_pass.py`
- [Cross-Entropy Loss](https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py): `forward_pass.py`
- [Manual Gradients](https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py): `forward_pass.py`
- [Parameter Update](https://github.com/indranramesh/dl-from-scratch/blob/main/forward_pass.py): `forward_pass.py`

### PyTorch Walkthrough

- [PyTorch Script](https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py): `train_torch.py`
- [Synthetic Data](https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py): `train_torch.py`
- [Input Tensors](https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py): `train_torch.py`
- [Tracked Parameters](https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py): `train_torch.py`
- [Linear Score](https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py): `train_torch.py`
- [Sigmoid](https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py): `train_torch.py`
- [Binary Cross-Entropy](https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py): `train_torch.py`
- [Autograd Backward](https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py): `train_torch.py`
- [Parameter Update](https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py): `train_torch.py`
- [Training Report](https://github.com/indranramesh/dl-from-scratch/blob/main/train_torch.py): `train_torch.py`

### Other components

- **Learner**

## Connections

- Learner → NumPy Script: runs
- NumPy Script → Synthetic Data: generates (evidence: `forward_pass.py`)
- Synthetic Data → Binary Labels: derives (evidence: `forward_pass.py`)
- Synthetic Data → Weighted Sum: multiplies (evidence: `forward_pass.py`)
- Initial Parameters → Weighted Sum: weights (evidence: `forward_pass.py`)
- Weighted Sum → Sigmoid: feeds (evidence: `forward_pass.py`)
- Sigmoid → Cross-Entropy Loss: scores against (evidence: `forward_pass.py`)
- Binary Labels → Cross-Entropy Loss: labels (evidence: `forward_pass.py`)
- Cross-Entropy Loss → Manual Gradients: reports loss (evidence: `forward_pass.py`)
- Sigmoid → Manual Gradients: supplies predictions (evidence: `forward_pass.py`)
- Binary Labels → Manual Gradients: supplies targets (evidence: `forward_pass.py`)
- Manual Gradients → Parameter Update: updates (evidence: `forward_pass.py`)
- Learner → PyTorch Script: runs
- PyTorch Script → Synthetic Data: generates (evidence: `train_torch.py`)
- Synthetic Data → Input Tensors: converts (evidence: `train_torch.py`)
- Input Tensors → Linear Score: computes (evidence: `train_torch.py`)
- Tracked Parameters → Linear Score: weights (evidence: `train_torch.py`)
- Linear Score → Sigmoid: feeds (evidence: `train_torch.py`)
- Sigmoid → Binary Cross-Entropy: scores against (evidence: `train_torch.py`)
- Input Tensors → Binary Cross-Entropy: provides labels (evidence: `train_torch.py`)
- Binary Cross-Entropy → Autograd Backward: backpropagates (evidence: `train_torch.py`)
- Autograd Backward → Parameter Update: updates gradients (evidence: `train_torch.py`)
- Tracked Parameters → Parameter Update: receives updates (evidence: `train_torch.py`)
- Parameter Update → Training Report: reports parameters (evidence: `train_torch.py`)
- Binary Cross-Entropy → Training Report: logs loss (evidence: `train_torch.py`)
