# DDPM-NumPy-from-Scratch This repository contains a **Denoising Diffusion Probabilistic Model (DDPM)** implemented purely using **NumPy** for demonstration and educational purposes. The goal of this project is to showcase a deep, fundamental understanding of Diffusion Models by building the core training and inference mechanics from scratch, without relying on high-level frameworks like PyTorch or TensorFlow. ## 🧠 Core Algorithmic Mechanics This implementation includes a custom, low-level implementation of all critical components: * **Forward and Reverse Diffusion:** Full implementation of the noise scheduling process. * **Time Embedding:** Positional encoding of the timestep variable, essential for the Diffusion Model's MLP (Noise Predictor). * **Custom Backpropagation:** Manual gradient calculation for the MLP, demonstrating a solid grasp of deep learning fundamentals. * **AdamW Optimizer:** Implementation of the AdamW optimization algorithm from scratch. * **Noise Scheduling:** Utilization of the standard **Cosine Scheduler** for stable training. ## 🛠️ Project Structure and Verification The clean structure ensures that the core logic is separate from the testing utilities: * `src/ddpm_numpy_training.py`: The complete core DDPM training and inference logic. * `tests/test_ddpm_core.py`: **Comprehensive Unit Tests** to verify the shape and correctness of all core functions (scheduler, time embedding, AdamW update, etc.). ## ✅ Getting Started (Requirements) Given the nature of the project, only the NumPy library is required: ```bash pip install numpy