How mit-han-lab/tinyml works
Project Type & Purpose
• This is a research and demo repository for TinyML methods. Its goal is to develop and evaluate novel training techniques (NetAug) and on-device learning strategies (TinyTL) for tiny neural networks, alongside architectures like MCUNet.
• The README highlights the real-world edge application context (e.g., deployment on IoT devices) and includes a range of experiments and demo scripts for training and evaluating efficient neural network models.
Analysis of the File Structure
• Notice top-level directories such as “netaug”, “mcunet”, “tinytl”, and “once-for-all” (though the latter is a separate project folder or reference). The primary focus in this repository is on “netaug” and “tinytl”.
• Within “netaug”, you have subdirectories for bash scripts (automation for experiments across datasets like ImageNet and transfer tasks), configuration files (YAML files for setting up experiments), Python modules for models (divided further into “base” and “netaug” variants), utility functions (for metrics, scheduling, etc.), and training/evaluation scripts.
• In “tinytl”, you see directories for dataset setup scripts (which are used to process several benchmarks), experiment scripts (organized by batch runs), and the core “tinytl” Python module which includes modules for data providers, models, and utilities.
How to Represent the System Architecture
a. Main Components:
• For NetAug:
• A “Configuration” component (showing YAML config files).
• Separate “Model” components subdivided into “base” models and “netaug” enhanced models.
• A “Training & Evaluation” pipeline component (represented by train.py and eval.py).
• “Automation Scripts” (the bash scripts for running experiments on ImageNet and transfer datasets).
• “Utilities” for scheduling, profiling, and distributed training.
• For TinyTL:
• “Dataset Setup” scripts (for creating and managing datasets).
• “Experiment Scripts” (batch experiment directories and shell scripts for different domains).
• “Core Learning Module” (the tinytl Python package, including data providers, models, and helper utilities).
• Possibly a “Training Launcher” (e.g., tinytl_fgvc_train.py) that ties the components together.
b. Relationships & Data Flow:
• That the automation bash scripts coordinate with the Python training scripts to execute experiments.
• A data flow from dataset setup scripts into the training pipelines, as well as a feedback loop from evaluation (metrics, profiles) into potential model updates or hyperparameter tuning.
• Dependencies between core modules: for instance, how utility functions support both training and evaluation, and how model layers (both in “base” and “netaug”) abstract common functionalities.
c. Architectural Patterns & Design Principles:
• There is a clear modular separation between configuration, model definitions, training pipelines, and experiments. This separation hints at a loosely coupled design where experiments can be run independently by swapping configuration files or launching different bash scripts.
• The dual-level model organization in NetAug (base vs. netaug) suggests extensibility and reusability, useful design principles when dealing with evolving training techniques.
d. Technologies & Frameworks:
• Although not explicitly listed, it is likely that these Python components rely on deep learning frameworks (such as PyTorch or TensorFlow) given the focus on neural network experimentation.
• The use of shell/bash scripting points to an infrastructure for automated experiment management.
• YAML configuration files denote that experiments are easily parameterized and potentially integrated within larger CI/CD or distributed training systems.