Skip to Content
Future InternetFuture Internet
  • Article
  • Open Access

27 May 2026

16 Pages

Memory-Efficient CNN Autoencoder for Real-Time ECG Anomaly Detection on TinyML-Enabled Edge Devices

and
Department of Electronics and Communication Engineering, Alliance School of Applied Engineering, Alliance University, Bangalore 562106, India
*
Author to whom correspondence should be addressed.
This article belongs to the Section Internet of Things

Abstract

Background: Continuously monitoring an ECG signal is vital for patients who cannot articulate their symptoms in a healthcare setting. To identify abnormalities, we introduce a compact one-dimensional convolutional autoencoder (CNN-AE) that can operate at low power consumption on TinyML-enabled edge devices. Methods: Comprising two convolutional layers and a bottleneck fully connected layer, the CNN-AE was trained on normal ECG signals from the Kaggle heartbeat Categorization dataset, derived from the PTB Diagnostic ECG Database. Anomalies were detected by comparing the reconstruction errors with the thresholds. To deploy the model at the edge, symmetric INT8 post-training quantization was applied, and the threshold was fine-tuned with calibration data. Results: The FP32 CNN-AE registered an accuracy of 83.12%, an F1-score of 88.67%, a precision of 85.88%, and a recall of 91.47% on 4046 normal and 10,506 abnormal ECG beats. The INT8 quantized model reduced the memory size by 75% (5.44 KB to 1.36 KB) while maintaining its performance (82.19% accuracy, 83.66% precision, 93.61% recall, and F1-score 88.36%). Inspection of the reconstruction errors and QRS morphology verified that quantization did not compromise the integrity of the ECG signals. Conclusions: The CNN-AE achieves a balance between accuracy, resource efficiency, and memory usage, allowing for real-time abnormality detection in assisted living and low-resource healthcare environments. Its capability on TinyML platforms indicates its role in integration with edge–cloud architectures, cloud-assisted optimization, and secure offloading strategies for scalable healthcare informatics.

1. Introduction

The creation of the Internet of Things (IoT) devices and the emergence of Tiny Machine Learning (TinyML) have led to machine learning implementation on the most limited-resource devices, thus changing the healthcare sector [1]. Among other aspects, real-time monitoring is crucial in cardiology, where uninterrupted electrocardiogram (ECG) monitoring is required for the timely identification of abnormalities. This is even essential for patients with psychophysiological disorders who cannot recognize and/or report their symptoms accurately. Although continuous ECG monitoring ensures the detection of anomalies, it is challenging for edge devices and wearables to support them, because deep learning models including CNNs and LSTMs require high processing capacity and high energy consumption [2]. Hence, their use in the medical setting is limited.
TinyML resolves the challenges of deploying AI models on resource-limited devices while maintaining modularity, rapid deployment, and energy-efficient inference [3]. It enables real-time, on-device data processing with low power consumption making it suitable for wearable healthcare applications. For anomaly detection in large time series datasets, the process includes signal segmentation, feature extraction, model training, and performance evaluation [4]. Autoencoder techniques are efficient for ECG anomaly detection, detecting irregular cardiac patterns with minimal computational overhead [5]. Additionally, INT8 quantization balances detection accuracy and memory efficiency, thereby enhancing the feasibility of deploying deep learning models on TinyML-enabled healthcare platforms.

2. Methods

2.1. System Overview

The proposed system in Figure 1 integrates ECG signal acquisition, preprocessing, anomaly detection, and scalable deployment as elements of one pipeline. The entire process beginning from the raw ECG signals that are filtered and segmented and from which the features are extracted. These processed signals become inputs to a compact one-dimensional CNN-AE model that generates a reconstruction of normal heartbeats, while highlighting anomalous ones by means of threshold-based error comparison. The quantized-to-INT8 model is deployed on TinyML platforms for real-time inference on resource-limited devices. Finally, edge–cloud integration facilitates advanced analytics, secure offloading, and scalable healthcare monitoring in low-resource environments.
Figure 1. System architecture for ECG anomaly detection.

2.2. Dataset and Preprocessing

For this experiment, ECG signals were sourced from the Kaggle ECG Heartbeat Categorization dataset [6], which is based on the PTB Diagnostic ECG Database [7]. This dataset contains preprocessed segmented ECG signals, which makes it highly suited for machine learning purposes. Each instance is a single heartbeat cycle centered at the R-peak and has 187 time-domain samples at a uniform sampling rate. This uniform format maintains the time-dependency aspects while lowering the input to the learning systems.
The dataset consists of 14,552 ECG beats categorized into 4046 normal and 10,506 abnormal ones. A convolutional autoencoder was trained in a one-class unsupervised manner using only normal ECG beats, allowing the model to learn the fundamental characteristics of normal ECG patterns. The test set included both normal and abnormal samples in order to measure the anomaly detection performance under FP32 and INT8 inference scenarios without bias.
Normal beats denote normal sinus rhythms, whereas abnormal beats indicate pathological conditions of the heart. Each heartbeat is represented by a 187-dimensional feature vector that corresponds to ECG amplitudes within the fixed window. Anomalous samples were merely utilized for the test set. In order to lessen the variation in amplitude, each heartbeat was normalized to have zero mean and unit variance before both training and testing, which guaranteed experiment reproducibility and consistency.
Per-Sample Normalization:
x i ~ denotes the input ECG feature, and μ x and σ x denote the mean and standard deviation computed per sample, respectively.
x i ~ = x i − μ x σ x

2.3. Problem Formulation

Algorithm 1 summarizes the entire processing pipeline including preprocessing, autoencoder training, reconstruction-based anomaly detection, INT8 quantization, threshold optimization, and evaluation. Anomaly detection in ECG beats is well suited to an unsupervised autoencoder framework. Abnormal cardiac shapes are diverse, sporadic, and hard to label in imbalanced datasets. By learning normal ECG morphology, anomalies can be detected in real time. Following a one-class reconstruction-based learning framework, the convolutional autoencoder (CNN-AE) was trained only on normal ECG beats to reconstruct healthy electrical patterns. During inference, normal signals are reconstructed accurately, while abnormal signals show larger reconstruction errors. These errors act as anomaly scores, with a fixed threshold separating normal from abnormal beats. In line with the one-class anomaly detection framework, only normal ECG beats are used to train the model. Hence, this approach is ideal for clinical situations where abnormal samples are limited or heterogeneous. Let, x i   ∈ R H denote an input ECG beat represented by H = 187 extracted features, and let f θ   (   . ) represent the trained convolutional autoencoder with parameters θ.
Algorithm 1 Training and Quantized Inference
1: Initialize CNN autoencoder and thresholds.
2: for each ECG beat do
3:   Acquire beat xi from dataset X;
4:   Normalize input (Equation (1));
5:   Reconstruct via autoencoder (Equation (2));
6:   Compute FP32 reconstruction error (Equation (3));
7:   Optimize using MSE loss (Equation (4));
8:   Estimate error distribution;
9:   Classify using FP32 threshold (Equation (6));
10:   Compute INT8 scale factor (Equation (5));
11:   Quantize weights to INT8 (Equation (7));
12:   Perform INT8 inference;
13:   Compute INT8 error (Equation (8));
14:   Sweep INT8 thresholds (Equation (9));
15:   Compute Precision, Recall (Equations (10) and (11));
16:   Compute F1-score (Equation (12));
17:   Select optimal threshold;
18:   Evaluate metrics and memory (Equations (13) and (14));
19: end for
The   reconstructed   output   is   x i ^ = f θ ( x i )

2.4. CNN Autoencoder Architecture and Training Strategy

As illustrated in Figure 2, the proposed lightweight convolutional autoencoder processes a 187 × 1 × 1 ECG feature vector using an encoder–decoder design. The encoder applies convolutional layers with 8 filters and a 3 × 1 kernel (same padding, ReLU activation), followed by a bottleneck layer of size 16. The decoder is a reflection of the encoder through a dense-reshape operation and a transposed convolution with a 3 × 1 kernel for signal reconstruction. The model has 1393 parameters and is trained for 40 epochs using Adam (learning rate 1 × 10−3, batch size 256) with MSE loss. Anomaly detection is carried out via the reconstruction error, with the threshold chosen by a grid search over 2000 values in order to maximize the F1-score. INT8 quantization is performed after training with threshold recalibration. The convolutional autoencoder is trained without supervision on normal ECG samples to learn typical heart activity. Abnormal beats are excluded and saved for testing. This one-class learning strategy is designed for imbalanced biomedical datasets, where anomalies are identified by comparing against the learned normal cardiac patterns. The training reduces the reconstruction error using the mean squared error (MSE) loss, which is optimized through back-propagation. A custom training loop tracks convergence. On a regular CPU, training finishes in 3 to 4 min, highlighting the model’s lightweight efficiency. The reconstruction error for each ECG beat is calculated using the mean squared error (MSE):
e i = 1 H ∑ j = 1 H ( x i , j − x ^ i , j ) 2
Figure 2. CNN autoencoder for anomaly detection.
Loss Function (MSE):
L   =   1 M   ∑ j = 1 M e ( x j )
where M denotes the number of training samples = 128.

2.5. Post-Training INT8 Quantization and Inference Pipeline

The post-training FP32-to-INT8 quantization method enables minimal memory inference of the convolutional neural network (CNN) autoencoder without changing its architecture. As illustrated in Figure 3, the FP32 weights and biases are first extracted, and the scale factor for each layer is derived based on the maximum absolute weight value,
s = m a x   ( | W | ) 127
Figure 3. FP32-to-INT8 post-training quantization and inference pipeline.
The parameters are transformed into INT8 via uniform rounding, and the scaling factors are retained for the inference step. During testing, INT8 operations are dequantized to FP32 approximations, and the reconstruction errors are computed. The classification thresholds are selected by considering the value that leads to the highest F1-score.
The FP32-to-INT8 post-training quantization method avoids retraining, because the learned weight distributions of the trained autoencoder are largely preserved under linear scaling and rounding. In this lightweight architecture, only a minimal parameter range is impacted, resulting in low quantization noise. Moreover, the reconstruction-based anomaly detection method can handle minor numerical perturbations efficiently. Further, threshold recalibration can adapt to changes in the reconstruction error distribution; thus, the quantized model can still provide detection results that are similar to the FP32 baseline with significantly less memory usage, which makes it suitable for TinyML-based ECG applications.

2.6. Experimental Setup, Anomaly Detection, and Thresholding

All experiments were conducted using MATLAB with the Deep Learning Toolbox. The convolutional autoencoder was trained using normal ECG beats in FP32 precision and then quantized to INT8 precision for fixed-point inference comparison. Preprocessing, calculation of the reconstruction error, anomaly detection, and evaluation using accuracy, precision, recall, F1-score, and ROC AUC were conducted. The anomaly detection framework uses reconstruction error analysis. The autoencoder objectives are to form compressed mappings of the physiological electrocardiographic signals and to perform the reconstruction of the normal input signals with minimal error. Following the one-class reconstruction framework presented in Section 2.3, abnormal ECG beats create greater differences between the reconstructed and original signals as the model is exposed only to normal heart patterns during training. In this case, the trained model receives each ECG sample and computes anomaly scores using the mean squared error. In line with the anomaly-scoring strategy explained in Section 2.3, a fixed threshold, τ, which is chosen through the validation procedure aiming to maximize the F1-score, allows the classification of beats: errors higher than τ correspond to abnormal, whereas normal samples are those with the errors lower than τ. This method, therefore, provides stability and mitigates sensitivity to noise and minor reconstruction variations, ensuring consistent and reliable anomaly detection across different inference conditions.
A heartbeat is classified as anomalous if its reconstruction error exceeds a predefined threshold:
Label i = 1 , e i > τ     ( a b n o r m a l ) 0 , e i   ≤ τ    ( n o r m a l )
In this work, the fixed FP32 threshold’s value was set to τ = 3.55993 × 10−4. Fixing a threshold is best practice, as it promotes transparency and reproducibility, thereby enabling independent researchers to replicate the anomaly detection results. The testing protocol separated training and test data, with the autoencoder trained on the normal ECGs. Then, evaluation was performed using a binary test set comprising normal and abnormal instances.

2.7. Model Size and Memory Analysis

We propose a memory-efficient approach to ECG abnormality detection based on a Lightweight convolutional autoencoder and post-training quantization. Most deep learning models are parameter-heavy, but the suggested network is reduced to just 1393 trainable parameters, which saves memory and enables easier code analysis. A floating-point 32 (FP32) parameter requires 32 bits or four bytes; so, the overall model has a memory footprint of approximately 5.44 KB. This architecture is substantially compact than conventional biomedical models. Additionally, after training, INT8 quantization stores each parameter as an 8-bit integer, thus lowering the model size by a factor of 4 to about 1.36 KB from FP32. Quantization does not alter the network architecture or inference process; it only compresses the parameter storage. Apart from saving memory, INT8 precision provides a faster run time by enhancing cache utilization and decreasing the memory bandwidth required. By choosing suitable thresholds, the quantized model produces the same anomaly detection performance as that of FP32. Hence, the memory footprint is significantly reduced with a slight decrement in accuracy. This method shows reproducibility and can be implemented in low-resource settings.

2.8. Quantization Strategy

INT8 quantization is conducted entirely in software without modifying the CNN autoencoder architecture or retraining the model weights. Using MATLAB R2025a’s dlquantizer, calibration was performed with normalized ECG samples to learn activation scaling factors. FP32 outputs are symmetrically quantized to INT8 (−127 to 127) and dequantized when required. This process ensures the consistent evaluation of the reconstruction error.
INT 8   symmetric   quantization ,       ω q = round 127 max ( | ω | )   .   ω
INT 8   reconstruction   error ,       e q ( x ) = 1 N ∑ i = 1 N ( x i − x ^ q , i ) 2
The optimization pipeline functions completely in software and does not require microcontroller or accelerator hardware. Using MATLAB’s deep learning framework, FP32 inference, INT8 approximation, threshold optimization, and metric evaluation on a CPU platform were performed. The model size reduction based on parameter precision was calculated assuming 4 bytes for FP32 and 1 byte for INT8. If dlquantizer is not available, software-based quantization can be used to maintain platform-independent evaluation consistency. Memory savings and performance improvements were achieved by reducing the numerical precision.
The differences in reconstruction errors between FP32 and INT8 show the need for separate threshold optimization. Candidate thresholds were calculated based on precision, recall, and F1-score, and the threshold yielding the best F1-score was selected as optimal.
The optimal INT8 threshold is determined as follows:
τ q =   arg   max τ F 1 ( τ )

3. Results

3.1. FP32 Performance

The FP32 autoencoder provides the technical reference model for ECG anomaly detection using reconstruction error thresholding. As shown in Figure 4, the confusion matrix demonstrates strong classification performance with 9610 true normal instances and few false negatives, confirming that the model effectively learns normal ECG patterns and determines anomalies accurately. The F1-score of 88.67% denotes a balanced trade-off between precision and recall, which is essential in healthcare, where both false negatives and false positives are crucial. Additionally, the reconstruction error histogram in Figure 5 validates this separation, while the ROC curve in Figure 6 achieves an AUC of 0.8327, demonstrating strong discriminative ability. FP32 inference thus presents a stable baseline for evaluating the impact of INT8 quantization.
Figure 4. FP32 confusion matrix.
Figure 5. Reconstruction error histogram.
Figure 6. INT8 confusion matrix.

3.2. INT8 Performance

The INT8 quantized model was evaluated using the FP32 threshold and an INT8-optimized threshold. Direct application of the FP32 threshold results increased false positives due to quantization-induced numerical shifts in the reconstruction error distribution. Nevertheless, threshold recalibration minimized this effect, as indicated in Figure 6 and supported by the reconstruction error distributions. The performance metrics, precision, recall, F1-score, and accuracy, were computed from Equations (10) and (13). After recalibration, the INT8 accuracy was 82.19%, and the F1-score was 88.36%, a less than 2% difference from FP32. The ROC curve, shown in Figure 7, remained largely consistent with the FP32 baseline, thus confirming that anomaly separability was preserved. This demonstrates that INT8 quantization, combined with the appropriate threshold optimization, retains the competitive detection performance while reducing memory and computational requirements.
Precision = T P T P + F P
Recall = T P T P + F N
F 1 = 2   ·   Precision   ·   Recall Precision + Recall
where 2 guarantees the harmonic mean, balancing the precision and recall along with penalizing unbalanced performance.
Accuracy = T P + T N T P + T N + F P + F N
Figure 7. FP32 ROC curve.

3.3. Comparative Analysis

The comparative results highlight the trade-off between accuracy and efficiency. Figure 8 illustrates overlapping ROC curves of the FP32 and INT8 models, with only minor F1 degradation, indicating preserved anomaly separability despite reduced numerical precision. As shown in Figure 9, FP32 offers slightly higher accuracy, but INT8 achieves nearly the same performance with a substantially reduced model size and memory requirement. Figure 10 demonstrates the deployment advantages of INT8 inference including less memory bandwidth, improved cache efficiency, and a lower computational load, all of which are beneficial for resource-constrained TinyML and edge computing environments.
Figure 8. ROC curve comparison.
Figure 9. ECG reconstruction error distribution.
Figure 10. Code memory comparison.
Model Memory Estimation:
Memory = N p  ×  b
where Np denotes the number of parameters, and b denotes bits per parameter (32 for FP32,8 for INT8).
According to Table 1, the transformer-based model has the best performance level; however, it was tested on the MIT-BIH dataset, which is different from the PTB dataset used in this study. The other works cited also refer to different datasets and experiment setups that are different from this study; thus, there should be cautious interpretation. On the other hand, the proposed lightweight CAE still performs at a competitive level, while its model size is decreased to 1.36 KB using INT8 quantization, which shows its suitability to wearable and other edge devices, where memory and computational efficiency are critical.
Table 1. Experimental comparison with existing ECG anomaly detection.

4. Discussion

We focused on detecting anomalies in ECG signals using a convolutional autoencoder (CAE); TinyML-based ECG analysis covers a broader spectrum of lightweight models including compact CNN classifiers, pruned and quantized networks, and edge-optimized frameworks. Previous studies indicate that lightweight CNNs can provide robust healthcare prediction results, though they generally become complex or dependent on labeled data [12]. In addition, pruning and quantization lower the computational cost while keeping the accuracy intact in medical signal processing [13]. The most recent related paper focused on real-time adaptability and deployment-aware optimization [14]. Against this background, the proposed lightweight CAE showed the optimum balance between detection performance and resource efficiency for constrained edge deployment.

4.1. Quantization Strategy and Engineering Insights

The proposed framework is a synthesis of one-class learning, post-training INT8 quantization, and a minimalist architecture. The framework does not explicitly optimize each of these components individually; instead, their integration and the architectural configuration of these elements are designed to meet the constraints of edge deployment, which constitutes the primary distinguishing factor in this context. A one-class autoencoder, a conventional method, is used here to retain the ECG morphology during low-precision inference. Its preservation is determined by several factors: a minimal reconstruction error, high morphological correspondence in waveform features (specifically the QRS complex), closely matched error distributions, and negligible variations in ROC. The measures jointly validate that the clinically relevant signal structures are retained. Unlike supervised methods that require balanced labeled datasets, this approach was trained exclusively on normal ECGs and can determine the fundamental cardiac patterns and detect deviations through the reconstruction error. This confirms the latest studies that revealed that in ECG analysis, generalization is enhanced and this is consistent with the one-class learning strategy of Section 2.3, where models focus on learning the normal patterns rather than trying to understand the various abnormal classes directly [12,15].
One of the most significant engineering choices was the development of the tiny CNN autoencoder (1393 parameters), rather than adopting substantially complex architectures. Larger models can score marginally higher in accuracy, but they require a lot of memory and computing power, which makes them unsuitable for TinyML scenarios. The introduced design is a trade-off between the capacity of a model to represent the data and the feasibility of deployment, while still ensuring that the performance remains at a high level. This conceptual methodology is consistent with the recent lightweight CNN models in healthcare, which emphasize scalability and real-time inference even at the cost of reduced architectural complexity [12].
A principal contribution is the use of symmetric INT8 quantization within a framework of reconstruction-based ECG. Quantization techniques are frequently used, but often, their role in the preservation of biomedical signal integrity is not a focus. ECG signals are highly sensitive to numerical precision, given that they have clinically important features, most notably the QRS complex. Hence, the decision to adapt INT8 precision was well justified by the need to balance the compression effectiveness with the signal accuracy. If the bit resolution is insufficient, high-frequency components may be distorted; on the other hand, formats with larger bits do not provide significant memory savings. The previous results have shown that numerical precision has a direct impact on the recognition accuracy in convolutional models, emphasizing the importance of selecting the appropriate quantization level [16].
The experiment results show that, using the suggested quantization approach, the model size can be reduced four times (from 5.44 KB to 1.36 KB) without damaging the performance, whereas the F1-score drops by less than 2%. Crucially, the reconstruction experiments reveal that the ECG morphology stays intact, with differences limited to a few regions of high energy that appear slightly smoother. Therefore, it can be inferred that INT8 quantization, if performed correctly, does not cause a significant loss of clinically relevant features. Unlike general quantization papers, this work shows the effect of the precision reduction on the ECG waveform reconstruction, thus making a practical contribution by indicating its healthcare applicability.
As described in the reconstruction-based framework of Section 2.3, that are trained with normal ECG signals spot abnormal signals by their failure to reconstruct the signal, i.e., at the deviation level of the reconstruction error [17]. The level of detection is often a threshold derived from the distribution of reconstruction losses [18]. As presented in Section 2.3, a shift in this error distribution was introduced by INT8 quantization, thus changing τ to τq without the need for re-calibration; the overlap of normal and abnormal errors would increase, and the detection performance would be degraded. This behavior is unchanged with distribution-sensitive anomaly detection frameworks, where separation under transformation is essential for continuity.

4.2. System-Level Efficiency and IoT Deployment Implications

Apart from model-level optimization, the framework also targets system-level efficiency, which is a significant factor in actual healthcare deployment. In the case of embedded systems, the performance is often limited not by the processing power but by the memory access and data movement. By making a fourfold reduction in parameter size, the INT8 model drastically reduces the need for bandwidth for memory and will, therefore, be able to better utilize the cache and run faster. This is in line with the recent research pointing out that an efficient selection of models and their continuous optimization are of key importance for the sustainable TinyML deployments [14].
The lightweight design also makes it possible to run inference locally on the device. Thus, one does not need to continuously send data to the cloud. Apart from reducing the latency and increasing the reliability, this will also enhance data privacy and security, which are important factors for medical applications [19]. The latest research on edge intelligence clearly indicates that localized processing can improve system responsiveness and reduce the communication overhead [20,21]. Thus, the model proposed in this research is not only highly efficient from a computational point of view but it is also ready for deployment in the wearable and assisted-care environments.
Even though direct comparisons are limited due to differences in datasets and evaluation protocols, the proposed framework balances detection accuracy, memory efficiency, and simplicity of deployment, which are essential for resource-constrained IoT environments. This indicates an important insight: progress in healthcare AI is not only a matter of new algorithms; it also depends on thoughtful engineering choices that make them highly fit for deployment environments. The coupling of one-class learning, quantization, and compact architecture leads to a healthcare real-time monitoring system that is both functional and capable.
Aside from reducing the demand for memory, performing INT8 quantization also makes it possible to perform integer-only inference by completely removing floating-point operations, which, in turn, makes it possible to run a model even on cheap microcontrollers that do not have dedicated floating-point units [15,22]. This not only reduces the computation and power consumption, but the efficiency factors shift from floating-point hardware and memory, as integer operations and data movement between memory and processing units take time [1,3].
Earlier work focused on the same topic also emphasizes that mixed-precision and quantized inference can preserve accuracy while simultaneously increasing throughput and minimizing power consumption in AI edge applications [21,23]. The new lightweight model, with only 1393 parameters, is an optimal fit for 16- and 32-bit MCU platforms, where integer operations are the most efficiently supported ones, even though 8-bit MCUs may cause a certain increase in latency due to their limited processing capability. A 4× reduction in the model size will have a direct impact on the energy consumption during continuous inference by decreasing the memory bandwidth requirements. Efficient reduction in the use of costly resources is essential for real-time ECG monitoring in IoT environments, which must function under severe limitations in power consumption, latency, and hardware cost [2,14].

4.3. One-Class vs. Two-Class Training and Clinical Error Analysis

Although the reconstruction error is a classic approach to anomaly detection, one-class (unsupervised) training is a matter of engineering choice, rather than a limitation. Consistent with the rationale presented in Section 2.3, abnormal ECG samples with labels are typically heterogeneous and severely imbalanced. This could lead to the bias of supervised models towards the major classes and a decrease in their ability to generalize to arrhythmias not previously seen. Existing works have demonstrated that autoencoder-based one-class models not only can closely model the normal ECG morphology but also can detect a wide range of anomalies as deviations without the need for labeling every abnormal sample exhaustively [12,15].
On the other hand, a two-class training approach might be capable of enhancing the separation of decision boundaries and lessening the overlap between normal and abnormal samples; however, these methods typically need larger labeled datasets and highly complex models. In this work, misclassifications occur mostly near the decision threshold, where the reconstruction errors of borderline abnormal beats intersect with normal variability. This represents trade-off between one-class and two-class: the former emphasizes generalization, while the latter aims at margin maximization. Adding supervised fine-tuning or hybrid models could help reduce those errors even further.
Error tolerance is a vital issue from a clinician’s point of view. False negatives (i.e., missing anomalies) are more dangerous than false positives. Therefore, the proposed framework functions primarily as a screening or early-warning tool, in which one can accept the occasional false positive, but the detection sensitivity must be high. Similar deployment practices can be found in edge-based ECG monitoring systems, where lightweight models are given the task of detection rather than perfect classification [14,24]. Further work will examine hybrid methods that merge reconstruction-based detection with lightweight classifiers in order to decrease the errors further while retaining the feature of deployability.

4.4. Limitations

Some limitations should be considered. First, the assessment was simulation-based. The actual performance will change from one hardware platform to another, which is the case of the performance–precision trade-off that has been well documented in other studies [15]. Furthermore, dependence on the PTB dataset limits generalization; hence, evaluation across different datasets, demographics, hardware, and clinical settings is required to ensure the reliability of the results [24,25]. Finally, the model successfully recognizes when an anomaly occurs but does not classify specific arrhythmia types, which is normally a requirement in the case of advanced diagnostics.

5. Conclusions

In this article, we introduced a lightweight convolutional autoencoder-based framework for ECG anomaly detection, which was specifically tailored to be run on limited-resource edge devices. By employing reconstruction-error-based inference, the system effectively distinguished between normal and abnormal cardiac patterns without requiring complex supervised classification. In the experiments, the ECG Heartbeat Categorization Dataset (derived from the PTB Diagnostic ECG Database) demonstrated that the FP32 model achieved robust detection performance, while INT8 quantization was used for testing, and the FP32 model achieved 83.12% accuracy, 85.88% precision, 91.47% recall, and an F1-score of 88.67%; post-training INT8 quantization allowed the model size to be reduced by about four times with minimal performance degradation (F1-score 88.36%). Thus, the evidence demonstrates that it is possible to have an efficient diagnostic tool even when the memory and precision levels are limited. These reported comparisons are meant to give a contextual reference rather than direct benchmarking as there are variations in datasets and tasks across studies. Moreover, the quantized model can run on software-level INT8 operations and fixed-point thresholding, without requiring any specialized hardware accelerators, and is completely compatible with TinyML platforms.
Continuous ECG monitoring is essential for patients who cannot describe their symptoms, especially in healthcare systems with limited resources. The CNN autoencoder method presented in this study is fit for assisted living and home healthcare settings, as it supports low power use, minimized memory constraints, and high-throughput, real-time execution. Analysis of the reconstruction error, along with the statistical comparison of the FP32 and INT8 models, verifies that clinically significant ECG shapes are retained after quantization, while the differences in error distributions are minimal. This trade-off was deliberate in order to increase the flexibility without compromising the accuracy of diagnosis.
Further research will be directed at demonstrating the effectiveness of the suggested model in real-life situations of deployment, including hardware-in-the-loop testing and executing the model on low-power microcontrollers to evaluate the latency, memory footprint, and power consumption. Collaborating with edge–cloud setups will be developed, in which small-scale reasoning is carried out on the device while sophisticated analytics are performed in the cloud. Theoretical and practical energy profiling will also be undertaken to measure efficiency recuperation. Although state-of-the-art computing paradigms including cloud-based optimization, could potentially lead to additional improvements, their suitability for real-time ECG monitoring is still a topic for discovery, encompassing emerging paradigms including quantum-assisted optimization.

Author Contributions

Conceptualization, K.P.S. and R.M.G.; methodology, K.P.S.; software, K.P.S.; validation, K.P.S.; formal analysis, K.P.S.; investigation, K.P.S.; resources, K.P.S.; writing—original draft preparation, K.P.S.; writing—review and editing, K.P.S.; visualization, K.P.S. and R.M.G.; supervision, R.M.G. All authors have read and agreed to the published version of the manuscript.

Funding

This research received no external funding.

Data Availability Statement

The ECG data used in this study were obtained from the publicly available ECG Heartbeat Categorization Dataset on Kaggle, which includes data derived from the PTB Diagnostic ECG Database. The dataset is available at https://www.kaggle.com/datasets/shayanfazeli/heartbeat (accessed on 10 September 2025). No new data were created or analyzed in this study.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Abadade, Y.; Temouden, A.; Bamoumen, H.; Benamar, N.; Chtouki, Y.; Hafid, A.S. A comprehensive survey on TinyML. IEEE Access 2023, 11, 96892–96922. [Google Scholar] [CrossRef] [Scilit]
  2. Hizem, M.; Bousbia, L.; Ben Dhiab, Y.; Ould-Elhassen Aoueileyine, M.; Bouallegue, R. Reliable ECG anomaly detection on edge devices for Internet of Medical Things applications. Sensors 2025, 25, 2496. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  3. Keivanimehr, A.R.; Akbari, M. TinyML and edge intelligence applications in cardiovascular disease: A survey. Comput. Biol. Med. 2025, 186, 109653. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  4. Revin, I.; Potemkin, V.A.; Balabanov, N.R.; Nikitin, N.O. Automated machine learning approach for time series classification pipelines using evolutionary optimization. Knowl. Based Syst. 2023, 268, 110483. [Google Scholar] [CrossRef] [Scilit]
  5. Wu, L.; Li, T.; Ali, M.K.M.; Ni, C.; Tian, Y.; Zhou, X. Adaptive Toeplitz convolution-enhanced classifier for anomaly detection in ECG big data. J. Big Data 2025, 12, 56. [Google Scholar] [CrossRef] [Scilit]
  6. De Chazal, P. ECG Heartbeat Categorization Dataset. Kaggle [Internet]. 2017. Available online: https://www.kaggle.com/datasets/shayanfazeli/heartbeat (accessed on 17 February 2026).
  7. Goldberger, A.L.; Amaral, L.A.N.; Glass, L.; Stanley, H.E. PhysioBank, PhysioToolkit, PhysioNet contributors. PhysioBank, PhysioToolkit, and PhysioNet: Components of a new research resource for complex physiologic signals. Circulation 2000, 101, e215–e220. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  8. Alamr, A.; Artoli, A. Unsupervised transformer-based anomaly detection in ECG signals. Algorithms 2023, 16, 152. [Google Scholar] [CrossRef] [Scilit]
  9. Shan, L.; Li, Y.; Jiang, H.; Zhou, P.; Niu, J.; Liu, R.; Wei, Y.; Peng, J.; Yu, H.; Sha, X.; et al. Abnormal ECG detection based on an adversarial autoencoder. Front. Physiol. 2022, 13, 961724. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  10. Ran, S.; Yang, X.; Liu, M.; Zhang, Y.; Cheng, C.; Zhu, H.; Yuan, Y. Homecare-oriented ECG diagnosis with large-scale deep neural network for continuous monitoring on embedded devices. IEEE Trans. Instrum. Meas. 2022, 71, 3147328. [Google Scholar] [CrossRef] [Scilit]
  11. Kaushik, P.; Sharma, P. Cutting-edge convolutional neural network autoencoders for anomaly detection in ECG signals: Advancements in early cardiac diagnosis. In Proceedings of the 2024 International Conference on Cybernation and Computation (CYBERCOM), Dehradun, India, 15–16 November 2024; pp. 340–344. [Google Scholar] [CrossRef] [Scilit]
  12. Singh, M.P.; Singh, J.; Ravi, V.; Gupta, A.D.; Alahmadi, T.J.; Shivahare, B.D.; Diwakar, M.; Tayal, M.; Singh, P. A healthcare system employing lightweight CNN for disease prediction with artificial intelligence. Open Public Health J. 2024, 17, e18749445302023. [Google Scholar] [CrossRef] [Scilit]
  13. Too, E.C.; Mwathi, D.G.; Gitonga, L.K.; Kinyori, S.; Mwaka, P. A pruned and quantized convolution neural network for enhancing tuberculosis detection using chest X-ray images. In Signals and Communication Technology; Springer: Berlin/Heidelberg, Germany, 2025; pp. 33–68. [Google Scholar] [CrossRef] [Scilit]
  14. Arratia, B.; Rosas, E.; Prades, J.; Peña-Haro, S.; Cecilia, J.M.; Manzoni, P. Towards efficient stream monitoring: A systematic approach for model selection and continuous improvement in Tiny Machine Learning applications. Eng. Appl. Artif. Intell. 2025, 162, 112415. [Google Scholar] [CrossRef] [Scilit]
  15. Kimhi, M.; Rozen, T.; Mendelson, A.; Baskin, C. AMED: Automatic mixed-precision quantization for edge devices. Mathematics 2024, 12, 1810. [Google Scholar] [CrossRef] [Scilit]
  16. Manganini, C.; Primiero, G. Defining formal validity criteria for machine learning models. In Synthese Library; Springer: Berlin/Heidelberg, Germany, 2026; Volume 527, pp. 295–312. [Google Scholar] [CrossRef] [Scilit]
  17. Daci, R.; Taleb-Ahmed, A.; Patrono, L.; Distante, C. Sparse Temporal AutoEncoder for ECG Anomaly Detection. Sensors 2026, 26, 1589. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  18. Roy, M.; Majumder, S.; Halder, A.; Biswas, U. ECG-NET: A deep LSTM autoencoder for detecting anomalous ECG. Eng. Appl. Artif. Intell. 2023, 124, 106484. [Google Scholar] [CrossRef] [Scilit]
  19. Maoui, M.; Benaboud, R. Perspectives of TinyML-Based Self-management in IoT-Based Systems. In Proceedings of the 13th International Conference on Information Systems and Advanced Technologies (ICISAT 2023); Springer: Cham, Switzerland, 2024; pp. 1–12. [Google Scholar] [CrossRef] [Scilit]
  20. Malche, T.; Tharewal, S.; Maheshwary, P. A TinyML approach to real-time snoring detection in resource-constrained wearable devices. Eng. Proc. 2024, 82, 55. [Google Scholar] [CrossRef] [Scilit]
  21. Schizas, N.; Karras, A.; Karras, C.; Sioutas, S. TinyML for ultra-low power AI and large-scale IoT deployments: A systematic review. Future Internet 2022, 14, 363. [Google Scholar] [CrossRef] [Scilit]
  22. Nakahara, Y.; Kiyama, M.; Amagasaki, M.; Iida, M. Relationship between recognition accuracy and numerical precision in convolutional neural network models. IEICE Trans. Inf. Syst. 2020, 103, 2528–2529. [Google Scholar] [CrossRef] [Scilit]
  23. Trigkas, A.; Piromalis, D.; Papageorgas, P. Edge intelligence in urban landscapes: Reviewing TinyML applications for connected and sustainable smart cities. Electronics 2025, 14, 2890. [Google Scholar] [CrossRef] [Scilit]
  24. Avetisyan, A.; Tigranyan, S.; Asatryan, A.; Mashkova, O.; Skorik, S.; Ananev, V.; Markin, Y. Deep neural networks generalization and fine-tuning for 12-lead ECG classification. Biomed. Signal Process. Control 2024, 93, 106160. [Google Scholar] [CrossRef] [Scilit]
  25. Deng, J.; Elghobashy, M.E.; Zang, K.; Patel, S.K.; Guo, E.; Heybati, K. So you’ve got a high AUC, now what? An overview of important considerations when bringing machine-learning models from computer to bedside. Med. Decis. Mak. 2025, 45, 640–653. [Google Scholar] [CrossRef] [Scilit] [PubMed]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.