Source-linked AI summary
Few-Shot Prototype Head Adaptation for On-Device ECG Personalization on PSoC~6
Guilherme Silva, Pedro Silva, Gladston Moreira, Eduardo Luz
TL;DR
Patient-specific ECG variation and scarce arrhythmia labels make on-device personalization difficult under microcontroller constraints. The paper freezes a compact CNN and adapts class prototypes, improving inter-patient macro-F1 over the baseline and linear SGD while demonstrating on-device replay fidelity. A normal-only variant also yields a reported personalization gain without arrhythmia annotations.
Problem
Patient-specific ECG morphology can degrade inter-patient arrhythmia classification, while on-device adaptation faces costly backpropagation and limited availability of labeled arrhythmic beats.
Source: §1 · p. 1Method
The method freezes an offline-trained compact 1-D CNN and adapts patient-specific class means in its 32-dimensional embedding space on a PSoC 6.
Source: §1 · p. 2Results
Prototype adaptation raises inter-patient macro-F1 from 0.635/0.639/0.646 to 0.731/0.771/0.797 at 1/5/10-shot, outperforming linear SGD at every count; replay matches host macro-F1 at 0.798.
Source: §4 · p. 4Takeaways & Limitations
The normal-only variant yields a consistent +0.05 macro-F1 without arrhythmia annotations, and the measured embedded path uses 11.39 ms per beat, 5.2 KB flash, and 22.2 KB SRAM.
Source: §1 · p. 2, §5 · p. 6The evaluation assumes upstream beat segmentation and R-peak detection, uses binary rather than full AAMI five-class classification, and its aggregate replay covers a flash-capped subset of 18 one-shot episodes.
Source: §5 · p. 6
Abstract
from arXiv · showhide
Wearable and bedside electrocardiogram (ECG) monitors must adapt to patient-specific morphology to maintain arrhythmia detection accuracy across users, yet personalization is typically performed offline and cannot account for individual physiology, electrode placement, or recording drift. On-device adaptation by backpropagation is expensive for microcontroller-class medical devices because it requires an optimizer state, repeated backward passes through convolutional layers, and labeled arrhythmic beats that may not be available at deployment time. This letter proposes prototype-only head adaptation as a compact personalization primitive for TinyML ECG systems. A one-dimensional convolutional neural network (1-D CNN; 1,314 parameters and 72.6k multiply-accumulate operations per beat) is trained offline on the MIT-BIH Arrhythmia Database under an inter-patient protocol, frozen as a feature extractor, and exported to a PSoC 6 microcontroller. Patient-specific adaptation then reduces to computing closed-form class means in a 32-dimensional embedding space, requiring no convolutional backward pass, no iterative optimization, and only one forward pass per support beat. Prototype adaptation improves inter-patient macro-F1 from 0.635/0.639/0.646 to 0.731/0.771/0.797 at 1/5/10-shot, outperforming linear stochastic-gradient-descent (SGD) head fine-tuning at every shot count for the target tiny backbone. On-device replay over 18 one-shot episodes on a PSoC 6 Cortex-M4F matches the host macro-F1 for the prototype head (0.798), with 11.39 ms per beat, 5.2 KB flash, and 22.2 KB SRAM. A restricted variant that updates only the normal-class prototype from passively buffered sinus beats yields a consistent +0.05 macro-F1 gain, reducing the annotation burden during initial
1 Introduction
Patient-specific ECG variation can degrade inter-patient arrhythmia classification, while on-device personalization is constrained by computation and scarce arrhythmia labels. The letter proposes prototype-only adaptation and evaluates its accuracy, hardware fidelity, and embedded cost.
1 Introduction
- Patient-specific morphology varies with physiology, electrode placement, and recording conditions, and models trained on one population can degrade on unseen individuals under inter-patient evaluation.On-device adaptation also faces costly convolutional backpropagation and a shortage of labeled arrhythmic beats, since normal sinus beats may accumulate first.Source: §1 · pp. 1–2
- The proposal freezes a compact CNN trained offline and adapts patient-specific class means in a 32-dimensional embedding space, using one forward pass per support beat without backward passes or optimizer state.A restricted variant updates only the normal-class prototype from passively buffered sinus beats and inherits the abnormal prototype from offline training.Source: §1 · p. 2
- Prototype adaptation raises inter-patient macro-F1 from 0.635 to 0.731 at 1-shot, from 0.639 to 0.771 at 5-shot, and from 0.646 to 0.797 at 10-shot, outperforming linear SGD at each count.The restricted normal-only variant adds a consistent +0.05 macro-F1 without arrhythmia annotations; on-device replay matches host macro-F1 at 0.798, with 11.39 ms per beat, 5.2 KB flash, and 22.2 KB SRAM.Source: §1 · p. 2
2 Prototype-Only Head Adaptation
A frozen compact CNN supplies embeddings for patient-specific prototype adaptation on the PSoC 6. The method uses closed-form class means and nearest-prototype classification, with a normal-only variant for settings where abnormal labels are unavailable.
2 Prototype-Only Head Adaptation
- The deployment flow trains a compact 1-D CNN offline on DS1, freezes and exports its backbone, then adapts only the classification head using target-patient support beats.The target tiny model has 1,314 parameters and 72,576 MACs per beat; beat segmentation and R-peak detection are assumed to be supplied upstream.Source: §2 · pp. 2–3, Figure 1 · p. 2
- Class prototypes are closed-form means of support-beat embeddings from the frozen backbone, and query beats are scored by negative squared Euclidean distance to each prototype.This requires support-set inference and class-wise additions in 32 dimensions, avoiding optimizer state and convolutional backward propagation.Source: §2 · p. 3
- The closed-form class mean is chosen over richer few-shot estimators because it avoids meta-training, auxiliary networks, or iterative inference while fitting the Cortex-M4F memory and latency constraints.The comparison baseline updates the frozen-backbone model’s final linear layer for 50 SGD steps using cross-entropy.Source: §2 · p. 3
- The restricted variant updates only the normal-class prototype from buffered sinus beats and inherits the abnormal prototype from DS1, allowing calibration before arrhythmic beats are available.The per-class update structure supports this normal-only setting when abnormal events are rare and annotation-dependent calibration is impractical.Source: §2 · p. 3
3 Protocol and PSoC 6 Implementation
The evaluation uses held-out DS2 records under a binary inter-patient protocol, with few-shot support examples per class. PSoC 6 replay profiling measures the deployable model path separately from the full firmware image.
3 Protocol and PSoC 6 Implementation
- The benchmark uses MIT-BIH DS1 for training and validation and DS2 for held-out testing, with binary normal-versus-abnormal classification and macro-F1.Few-shot settings use 1, 5, or 10 support examples per class; records lacking at least K + 1 minority-class beats are excluded for that shot count.Source: §3 · p. 3
- Firmware replay targets a PSoC 6 BLE board with a Cortex-M4F application core, profiling the frozen backbone and both head rules using DWT cycle counts at a measured 100 MHz clock.The board has 1 MB Flash and 288 KB SRAM; replay metrics are logged over UART.Source: §3 · p. 3
- The reported memory budget covers the model-centric deployable adaptation path, separately from the full replay firmware image containing board support, profiling, runtime, and replay assets.The table caption states that weights are stored as float32 constants in flash.Source: §3 · p. 3, Table 1 · p. 4
4 Results
On eligible DS2 patients, prototype adaptation improves macro-F1 over pre-adaptation and linear SGD on the tiny backbone; further evaluations examine normal-only support, calibration time, and backbone scaling.
4 Results
- Prototype adaptation raises macro-F1 from 0.635 to 0.731 at 1-shot, from 0.639 to 0.771 at 5-shot, and from 0.646 to 0.797 at 10-shot, outperforming linear SGD.These comparisons use the full eligible DS2 protocol for the target tiny backbone.Source: §4 · p. 4, Table 2 · p. 4
- At 1-shot, prototype calibration is 17× faster than SGD in the host reference (216 ms vs. 3690 ms); the rising pre-adaptation curve reflects eligibility filtering, not adaptation.The filter progressively removes harder, more class-imbalanced records as K increases.Source: §4 · p. 4, Figure 2 · p. 5
- Normal-only support gains 0.045–0.050 macro-F1 across shot counts without target-patient arrhythmia annotations, but remains weaker than full prototype adaptation.At 10-shot, normal-only reaches 0.699 macro-F1, versus 0.649 before adaptation and 0.797 with full prototype support.Source: §4 · p. 4, Figure 3 · p. 5
- A 10-shot prototype calibration takes 228.04 ms and the corresponding SGD calibration 244.66 ms, both within the 400 ms RR interval.On the PSoC 6 CM4 at 100 MHz, both methods scale linearly with K because each uses one backbone forward pass per support beat.Source: §4 · pp. 4–5, Figure 4 · p. 6
- The prototype advantage is capacity-dependent: larger backbones narrow or reverse it at low shot counts.The scaling study evaluates DS2 F1 before personalization and reports the best retuned head-adaptation method in few-shot columns.Source: §4 · p. 5, Table 3 · p. 5
- The tiny backbone’s compressed 32-dimensional embedding has tightly bounded intra-class variance, making the closed-form mean a stable class representative.Larger backbones produce richer manifolds where the mean is less faithful, shifting the low-shot advantage toward SGD.Source: §4 · p. 6
5 Discussion, Limitations, and Conclusion
Prototype-only adaptation is especially well matched to the target tiny model and MCU deployment path. Its normal-only variant may reduce the need for arrhythmia annotations during initial deployment.
Discussion
- Closed-form, per-class prototype updates avoid convolutional backpropagation and let calibration begin with passively buffered normal beats alone.Unlike gradient-based head fine-tuning, this variant requires no arrhythmia annotations.Source: §5 · p. 6
- The prototype-versus-SGD advantage is not universal: larger backbones make the ranking shot-dependent, so the claim is specific to the tiny model and MCU path.Source: §5 · p. 6
Limitations
- Evaluation assumes upstream beat segmentation and R-peak detection, uses binary normal-versus-abnormal classification, and includes 18 one-shot on-device replay episodes.The current firmware uses native C float32 kernels rather than int8/TFLM.Source: §5 · p. 6
Conclusion
- The method improves inter-patient macro-F1 for the target tiny model while remaining feasible within a small measured memory and timing footprint.Source: §5 · p. 6
- Future work will integrate upstream beat detection, extend firmware to int8/TFLM, and evaluate the full AAMI five-class setting.Source: §5 · p. 6