Skip to Content
MachinesMachines
  • Article
  • Open Access

2 December 2026

16 Pages

A Hybrid CNN-BiGRU-Attention Network for Multi-Class Spark-State Classification in Electrical Discharge Machining

,
,
and
Chair of Manufacturing Technology with Focus Machining, Faculty of Mechanical Engineering, Otto von Guericke University Magdeburg, Universitätsplatz 2, 39106 Magdeburg, Germany
*
Author to whom correspondence should be addressed.
Machines2026, 14(12), 1435;https://doi.org/10.3390/machines14121435 
(registering DOI)
This article belongs to the Section Advanced Manufacturing

Abstract

Electrical discharge machining (EDM) is a highly nonlinear manufacturing process in which stable machining performance depends on regulating transient spark-gap conditions. Traditional rule-based discriminators and offline static machine learning models struggle to capture stochastic gap dynamics, while recent unsupervised pulse diagnostics rely on post hoc peak segmentation unsuitable for online operation. To bridge this gap, this study introduces a causal, end-to-end deep learning framework that transfers offline unsupervised pulse diagnostics into a real-time sliding-window spark-state classifier deployable on embedded Edge AI hardware. A lightweight hybrid CNN-BiGRU-Attention network with a multi-modal conditioning interface processes raw transient gap voltage and discharge current waveforms to categorize the terminal state of a 1024-sample observation window into five physically grounded stability classes ( Y 1 to Y 5 ). Evaluated across an experimental die-sinking EDM database comprising 8264 valid recording blocks (350,867 detected discharges and 234.37 million causal sliding windows), the proposed classifier achieves 90.27% five-seed mean accuracy (90.39% single-seed accuracy and 0.9040 macro F1-score on a balanced independent test set of 49,920 windows; 94.82% accuracy and 0.9627 weighted F1-score on the naturally imbalanced 2.21-million-window test stream) within the investigated single-machine configuration, significantly outperforming rule-based threshold discriminators. Exported via ONNX and TensorRT to an embedded NVIDIA Jetson Orin NX module, the classifier achieves a batch-1 inference latency of 1.28 ms on the CPU (FP32, numerically verified to have a maximum logit deviation of 6.79 × 10 − 6 ) and 1.29 ms via TensorRT (FP16), establishing a low-latency state-estimation module designed to support future closed-loop adaptive gap control.

1. Introduction

As a key manufacturing technology, die-sinking electrical discharge machining (EDM) enables the shaping of high-performance materials such as hardened steels, superalloys [1], titanium alloys [2], and metal matrix composites [3] independently of their hardness or mechanical strength. Nevertheless, maintaining consistent surface integrity and machining efficiency remains challenging due to the intricate coupling of machine configurations and transient, spatio-temporal discharge phenomena, especially when fabricating complex geometries or operating in mass production environments [2,4,5]. To address this complexity, in situ process monitoring and control (PMC) [6] and data-driven pulse diagnostics [7] have emerged as essential approaches for stabilizing discharge sequences and securing component quality.
While numerous studies have demonstrated the potential of artificial intelligence for modeling and optimizing EDM processes [5,8,9], existing approaches predominantly rely on static input–output mappings or offline parameter selection strategies [4,10]. Conversely, recent unsupervised clustering frameworks [7] provide objective offline diagnostics but require post hoc peak segmentation that precludes direct real-time execution. Traditional machine learning algorithms further depend on hand-crafted features and struggle to process raw, high-frequency physical waveforms directly [11,12]. Shifting toward deep learning enables automatic extraction of hierarchical temporal features directly from raw sensor streams, which can be paired with static operational conditioning to support online process monitoring across varying generator settings [6].
To address these challenges, this paper introduces a lightweight neural network framework that transfers offline unsupervised pulse diagnostics [7] into a causal, end-to-end sliding-window spark-state classifier verified for near-millisecond Edge AI deployment, providing a low-latency state-estimation module intended to support future closed-loop adaptive EDM gap regulation. Specifically, the main contributions are threefold: (i) formulating a causal five-class terminal-window spark-state classification task grounded in unsupervised pulse diagnostics [7]; (ii) designing and benchmarking a lightweight hybrid CNN-BiGRU-Attention architecture with a multi-modal conditioning interface against rule-based thresholds, progressive ablations, and an external temporal convolutional network (TCN) across both balanced and naturally imbalanced test streams within the investigated die-sinking EDM configuration; and (iii) verifying numerical deployment parity and near-millisecond inference latency via ONNX and TensorRT on an embedded EdgeAI module. Section 2 reviews the state of the art; Section 3 outlines the conceptual closed-loop architecture and classification methodology; Section 4 details the network design and Edge AI deployment; Section 5 describes the experimental setup and labeling pipeline; Section 6 presents the empirical evaluations, ablations, and limitations; and Section 7 concludes this study.

2. State of the Art

This section reviews the progression from analytical EDM models and static machine learning to unsupervised pulse diagnostics and deep learning frameworks for real-time process monitoring.

2.1. Analytical and Empirical Models of EDM Phenomena

Early EDM research established analytical single-spark models of plasma channel expansion and thermal conduction [13,14]. However, because continuous EDM is highly stochastic and governed by dielectric variations, debris accumulation, and gas bubble dynamics, deterministic models struggle to generalize [15]. Semi-empirical regression models linking generator settings to macroscopic material removal rate (MRR) and surface roughness ( R a ) provide offline baselines but cannot capture transient, spatio-temporal fluctuations that must be captured for real-time control.

2.2. Machine Learning for Static Parameter Mapping

Shallow artificial neural networks (ANNs), support vector regression, and hybrid ANN–genetic algorithm models improved nonlinear mapping from static generator settings (peak current, pulse-on/off time) to macroscopic outputs [8,9,10,16,17]. Because these methods ignore real-time gap waveforms, they remain confined to offline parameter selection and cannot detect or mitigate transient instabilities such as arcing chains or persistent short circuits during machining [4,12].

2.3. Unsupervised Pulse Classification and Diagnostics

Active monitoring shifted toward classifying individual discharge pulses from high-frequency voltage and current waveforms. Classical threshold-based discriminators separate normal sparks from arcs and short circuits [18], yet rigid thresholds are sensitive to noise and changing technology settings [19]. Unsupervised clustering (e.g., PCA and K-means) avoids manual annotation [7]. Notably, Damm et al. [7] clustered segmented discharge features into four active discharge regimes (Type 1: normal discharges; Type 2: short circuits; Type 3: arcing discharges; Type 4: delayed ignitions), complemented in continuous monitoring by the non-discharge baseline interval, and linked classified pulse ratios directly to MRR and tool electrode wear (TWR) [7,20]. However, because full clustering pipelines require post hoc peak segmentation and batch evaluation, they serve as offline diagnostic and annotation tools rather than real-time online classifiers.

2.4. Deep Learning and Multi-Modal Data Streams

Deep learning architectures such as CNNs and RNNs learn hierarchical temporal features directly from high-frequency sensor streams without manual feature engineering [21]. Prior works demonstrated deep neural networks for unexpected event prediction in wire EDM [22], hybrid CNN-GRU models for transient spark analysis [23], and LSTM networks for continuous electrode degradation tracking [24]. Because EDM dynamics also depend on operator-configured baseline technology settings [6,11], recent multi-modal frameworks combine tabular machine parameters with raw sequential waveforms using parallel branches (e.g., dense layers fused with TCNs or GRUs) [25,26].

2.5. Identified Research Gap and Scope of the Present Work

Table 1 contrasts representative data-driven EDM monitoring studies with the present work. Most existing deep architectures operate as offline or open-loop advisors without verified embedded inference latency, whereas unsupervised diagnostics [7] depend on post hoc peak segmentation. Furthermore, two temporal scales must be distinguished in EDM: individual discharges evolve on a microsecond scale (1 μs to 100 μs), requiring megahertz-scale acquisition, whereas detrimental instabilities—such as persistent arcing chains and short-circuit clusters—develop over consecutive pulses on a millisecond scale. Active gap stabilization via high-bandwidth piezo actuators therefore requires state-estimation updates near 1 m s (≈ 1 kHz ).
Table 1. Comparison of representative data-driven EDM monitoring and classification studies with the present work across input modality, target definition, windowing/latency, and control mode.
In direct contrast to the work of Damm et al. [7], which serves solely as an offline unsupervised pulse-annotation foundation, the present study trains an end-to-end supervised classifier operating directly on raw sliding-window waveforms without prior peak segmentation and validates its near-millisecond execution on embedded hardware. Architecturally, omitting recurrent sequence context weakens tracking of multi-pulse temporal evolution, omitting temporal attention dilutes short-lived terminal breakdown edges across compressed feature steps, and omitting static parameter conditioning removes the interface required when scaling across heterogeneous generator configurations.

3. Proposed System Architecture and Classification Methodology

To motivate the real-time latency requirements of the classifier, Figure 1 illustrates the overarching conceptual closed-loop system architecture comprising a physical EDM machine, a high-speed signal acquisition interface, and the EdgeAI module. It is emphasized that only the signal acquisition, monitoring, and AI spark-state classification pipeline are experimentally implemented and benchmarked in this study, whereas closed-loop predictive control and physical piezo actuation remain prospective development stages.
Figure 1. Schematic overview of the proposed system architecture, including the sensor–actuator configuration, data acquisition system, and the EdgeAI module. Sensors measure the discharge current I ( t ) , the gap voltage U ( t ) , and the position z ( t ) . In the present study, the high-speed data acquisition, monitoring, and AI spark-state classification layers are experimentally implemented and validated, whereas the predictive control block and the piezo actuator applying the micro-displacement change Δ s ( t ) represent the conceptual closed-loop actuation interface for future work.

3.1. Closed-Loop System Architecture and the EdgeAI Module

The EdgeAI module is organized into three functional layers: monitoring, artificial intelligence (AI), and predictive control. The monitoring layer acquires and buffers incoming waveforms and passes them to the AI layer, where the trained neural network classifies the terminal gap state of each sliding observation window into five discrete classes ( Y 1 to Y 5 : non-discharge baseline Y 1 and the four active discharge regimes Y 2 to Y 5  [7]). Downstream, the conceptual predictive control layer is intended to translate the estimated class probabilities into micro-positioning commands bypassing slow CNC servo feeds.

3.2. Sensor Integration and Mechanical Configuration

Three time-dependent variables are tracked in the mechanical setup: discharge current I ( t ) , gap voltage U ( t ) , and axial position z ( t ) . While z ( t ) supports macroscopic feed tracking, the high-frequency classifier developed here uses exclusively U ( t ) and I ( t ) as dynamic waveform inputs. The workpiece is submerged in dielectric fluid inside an electrically isolated clamping assembly, with low-impedance power delivery through dedicated electrode and workpiece contacts to minimize parasitic inductance and signal distortion (detailed in [7]).

3.3. Conceptual Predictive Actuation and Gap Stabilization Interface

In the prospective closed-loop stage, a high-bandwidth piezo actuator mounted beneath the workpiece clamping column provides sub-millisecond micro-displacements Δ s ( t ) to dynamically regulate the spark gap s ( t ) , complementing the slow, coarse CNC servo axis. To formalize how the classifier’s five-class softmax probability vector p ( t ) = [ P ( Y 1 , t ) , … , P ( Y 5 , t ) ] ⊤ can drive prospective gap regulation without reacting to isolated single-window noise, a conceptual weighted-risk control law over a moving-average-smoothed probability estimate p ¯ ( t ) is formulated as
Δ s ( t ) = clip K p ∑ k = 1 5 w k P ¯ ( Y k , t ) , − Δ s max , Δ s max ,
where K p > 0 denotes the proportional displacement gain, Δ s max enforces actuator saturation and slew-rate safety limits, and the physical state weights encode gap-correction polarity: w 3 , w 4 > 0 command immediate gap widening (retraction) upon persistent short circuits ( Y 3 ) or arcing chains ( Y 4 ); w 1 , w 5 < 0 command fine gap narrowing (feed advance) during prolonged open-circuit pauses ( Y 1 ) or delayed ignitions ( Y 5 ); and w 2 = 0 maintains the gap during productive normal discharges ( Y 2 ). Combined with a deadband hysteresis threshold on P ¯ ( Y k , t ) , Equation (1) outlines the prospective interface between Edge AI state estimation and physical piezo actuation, whose experimental tuning and closed-loop validation are reserved for future work.

4. Neural Network Architecture and Edge AI Implementation

To classify high-frequency gap waveforms under strict edge-latency budgets, a compact multi-input deep learning architecture was designed, trained offline, and compiled for embedded deployment.

4.1. Hybrid CNN-BiGRU-Attention Network Architecture

As shown in Figure 2, the network consists of a dynamic waveform branch, a static conditioning interface, a feature fusion node, and a five-class classification head.
Figure 2. Schematic of the proposed hybrid CNN-BiGRU-Attention neural network. High-frequency transient waveforms (Input1) and static operational parameters (Input2) are processed in parallel, concatenated into a 130-dimensional vector, and mapped to a 5-dimensional output representing the EDM process states.

4.1.1. Dynamic Waveform Branch (CNN-BiGRU-Attention)

The dynamic branch processes transient gap voltage U ( t ) and discharge current I ( t ) as Input 1 ∈ R 2 × N ( N = 1024 ):
  • 1D-CNN Feature Extraction: Three 1D convolutional (Conv1d) stages extract local morphological features—such as steep d U / d t and d I / d t plasma breakdown edges and current-peak envelopes. Stage 1 applies 16 filters with batch normalization (BN), 4 × pooling, and dropout (reducing length to 256); Stage 2 applies 32 filters, BN, 4 × pooling, and dropout ( 32 × 64 ); Stage 3 applies 64 filters and BN without pooling ( 64 × 64 ).
  • Bidirectional Temporal Modeling: A Bidirectional Gated Recurrent Unit (BiGRU) layer with 64 hidden units per direction and dropout encodes the sequence into a tensor of shape 128 × 64 , correlating pre-breakdown ignition delay t d , active discharge duration t e , and post-breakdown plasma decay across the window. In sliding-window deployment, incoming samples are continuously written to a circular ring buffer via direct memory access (DMA). Because inference triggers at the terminal timestamp t end of the already buffered historical window [ t end − N Δ t , t end ] , no future measurements t > t end enter the backward pass; the BiGRU operates strictly causally and retrospectively with respect to t end .
  • Attention-Based Temporal Pooling: A linear temporal attention layer aggregates the 64 compressed steps into a 128 × 1 context vector, selectively weighting the most discriminative terminal breakdown instants despite multiple pulses within the observation window. Compared to pure Transformer self-attention ( O ( N 2 ) across N = 1024 ), combining two-stage convolutional downsampling ( 1024 → 64 ) with BiGRU and linear attention pooling ( O ( N ) ) preserves computational tractability on embedded hardware.

4.1.2. Static Conditioning Interface, Fusion, and Classification Head

In parallel, two static generator protocol settings (pulse-on and pulse-off settings in the implemented pipeline) enter as Input 2 ∈ R 2 and are concatenated with the 128-dimensional attention vector into a 130-dimensional fused vector. A Linear + BN + ReLU projection ( 130 → 64 ) followed by a linear output layer maps this representation to 5-class logits ( Y 1 to Y 5 ), converted via softmax into class probabilities during inference.

4.2. Edge AI Deployment, Latency Budget, and Numerical Consistency

To eliminate host-PC communication jitter, the trained PyTorch 2.5.1 (CUDA 12.4) checkpoint (146,678 parameters; 573.0 KB FP32 weights; 579.7 KB ONNX file; 12 MB active runtime memory) was exported to ONNX (Opset 11, IR version 6) with dynamic batch axes and benchmarked on an embedded NVIDIA Jetson Orin NX Engineering Reference Developer Kit Super (Linux aarch64, 8× ARM A78AE, 1024 Ampere CUDA Cores, 32 Tensor Cores, 16 GB LPDDR5, TDP 15–25 W) using ONNX Runtime v1.24.0 and native C++ TensorRT 10.x (enqueueV3, compiled via trtexec --fp16).
Table 2 reports the pure neural network inference benchmarks measured on synthetic batch-1 inputs (and batch-128 throughput validation). Python ONNX Runtime benchmarks used 15 warmup runs and 1000 timed runs at batch 1 (100 runs at batch 128); an extended Python TensorRT-EP streaming simulation over 50 warmup runs and 5000 runs yielded 2.2500 ± 0.0210  ms (99th percentile 2.2804  ms); and native C++ TensorRT execution times with zero-copy unified memory and CUDA Graphs were averaged over 10,000 timed runs after 50 warmups.
Table 2. Edge AI pure neural network inference benchmarks of the exported hybrid CNN-BiGRU-Attention model (synthetic batch-1 inputs, 580 KB ONNX file), comparing latency, throughput, and power envelope across execution providers.
Notably, batch-1 C++ TensorRT execution (1.2944 ms) is marginally slower than local ARM CPU execution (1.2761 ms). For a compact recurrent model (580 KB) operating at batch 1, the 64 sequential BiGRU steps offer limited parallelism across 1024 CUDA/32 Tensor Cores, so GPU synchronization and host-device dispatch overheads dominate, whereas the ARM A78AE CPU executes small sequential matrix-vector products directly within its L1/L2 cache. Conversely, under parallel batch-128 execution, GPU acceleration dominates (5.04 ms via TensorRT-EP and 7.61 ms via CUDA vs. 75.64 ms on the CPU).
To clearly distinguish pure model inference from full end-to-end closed-loop latency, Table 3 separates experimentally measured inference timing from system overheads estimated analytically and from datasheets. While filling the initial 1024-sample window requires 1.024 ms at 1 M Hz (or 10.24 ms at 100 k Hz ), continuous DMA ring-buffer operation updates the sliding window asynchronously, yielding an estimated effective closed-loop pacing rate of 500–780 Hz once integrated with physical ADC streaming.
Table 3. End-to-end system latency budget separating experimentally measured neural network inference from analytically/datasheet-estimated closed-loop streaming and actuation stages.
Numerical deployment consistency was verified across the entire balanced test set (N = 49,920) between the original PyTorch 2.5.1 FP32 model (CPU) and the exported ONNX Runtime CPU model, yielding a maximum absolute logit deviation of 6.79 × 10 − 6 (mean 6.75 × 10 − 7 ), a maximum probability deviation of 2.89 × 10 − 6 , and 100.00% exact prediction agreement (90.39% accuracy, 0.9040 macro F1). When compared with PyTorch A100 GPU (FP32/TF32), ONNX CPU maintained 99.996% agreement (49,918/49,920, identical 90.39% accuracy; max logit difference 5.95 × 10 − 3 due to Ampere TF32 accumulation). While the C++ TensorRT benchmark utilized FP16 (trtexec --fp16) on the Jetson hardware, direct test-set logit validation of the FP16 engine and post-training INT8 quantization remain subjects for closed-loop hardware integration. Notably, for a compact 580 KB recurrent model at batch 1, INT8 quantization is expected to yield limited latency reduction due to quantization/dequantization and sequential dispatch overhead while risking sensitivity loss on subtle d U / d t breakdown edges, though FP16/INT8 quantization becomes increasingly advantageous for larger multi-channel architectures.

4.3. Supervised Offline Training and Model Convergence

Model parameters were optimized offline using cross-entropy loss with the Adam optimizer, dropout regularization in the pooling and BiGRU layers, and batch normalization after each convolution. Model checkpoints were selected based on peak validation macro F1-score prior to ONNX export.

5. Experimental Setup and Data Acquisition

The experimental recordings build on the die-sinking EDM testbed established by Damm et al. [7], which is used here strictly as an automated offline annotation source to train and benchmark an end-to-end supervised real-time classifier without post hoc peak segmentation.
Machining trials were conducted on a Mitsubishi SG12R die-sinking EDM machine using an oil-based dielectric fluid (IonoPlus IME-MH, Oelheld), predominantly negative tool polarity (84.5% of recording blocks; positive 15.5%), flushing levels 0–2 without tool rotation, primarily solid carbide workpieces (84.8%, complemented by supplementary steel trials 15.2%), and a cylindrical copper tool electrode (1 m m diameter in the calibrated main five-class series, alongside supplementary 3 m m /5 m m series). Electrical gap transients U ( t ) and I ( t ) were captured using a Tektronix MDO34 digital oscilloscope (firmware 1.10.4, 100,000-point record length, raw sampling intervals of 4 ns to 1 μs, i.e., 1 M Hz to 250 M Hz ) equipped with a 1000:1 differential voltage probe and a 10:1 active current clamp in the main calibrated series [7]. During preprocessing, raw streams were resampled to 1 M Hz (or 100 k Hz for extended recordings).
To generate objective ground-truth labels without manual annotation bias, a two-stage unsupervised labeling pipeline grounded in [7] was applied offline: (1) threshold-free peak detection separates non-discharge baseline/pause intervals ( Y 1 ) from active discharge peaks; (2) active discharges are partitioned via K-means clustering ( K = 4 , 10 random initializations, | z | < 3.0 outlier filtering during fitting) over six Z-standardized waveform features (voltage amplitude Δ U , current amplitude Δ I , pulse duration, absolute voltage/current slopes, and current–voltage peak time offset Δ t I − V ) into four active discharge classes ( Y 2 to Y 5 ), corresponding to the four physical EDM discharge regimes whose macroscopic correlations with MRR and TWR were independently validated by expert inspection and machining trials in [7]. Across five stratified 20,000-peak subsamples of the 247,022 clustered training peaks, this four-cluster partition achieved an empirical silhouette score of 0.6106 ± 0.0024 , confirming a well-separated cluster structure.
Subsequently, causal sliding observation windows of length N = 1024 samples were extracted with a stride of 1 sample (1023-sample/99.90% overlap) and assigned the class label ( Y 1 to Y 5 ) at the terminal sample t end . The length N = 1024 provides a power-of-two dimension compatible with two 4 × pooling stages ( 1024 → 256 → 64 ), ensures efficient DMA ring-buffer alignment, and covers one to two discharge cycles within the sub-1.3 ms inference budget. Table 4 summarizes the physical interpretation, characteristic ignition-delay centroids from [7] (to which readers are referred for representative waveform plots), empirical waveform cluster statistics ( Δ U , Δ I mean ± SD; pulse duration median [IQR]), and balanced test support for each class.
Table 4. Physical definitions, characteristic electrical waveform features (ignition-delay centroids t d from [7] and empirical cluster statistics from 247,022 clustered training peaks), macroscopic process impact, and balanced test support (N = 49,920) of the five EDM spark-state classes ( Y 1 to Y 5 ).

6. Results and Discussion

This section evaluates dataset partitioning, training convergence, comparative benchmarking against rule-based, ablation, and external deep baselines across balanced and naturally imbalanced test streams, statistical robustness, and practical limitations.

6.1. Dataset Partitioning, Class Imbalance, and Training Configuration

The complete experimental database spans 8369 continuous oscilloscope recording blocks, of which 8264 valid blocks (≥1024 cleaned samples; 105 short/invalid blocks excluded) contain 350,867 detected discharge peaks, yielding 234,371,928 causal sliding windows ( stride = 1 ) or 234,558 non-overlapping windows ( stride = 1024 ). To prevent temporal data leakage across overlapping sliding windows, partitioning was performed strictly at the recording-block (file) level using a fixed seed (42), targeting a 70%:15%:15% ratio: 5742 valid training blocks (69.5%, 246,797 peaks), 1262 validation blocks (15.3%, 53,343 peaks), and 1260 independent test blocks (15.2%, 50,727 peaks), with zero overlapping windows shared across split boundaries.
Because natural EDM streams are heavily dominated by non-discharge baseline intervals (95.65% Y 1 ; Table 5), class imbalance was handled via a two-stage training protocol: in each epoch, 30 randomly sampled training blocks were balanced to 10,000 windows per class (50,000 total) via undersampling of Y 1 and oversampling of minority classes with replacement, combined with inverse-frequency cross-entropy loss weights (effectively w c = 1.0 under full class balance) and early stopping governed by validation macro F1-score. For unbiased class-equal evaluation, the balanced independent test set (N = 49,920) was constructed by drawing 100 test blocks (99 valid, 2,852,723 natural windows) using seed 42; because all five classes exceeded 12,270 natural windows in this subset, pure stratified undersampling without replacement yielded 10,000 unique windows per class (50,000 total), and mini-batching (batch_size = 128, drop_last = True) discarded the final 80-window remainder (⌊ 50,000/128 ⌋ × 128 = 390   × 128 = 49,920). To assess realistic online operating conditions, all models were additionally evaluated on the full naturally imbalanced test split across all 1260 test blocks ( stride = 16 , N = 2,214,745 windows).
Table 5. Exact per-class window distribution across the block-level splits (sliding windows at stride = 1 ), the full naturally imbalanced evaluation grid ( stride = 16 , all 1260 test blocks), and the balanced independent test set (N = 49,920).
Offline training was conducted in PyTorch 2.5.1 on an NVIDIA A100-PCIE-40GB GPU using Adam (initial learning rate 1 × 10−4, ReduceLROnPlateau down to 1 × 10−8), a mini-batch size of 128, up to 100 epochs, and early stopping with patience 20 on validation macro F1-score.

6.2. Training Performance and Loss Convergence

Figure 3 illustrates the training trajectory of the proposed hybrid CNN-BiGRU-Attention network. Training and validation cross-entropy losses decrease steadily from initial values of 1.00 and 1.69 until an optimal checkpoint is reached at epoch 34 (validation macro F1 = 0.8588, training loss = 0.2929, validation loss = 0.4986), after which early stopping terminates training at epoch 54 and restores epoch-34 weights for deployment.
Figure 3. Training progress of the proposed hybrid CNN-BiGRU-Attention network over 54 epochs, displaying raw and 5-epoch-smoothed trajectories of training loss, validation loss, and validation macro F1-score.

6.3. Comparative Evaluation, Ablation Study, and Imbalanced-Stream Analysis

To rigorously assess architectural design choices, Table 6 benchmarks ten models under a unified single-seed (seed = 42) evaluation across both the balanced test set (N = 49,920) and the full naturally imbalanced test stream (N = 2,214,745): two rule-based threshold baselines (instantaneous U ( t end ) , I ( t end ) and causal pulse-amplitude tracking [18,19]), a static-only MLP sanity check, progressive architectural ablations (Pure 1D-CNN, Unidirectional CNN-GRU, CNN-BiGRU without Attention, CNN-Attention without BiGRU, and Waveform-only Hybrid without Input2), an external causal dilated temporal convolutional network (TCN; four residual blocks, dilations 1–8, receptive field 484) with identical multi-modal fusion, and the proposed Hybrid CNN-BiGRU-Attention network. Model complexity is quantified via trainable parameters, batch-1 MACs/FLOPs ( 1 MAC = 2 FLOPs ), and A100 training duration.
Table 6. Unified single-seed (seed = 42) comparative benchmark, component ablation, and complexity analysis on both the balanced (N = 49,920) and full naturally imbalanced (N = 2,214,745) test sets.
Table 6 reveals several crucial insights:
  • Deep Learning vs. Rule-Based and Static Baselines: The Static MLP acts purely as a lower-bound sanity check (28.94% balanced, 3.65% unbalanced), confirming that static settings alone cannot resolve transient gap states. While the causal threshold baseline achieves 95.66% unbalanced accuracy by predicting the dominant 95.24% baseline class Y 1 , it fails to discriminate active discharge states (balanced accuracy 61.32%, unbalanced macro F1 0.5190). All deep waveform models outperform rule-based thresholding by + 28 –30 percentage points in balanced accuracy and + 0.14 – 0.18 in unbalanced macro F1.
  • Component Ablation and External TCN Trade-Off: Removing temporal attention from the proposed model (CNN-BiGRU No Attn) lowers balanced accuracy by − 1.18  pp (89.21% vs. 90.39%), confirming that attention pooling isolates terminal breakdown cues more effectively than last-step readout. Interestingly, for this single seed (seed = 42), all strong temporal architectures—Uni-CNN-GRU (91.44%), CNN-Attention No BiGRU (90.86%), External TCN (90.80%), Waveform-only (90.54%), and Hybrid (90.39%)—cluster tightly within ≈1 pp, which lies within the multi-seed stochastic variance ( ± 0.98 %, Section 6.4). Notably, CNN-Attention (No BiGRU) achieves strong accuracy with 9 × fewer parameters (16,118) and 6.5 × fewer MACs (1.45 M), highlighting an attractive ultra-lightweight candidate for microcontrollers, whereas External TCN requires 2.53 × higher computational cost (23.94 M MACs) while achieving lower unbalanced performance (94.08% accuracy, 0.6607 macro F1).
  • Multi-modal Conditioning vs. Shortcut Hypothesis: Removing static inputs (Waveform-only Hybrid: 90.54% balanced, 95.79% unbalanced) matches the full hybrid model without accuracy loss. This occurs because, within the calibrated five-class main measurement regime, the static protocol parameters (ON, OFF) are held constant; consequently, the raw transient waveforms U ( t ) , I ( t ) carry the complete discriminative information. Crucially, this directly refutes any concern that the classifier exploits a static-parameter or sampling-rate shortcut, while retaining Input2 as an extensible conditioning interface for broader multi-regime datasets.
Table 7 compares class-wise metrics of the proposed hybrid model across both test distributions, alongside its confusion matrix on the balanced test set in Figure 4. Under the natural 95.24% Y 1 prevalence, overall accuracy rises to 94.82% (weighted F1 0.9627), while macro F1 drops to 0.6696. This reflects a classical Bayesian base-rate effect resulting from class-balanced training: although Y 1 recall remains high (95.21%), the remaining 4.79% false positives from over 2.1 million baseline windows fall predominantly into the lowest-amplitude peak class Y 3 ( Δ U = 0.31 V , 0.57% prevalence), depressing Y 3 precision to 0.1127 while maintaining strong active-state recall ( Y 2 : 0.9162, Y 3 : 0.7997, Y 4 : 0.8517, Y 5 : 0.7197). In online deployment, this precision drop can be directly mitigated without retraining via prior-adjusted softmax thresholding and temporal probability smoothing.
Table 7. Class-wise precision, recall, and F1-score of the proposed hybrid CNN-BiGRU-Attention model on the balanced (N = 49,920) and full naturally imbalanced (N = 2,214,745) test sets.
Figure 4. Confusion matrix of the proposed hybrid CNN-BiGRU-Attention model on the balanced test dataset (N = 49,920), displaying sample distributions across the baseline ( Y 1 ) and four active discharge classes ( Y 2 to Y 5 ).
Stratified evaluation across generator settings confirmed high five-class performance within the calibrated main regime (IP  ≤ 4.1 /ON  = 3.3 , representing 94.4% of unbalanced test windows: 96.23%/95.06% unbalanced accuracy and 89.39%/90.24% balanced accuracy), whereas secondary recording blocks with differing electrode/probe settings contained only two detected classes ( Y 1 , Y 3 ) and exhibited lower unbalanced accuracy (89.19% at medium current, 79.82% at high current), motivating explicit domain adaptation in future work.
Figure 4 reveals a strongly diagonally dominant confusion matrix on the balanced test set, with moderate off-diagonal confusion concentrated among Y 2 (Normal), Y 4 (Arcing), and Y 5 (Delayed Ignition). Physically, Y 2 , Y 4 , and Y 5 form a continuous transition governed by dielectric deionization state and local debris concentration rather than discrete thresholds. Because supervised ground truth is inherited from unsupervised clustering, boundary waveforms with intermediate ignition delay t d exhibit irreducible aleatoric label uncertainty, establishing a natural Bayes ceiling consistent with the observed ≈90% accuracy. Crucially, from a real-time EDM monitoring perspective, misclassification costs are strongly asymmetric: confusions between Y 2 and Y 5 are benign (neither causes thermal surface damage or excessive wear), while isolated false negatives on arcing ( Y 4 predicted as Y 2 ) are mitigated in online operation because damaging arcing develops as persistent multi-pulse chains over several milliseconds, which moving-average probability aggregation over consecutive windows reliably detects. Meanwhile, short-circuit bridging ( Y 3 ) achieves 0.95 balanced precision and 0.94 recall.

6.4. Statistical Significance and Multi-Seed Robustness

To assess robustness against random initialization, the core progressive architectures were trained across five independent random seeds (42, 101, 2023, 99, and 7) in a multi-seed evaluation protocol (Table 8). While single-seed evaluations (Table 6) can fluctuate within ± 1 % across closely competing temporal models, the five-seed protocol confirms consistent convergence with standard deviations of 0.38% to 1.10%. A paired two-sample t-test comparing the proposed hybrid network and the unidirectional CNN-GRU baseline across the five seeds yielded t = 3.92 ( p = 0.0170 < 0.05 ), with non-overlapping 95% binomial confidence intervals on the balanced test set ([90.01%, 90.53%] vs. [88.67%, 89.21%]).
Table 8. Mean and standard deviation of balanced test accuracy and macro F1-score across five independent training seeds for the core progressive architectures.

6.5. Generalizability, Practical Robustness, and Limitations

Several scope boundaries and practical robustness factors must be acknowledged. First, the calibrated five-class dataset was acquired on a single die-sinking machine (Mitsubishi SG12R) using an oil dielectric and primarily copper/carbide tooling; transferring the trained weights directly to different workpiece alloys (e.g., steels, superalloys), electrode materials (e.g., graphite), or deionized-water dielectrics introduces a domain shift in open-circuit and discharge voltage levels. Second, severe industrial disturbances—including heavy debris accumulation, dielectric contamination, progressive electrode wear altering effective frontal area, extreme flushing variations, and high-aspect-ratio deep-hole machining—shift class prevalence toward Y 3 and Y 4 and may distort waveform morphology beyond the calibrated training envelope. While the classifier inherently detects rising short-circuit and arcing frequencies within its calibrated domain, cross-machine and cross-material generalization requires lightweight transfer learning (fine-tuning the projection head on compact calibration runs) and online prior calibration, which are directly supported by the generic architecture and automated unsupervised labeling pipeline.

7. Conclusions

A hardware-oriented Edge AI framework for causal, real-time EDM spark-state classification using a hybrid CNN-BiGRU-Attention neural network was presented and benchmarked. Having been developed by transferring offline unsupervised pulse diagnostics into a direct sliding-window classifier, the exported model operates at 1.28 ms on the CPU (ONNX FP32, verified to achieve 100% numerical prediction agreement with PyTorch) and 1.29 ms via C++ TensorRT (FP16) on an embedded NVIDIA Jetson Orin NX (≈ 780 Hz pure inference rate within ≤25 W). Across the investigated die-sinking EDM dataset, the proposed network achieves 90.27% five-seed mean accuracy (90.39% single-seed balanced accuracy; 94.82% unbalanced-stream accuracy), vastly outperforming rule-based threshold discriminators, while ablation benchmarks further identify pure CNN-Attention as a compelling ultra-lightweight alternative (16.1k parameters) and confirm that transient waveforms alone drive classification without static-parameter shortcuts. This establishes a verified, low-latency state-estimation module designed to support future closed-loop gap stabilization.
Future research will focus on physically integrating the EdgeAI module with live ADC/DMA streaming and implementing the conceptual control law (Equation (1)) to drive the high-bandwidth piezo actuator during closed-loop machining trials. This will enable direct empirical quantification of closed-loop MRR, TWR, and surface roughness ( R a ) improvements, alongside hardware-in-the-loop end-to-end latency validation, FP16/INT8 accuracy benchmarking, and transfer learning adaptation across varying workpiece materials, electrode wear states, and extreme high-aspect-ratio flushing conditions.

Author Contributions

Conceptualization, P.P. and P.D.; methodology, P.P. and P.D.; software, P.P.; validation, P.P. and P.D.; formal analysis, P.P.; investigation, P.P. and P.D.; resources, G.M. and M.H.-O.; data curation, P.P. and P.D.; writing—original draft preparation, P.P.; writing—review and editing, P.P., P.D., G.M. and M.H.-O.; visualization, P.P.; supervision, G.M. and M.H.-O.; project administration, G.M. and M.H.-O.; funding acquisition, M.H.-O. All authors have read and agreed to the published version of the manuscript.

Funding

This project was funded by the State of Saxony-Anhalt with funds from the European Union under the European Regional Development Fund (ERDF) under project number ZS/2023/12/182059. The machine tool Mitsubishi SG12R was funded by the German Research Foundation (DFG) under project number 509924008.

Data Availability Statement

The implementation and source code underlying this study are publicly available on GitHub at https://github.com/p-pl/edm-spark-control (accessed on 28 November 2026).

Acknowledgments

During the preparation of this work, the authors used Gemini 3.1 Pro by Google to support structuring, outlining, and language refinement in Section 1, Section 2, Section 6 and Section 7. All conceptualization, experimental data acquisition, model implementation, quantitative evaluations, and scientific interpretations were performed exclusively by the authors, who reviewed and edited the manuscript as needed and take full responsibility for the content of the published article.

Conflicts of Interest

The authors declare no conflicts of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript; or in the decision to publish the results.

References

  1. Paul, T.; Das, S.; Sengupta, A.R. A critical review of electrical discharge machining for superalloys and high performance metals. Discov. Appl. Sci. 2026, 8, 223. [Google Scholar] [CrossRef] [Scilit]
  2. Rajhi, W.; Boujelbene, M.; Ben Said, L.; El Aoud, B.; Alshammrei, S. Modeling the surface alterations effect on EDM efficiency of Ti6Al4V alloy. Int. J. Refract. Met. Hard Mater. 2025, 132, 107292. [Google Scholar] [CrossRef] [Scilit]
  3. Pedroso, A.F.V.; Lucas, R.; Teixeira, L.; Campilho, R.D.S.G.; Pinto, A.G.; Costa, R.; Sales-Contini, R.d.C.M. Electrical Discharge Machining of Composites: A Critical Review of Challenges and Innovations. J. Mech. Eng. Manuf. 2025, 1, 5. [Google Scholar] [CrossRef] [Scilit]
  4. Ulhakim, M.T.; Sukarman; Khoirudin; Mulyadi, D.; Susilo, H.; Rohman; Setiyo, M. Electrical discharge machining: Recent advances and future trends in modeling, optimization, and sustainability. Int. J. Light. Mater. Manuf. 2025, 8, 495–511. [Google Scholar] [CrossRef] [Scilit]
  5. Hasan, M.M.; Saleh, T.; Sophian, A.; Rahman, M.A.; Huang, T.; Mohamed Ali, M.S. Experimental modeling techniques in electrical discharge machining (EDM): A review. Int. J. Adv. Manuf. Technol. 2023, 127, 2125–2150. [Google Scholar] [CrossRef] [Scilit]
  6. Ye, L.; Guo, C.; Valentinčič, J.; Qian, J.; Reynaerts, D.; Yu, N. In-situ process monitoring and control in EDM: A review. J. Manuf. Process. 2025, 152, 899–928. [Google Scholar] [CrossRef] [Scilit]
  7. Damm, P.; Bederitzky, O.; Vogel, J.; Riefer, A.; Plänitz, P.; Lerez, C.; Meichsner, G.; Hackert-Oschätzchen, M. Classification and Detection Method for Discharges in Electrical Discharge Machining through Unsupervised Learning. Solid State Phenom. 2026, 391, 43–53. [Google Scholar] [CrossRef] [Scilit]
  8. Assarzadeh, S.; Ghoreishi, M. Neural-network-based modeling and optimization of the electro-discharge machining process. Int. J. Adv. Manuf. Technol. 2008, 39, 488–500. [Google Scholar] [CrossRef] [Scilit]
  9. Wang, K.; Gelgele, H.L.; Wang, Y.; Yuan, Q.; Fang, M. A hybrid intelligent method for modelling the EDM process. Int. J. Mach. Tools Manuf. 2003, 43, 995–999. [Google Scholar] [CrossRef] [Scilit]
  10. Joshi, S.N.; Pande, S.S. Development of an intelligent process model for EDM. Int. J. Adv. Manuf. Technol. 2009, 45, 300–317. [Google Scholar] [CrossRef] [Scilit]
  11. Dey, K.; Kalita, K.; Chakraborty, S. Prediction performance analysis of neural network models for an electrical discharge turning process. Int. J. Interact. Des. Manuf. 2023, 17, 827–845. [Google Scholar] [CrossRef] [Scilit]
  12. Sable, Y.S.; Dharmadhikari, H.M.; More, S.A.; Sarris, I.E. Exploring Artificial Neural Network Techniques for Modeling Surface Roughness in Wire Electrical Discharge Machining of Aluminum/Silicon Carbide Composites. J. Compos. Sci. 2025, 9, 259. [Google Scholar] [CrossRef] [Scilit]
  13. Schumacher, B.M. About the Role of Debris in the Gap During Electrical Discharge Machining. CIRP Ann. 1990, 39, 197–199. [Google Scholar] [CrossRef] [Scilit]
  14. DiBitonto, D.D.; Eubank, P.T.; Patel, M.R.; Barrufet, M.A. Theoretical models of the electrical discharge machining process. I. A simple cathode erosion model. J. Appl. Phys. 1989, 66, 4095–4103. [Google Scholar] [CrossRef] [Scilit]
  15. Kunieda, M.; Lauwers, B.; Rajurkar, K.P.; Schumacher, B.M. Advancing EDM through Fundamental Insight into the Process. CIRP Ann. 2005, 54, 64–87. [Google Scholar] [CrossRef] [Scilit]
  16. Tarng, Y.S.; Ma, S.C.; Chung, L.K. Determination of optimal cutting parameters in wire electrical discharge machining. Int. J. Mach. Tools Manuf. 1995, 35, 1693–1701. [Google Scholar] [CrossRef] [Scilit]
  17. Spedding, T.A.; Wang, Z.Q. Study on modeling of wire EDM process. J. Mater. Process. Technol. 1997, 69, 18–28. [Google Scholar] [CrossRef] [Scilit]
  18. Dekeyser, W.; Snoeys, R.; Jennes, M. Expert system for wire cutting EDM, based on pulse classification and thermal modeling. Robot. Comput.-Integr. Manuf. 1988, 4, 219–224. [Google Scholar] [CrossRef] [Scilit]
  19. Küpper, U.; Herrig, T.; Klink, A.; Welling, D.; Bergs, T. Evaluation of the Process Performance in Wire EDM Based on an Online Process Monitoring System. Procedia CIRP 2020, 95, 360–365. [Google Scholar] [CrossRef] [Scilit]
  20. Abhilash, P.M.; Chakradhar, D.; Luo, X. Machine Learning Based Classification and Analysis of Wire-EDM Discharge Pulses. In Proceedings of the 2022 8th International Conference on Nanomanufacturing & 4th AET Symposium on ACSM and Digital Manufacturing (Nanoman-AETS), Dublin, Ireland, 30 August–1 September 2022; pp. 1–6. [Google Scholar] [CrossRef] [Scilit]
  21. Saeedi, J.; Dotta, M.; Galli, A.; Nasciuti, A.; Maradia, U.; Boccadoro, M.; Gambardella, L.M.; Giusti, A. Measurement and inspection of electrical discharge machined steel surfaces using deep neural networks. Mach. Vis. Appl. 2021, 32, 21. [Google Scholar] [CrossRef] [Scilit]
  22. Sanchez, J.A.; Conde, A.; Arriandiaga, A.; Wang, J.; Plaza, S. Unexpected Event Prediction in Wire Electrical Discharge Machining Using Deep Learning Techniques. Materials 2018, 11, 1100. [Google Scholar] [CrossRef] [Scilit]
  23. Liu, C.; Yang, X.; Peng, S.; Zhang, Y.; Peng, L.; Zhong, R.Y. Spark Analysis Based on the CNN-GRU Model for WEDM Process. Micromachines 2021, 12, 702. [Google Scholar] [CrossRef] [Scilit]
  24. Kumar, N.V.; Chakradhar, D. Predictive Maintenance of Wire Electrical Discharge Machining Using Long Short-Term Memory Networks for Improved Process Control. Procedia CIRP 2025, 133, 167–172. [Google Scholar] [CrossRef] [Scilit]
  25. Jiang, J.-R.; Yen, C.-T. Product Quality Prediction for Wire Electrical Discharge Machining with Markov Transition Fields and Convolutional Long Short-Term Memory Neural Networks. Appl. Sci. 2021, 11, 5922. [Google Scholar] [CrossRef] [Scilit]
  26. Ye, L.; Qian, J.; Reynaerts, D. A physics-informed CNN-TSE hybrid network for micro-EDM process monitoring and control. Mech. Syst. Signal Process. 2023, 202, 110685. [Google Scholar] [CrossRef] [Scilit]
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

Article metric data becomes available approximately 24 hours after publication online.