How r8025n/neural-network works
Project Type and Purpose
• This is a standalone Python application implementing a fully-connected feedforward neural network using only NumPy.
• Purpose: load the MNIST dataset, train a network via mini-batch SGD and backpropagation, and allow easy experimentation.
File Structure
• Top-level scripts:
• main.py – entry point / orchestrator
• network.py – the NeuralNetwork class (forward pass, backprop, weight updates)
• data_loader.py – loads and preprocesses MNIST from data/mnist.pkl.gz
• utils.py – activation functions (sigmoid, sigmoid_prime), evaluation helpers
• Data folder: data/mnist.pkl.gz – compressed dataset
• No external services or microservices—monolithic script.
Extract Key Architecture Insights from README
• Single process, linear pipeline: Data → Network → Training loop.
• Core dependencies: Python 3.x, NumPy only.
• No REST API or UI layer—CLI-driven training script.
Main Components
A. Data Source
• MNIST dataset file (data/mnist.pkl.gz)
B. Data Loader Layer (data_loader.py)
• Loads, unpacks, yields mini-batches
C. Model Layer (network.py)
• NeuralNetwork class with:
– Weight and bias storage
– forward() method
– backprop() method
– update_mini_batch() method
D. Utility Layer (utils.py)
• Activation functions (sigmoid, sigmoid_prime)
E. Orchestration Layer (main.py)
• Reads parameters (epochs, batch size, architecture)
• Invokes data loader → training loop → evaluation
F. Environment
• Python runtime, NumPy library
Relationships and Data Flow
• Loop: Orchestration Layer iterates over epochs and batches
Architectural Patterns and Principles
• Layered architecture: separate data ingestion, computation, and orchestration
• Single-responsibility: each module has a well-defined role
• Pipeline pattern: sequential processing of mini-batches
• No external service dependencies—self-contained.
Technologies and Frameworks
• Python 3.x – runtime
• NumPy – numerical computations
• gzip / pickle – data serialization