8.12. On-Device Training (ODT)
On-device training lets a model continue training directly on the microcontroller after deployment. Instead of the classic flow (train on the PC, deploy a frozen model, inference only), the model is split into a frozen part and a trainable part. The frozen part is compiled for inference, and the trainable part is deployed with the training library, so the device can adapt to local data without a round trip to the PC.
Traditional: Train on PC -> Compile -> Deploy -> Inference only
On-device: Train on PC -> Split model -> Deploy frozen + trainable parts
-> Continue training on the MCU -> Inference
Use it when:
Data drifts: the installation differs from the lab where the model was trained.
Privacy matters: raw sensor data must not leave the device.
Each installation is different: personalize per motor, fan or machine without retraining on the PC.
Re-deployment is costly: adapting avoids the collect, retrain, recompile, reflash cycle.
8.12.1. Two frameworks
Tiny ML ModelZoo 1.5.0 has two ODT frameworks. Each has a full Markdown guide.
The core training library works in 32-bit floating point and is device agnostic. It supports partial training (freeze the early layers, train the last k) and full training. The supported task is anomaly detection with autoencoder models. The example is the fan blade anomaly detection on the F29H85x (C29x) LaunchPad.
Training with integer arithmetic only: INT8 weights, INT32 accumulators and integer gradient updates
(NITI algorithm with adaptive shifts). It uses the 24K-parameter NPU classification model CLS_24k_NPU,
and the example is arc fault classification on the AM13E230X LaunchPad (M33 core).
Aspect |
Float ODT |
Integer ODT |
|---|---|---|
YAML |
|
|
Weights |
float32 |
INT8 |
Gradients |
float32 |
INT32 accumulate, INT8 store |
C library |
|
|
Example config |
|
|
8.12.2. Configuration
Both flows are switched on from the training section of the config YAML:
training:
quantization: 2 # required for integer ODT
ondevice_training: true # enable the ODT export pipeline
trainable_layers_from_last: 3 # number of trailing layers that are trainable
export_samples_per_class: '[10,5,5]' # [train, val, test] samples per class exported as C arrays
For the real values for each flow, use the example configs above and the guides:
Float ODT: Running ModelZoo for On-Device Training
Integer ODT: Running ModelMaker for Integer On-Device Training
Run the example with the usual script, for example
./run_tinyml_modelzoo.sh examples/dc_arc_fault/config_dsi_ondevice_learning.yaml (see Quickstart).
The run exports the model, the trainable model configuration and a small data set as C files, which you copy into the
device SDK example project in Code Composer Studio. The guides describe each file.
Note
The tinyml-tensorlab ModelMaker environment mentioned in a few places of the integer ODT guide is the 1.4.0 way
to run; in 1.5.0 you run ModelZoo as described in Installation.
8.12.3. Documentation
Float on-device training
- 8.12.3.1. On-Device Training Documentation
- 8.12.3.2. On-Device Training — Overview
- 8.12.3.3. Running ModelZoo for On-Device Training
- 8.12.3.4. Generated Artifacts Overview
- 8.12.3.5. Trainable Model Configuration Files
- 8.12.3.6. On-Device Training Data
- 8.12.3.7. On-Device Training Library
- 8.12.3.8. Anomaly Detection On-Device Training Library
- 8.12.3.9. Fan Blade Anomaly Detection — On-Device Training Example
- 8.12.3.10. On-Device Training — FAQ & Troubleshooting
Integer on-device training
- 8.12.3.11. Integer On-Device Training Documentation
- 8.12.3.12. Integer On-Device Training: Overview
- 8.12.3.13. Running ModelMaker for Integer On-Device Training
- 8.12.3.14. Generated Artifacts Overview
- 8.12.3.15. Integer Model Configuration: Deep Dive
- 8.12.3.16. Training Data
- 8.12.3.17. Integer ODL Library: API Reference