How activatedgeek/lenet-5 works
Main Components
a. Data Source
• MNIST dataset (external)
• Data loader/preprocessing logic baked into run.py (using torchvision or similar)
b. Model Definition
• lenet.py – defines the LeNet-5 architecture (convolutional, pooling, fully connected layers)
c. Training Orchestrator
• run.py – sets up the training loop:
– Instantiates model, loss fn, optimizer
– Loads batches from MNIST
– Performs forward/backward passes
– Sends scalar metrics (train loss) to Visdom
– Saves/export model as lenet.onnx
d. Visualization Service
• Visdom server (python –m visdom.server) running on localhost:8097
• Receives real-time loss updates via Visdom client API in run.py
e. Model Export and Viewing
• ONNX export (lenet.onnx)
• External viewer (Netron) to inspect the graph
Relationships and Data Flows
• MNIST data → (Data Loader) → Model (lenet.py)
• Model forward/backward → Optimizer → Updated model weights
• Loss & epoch metrics → Visdom client → Visdom server → Browser graph
• Final model → ONNX exporter → lenet.onnx → Netron
Architectural Patterns & Design Principles
• Pipeline pattern: clear separation of data ingestion, model definition, training loop, visualization, and export
• Modular code: lenet.py (model) vs run.py (orchestration)
• Externalized monitoring: decoupled Visdom server for real-time visualization
Key Technologies & Frameworks
• Python 3.x
• PyTorch (inferred via ONNX export, though requirements.txt will specify torch/torchvision)
• Visdom (visualization)
• ONNX (model interchange format)
• Netron (ONNX graph viewer)