Skip to main content

Hardware-Aware Neural Networks from Scratch

A pure NumPy implementation for training and evaluating neural networks under real-world hardware constraints. Build transparent, reproducible models with precision, memory, and latency awareness.

model.py

Quick Start

Get up and running in minutes with our streamlined workflow

1

Install dependencies

Clone the repository and install the required packages:
git clone https://github.com/RaviTejaMedarametla/neural-network-from-scratch.git
cd neural-network-from-scratch
pip install -r requirements.txt
pip install -r requirements-dev.txt
Verify your environment:
python scripts/verify_environment.py
2

Run your first experiment

Train a model with the baseline configuration using synthetic data:
python scripts/run_workflow.py --mode full --experiment baseline --stats-repeats 5
This will:
  • Train a 784→64→10 network on synthetic data
  • Run benchmarks measuring latency, memory, and throughput
  • Generate statistical analysis across 5 runs
3

Inspect the results

After training completes, check the output:
experiments/
├── checkpoints/      # Saved model weights (.npz files)
├── logs/             # Training history and metrics (JSON)
└── reports/          # Benchmark and profiling reports
View your experiment log:
cat experiments/logs/<experiment_id>.json
{
  "experiment_id": "baseline_1234567890",
  "version": 1,
  "config": {
    "layer_sizes": [784, 64, 10],
    "precision": "float32",
    "epochs": 2
  },
  "metrics": {
    "train_loss": [0.523, 0.312],
    "val_loss": [0.547, 0.329],
    "val_accuracy": [0.832, 0.891]
  }
}
4

Try hardware-constrained training

Run an experiment with memory and precision constraints:
python "Neural Network from Scratch/task/train.py" --experiment real_fashion_mnist
For advanced configurations, see the Experiments guide.

Key Features

Everything you need to study neural networks under realistic constraints

Pure NumPy Implementation

Transparent tensor operations with no hidden optimizations. Perfect for education and debugging.

Hardware Simulation

Model memory limits, compute speed, and precision degradation before deploying to real hardware.

Multi-Precision Support

Train in float32, infer in float16 or int8. Measure the accuracy-performance trade-off.

Comprehensive Benchmarking

Measure latency, throughput, memory usage, and energy consumption with statistical rigor.

Experiment Tracking

Every run is logged with full reproducibility metadata: seeds, dataset hashes, and hyperparameters.

Statistical Analysis

Aggregate metrics across multiple runs with confidence intervals and significance tests.

Profiling Tools

Layer-by-layer breakdown of compute time, memory allocations, and parameter counts.

ONNX Export

Export trained models to ONNX format for deployment in production runtime environments.

PyTorch Comparison

Validate your implementation against PyTorch’s reference behavior with automated tests.

Ready to get started?

Train your first hardware-aware neural network in under 5 minutes. No GPU required.

Start Building