CNN and FiLM-based leakage current type intelligent identification method
By employing a CNN and FiLM-based intelligent leakage current type identification method, a dataset is constructed using multi-channel waveforms and environmental feature parameters. A FiLM conditional modulation module and a multi-task learning framework are introduced to solve the problems of poor anti-interference and low adaptability in existing leakage current detection technologies. This achieves high-precision leakage current type identification and grounding system discrimination, improving the accuracy and robustness of system diagnosis.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-31
- Publication Date
- 2026-03-31
AI Technical Summary
Existing leakage current detection methods have poor anti-interference capabilities in complex transformer substation environments, high false alarm and false alarm rates, and cannot effectively distinguish between different types of leakage current. They perform poorly, especially when DC components are mixed in and when arc discharge occurs. They also lack adaptability and cannot take advantage of environmental conditions such as humidity, temperature, and grounding resistance.
A smart leakage current type identification method based on CNN and FiLM is adopted. By collecting multi-channel waveforms and environmental feature parameters, a dataset is constructed. The FiLM conditional modulation module and multi-task learning framework are introduced. The weighted cross-entropy loss function and OneCycleLR dynamic learning rate scheduling strategy are used to achieve high-precision identification of leakage current type and grounding system discrimination, thereby enhancing the discriminativeness of feature representation.
It achieves high-precision identification of multiple types of faults such as single-phase grounding and arc-type leakage under complex working conditions. It can adapt to different grounding systems, improve the accuracy and robustness of system diagnosis, reduce the risk of false alarms and missed alarms, and adapt to different environmental changes.
Smart Images

Figure CN121765448A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of power distribution network leakage current detection technology, specifically involving an intelligent identification method for leakage current type based on CNN and FiLM. Background Technology
[0002] In low-voltage power distribution network operation, leakage current is caused by factors such as aging equipment insulation, damaged wires, humid environment, or equipment failure. Its manifestations are complex and diverse, including single-phase grounding leakage, arcing leakage, and DC system leakage. If these faults are not identified and located in a timely manner, they can lead to damage to power distribution lines, equipment burnout, and even electrical fires, seriously threatening power supply safety and the personal and property safety of users.
[0003] Existing leakage current detection methods mainly rely on traditional technologies, with the core depending on residual current devices (RCDs) or discrimination logic based on fixed thresholds. These methods have poor anti-interference capabilities and high false alarm and false alarm rates in complex transformer substation environments containing harmonics and noise. They also have limited classification capabilities and cannot effectively distinguish between different types of leakage current, especially when DC components are mixed in or when arcing occurs. Furthermore, they lack adaptability and traditional methods cannot take advantage of the influence of environmental conditions, such as humidity, temperature, and grounding resistance, on leakage current characteristics.
[0004] Therefore, there is an urgent need for a technical solution that combines multi-source features with machine learning models to achieve automatic, accurate, and robust identification of leakage current types, and to solve the core problems of traditional methods such as weak anti-interference, poor classification, and low adaptability. Summary of the Invention
[0005] The purpose of this invention is to overcome the shortcomings of the prior art and provide an intelligent identification method for leakage current type based on CNN and FiLM, which can achieve high-precision identification of multiple types of faults such as single-phase grounding, arc leakage, and DC system leakage, and can be adapted to different grounding systems to improve the accuracy and robustness of system diagnosis.
[0006] The objective of this invention is achieved as follows: a smart leakage current type identification method based on CNN and FiLM, comprising the following steps:
[0007] S1. Collect real-time operating data of typical power supply areas, obtain leakage current waveforms and related environmental characteristic parameters under different operating conditions, and construct the original leakage current sample dataset.
[0008] S2. Construct a CNN-based leakage current classification model, introduce the FiLM conditional modulation module, and use a multi-task learning framework at the end of the network. The main task is leakage current type identification, and the auxiliary task is grounding system discrimination to enhance the discriminativeness of feature representation.
[0009] S3. Use the weighted cross-entropy loss function to alleviate the class imbalance problem; introduce the OneCycleLR dynamic learning rate scheduling strategy to improve convergence efficiency and prevent overfitting, and use the early stopping strategy to automatically save the model parameters that perform best on the validation set.
[0010] S4. Evaluate the model's performance on the test set, using accuracy and confusion matrix as evaluation metrics.
[0011] Furthermore, step S1, which involves collecting real-time operating data from typical power supply areas, obtaining leakage current waveforms and related environmental characteristic parameters under different operating conditions, and constructing an original leakage current sample dataset, also includes:
[0012] The dataset is preprocessed and labeled, and divided into training, validation and test sets according to a certain ratio to provide basic data support for subsequent model training and validation.
[0013] The system acquires multi-channel waveforms composed of three-phase voltage, current, and zero-sequence (or residual) current, reads auxiliary feature fields and label fields aligned with the samples, performs channel-by-channel normalization on each waveform channel, and adds small-amplitude Gaussian noise and waveform mixup to enhance robustness.
[0014] The multi-channel waveform may include channels va, vb, vc, ia, ib, ic, and ires. Auxiliary feature fields include humidity, moisture_factor, and temperature. Tag fields include leakage type (class) and grounding system (grounding).
[0015] Furthermore, step S1, which involves collecting real-time operating data from typical power supply areas, obtaining leakage current waveforms and related environmental characteristic parameters under different operating conditions, and constructing an original leakage current sample dataset, also includes:
[0016] The samples are divided into input features and output labels. The input includes multi-channel time-series waveforms and four-dimensional auxiliary features; the output labels include the leakage type of the main task and the grounding system of the auxiliary task. A hierarchical strategy is adopted to divide the data into training set, validation set and test set, with the training set accounting for 60%, the validation set for 20%, and the test set for 20%. The output labels use integer encoding to adapt to cross-entropy loss. When needed, one-hot encoding can be generated during the evaluation stage for confusion matrix display.
[0017] Furthermore, in step S2, constructing a CNN-based leakage current classification model and introducing a FiLM conditional modulation module includes:
[0018] The specific steps for constructing a network structure that includes residual one-dimensional convolutional blocks and FiLM are as follows.
[0019] (1) Perform backbone extraction, including two levels of residual convolutional blocks (with GroupNorm, GELU, Dropout), kernel length 5–7, emphasizing short-term local patterns and transients;
[0020] (2) Perform conditional modulation, take four-dimensional auxiliary features as input, generate channel-level scaling or translation parameters (γ, β) through a multilayer perceptron, perform channel-level affine transformation on the convolutional features, and realize working condition adaptation;
[0021] (3) Perform feature aggregation, and combine adaptive average pooling and max pooling in parallel to obtain the global representation;
[0022] (4) Perform dual-head output, classify the leakage current type of the output head, and the grounding system (TN / TT / IT) of the output head.
[0023] Furthermore, in step S3, a weighted cross-entropy loss function is used to alleviate the class imbalance problem; the OneCycleLR dynamic learning rate scheduling strategy is introduced, including:
[0024] Cross-entropy with class-imbalanced weights is used as the loss for the main task, while standard cross-entropy is used for the auxiliary task. The optimizer is AdamW, combined with OneCycleLR for learning rate scheduling and gradient pruning. The four-dimensional auxiliary features are standardized only using training set statistics to avoid data leakage, and the early stopping criterion is based on the accuracy of the validation set.
[0025] Further, step S4 evaluates the model's performance on the test set, using accuracy and confusion matrix as evaluation metrics, including:
[0026] The accuracy, macro-average precision, recall, and F1 score of the primary task are evaluated on the test set, and a confusion matrix is generated. The accuracy of the secondary task is also given to demonstrate its positive transfer effect.
[0027] In online or offline scenarios, input real-time acquired multi-channel waveforms and four-dimensional auxiliary features, and obtain the discrimination results of leakage current type and grounding system through model forward propagation;
[0028] When the accuracy of the main task or the macro average F1 score does not reach the preset threshold, adjust the learning rate, data augmentation intensity or number of convolution channels, or perform subset selection and retraining within the four-dimensional auxiliary features according to the on-site sensing configuration until the target is met.
[0029] The beneficial effects of this invention are as follows: This invention provides an intelligent leakage current type identification method based on CNN and FiLM, comprising the following steps: S1. Collecting real-time operating data of typical power supply areas, obtaining leakage current waveforms and related environmental characteristic parameters under different operating conditions, and constructing an original leakage current sample dataset; S2. Constructing a CNN-based leakage current classification model, introducing a FiLM conditional modulation module, using a multi-task learning framework at the end of the network, with the main task being leakage current type identification and the auxiliary task being grounding system discrimination, enhancing the discriminative power of feature representation; S3. Using a weighted cross-entropy loss function to alleviate the class sample imbalance problem; introducing a OneCycleLR dynamic learning rate scheduling strategy to improve convergence efficiency and prevent overfitting, and using an early stopping strategy to automatically save the model parameters that perform best on the validation set; S4. Evaluating the model performance on the test set, using accuracy and confusion matrix as evaluation metrics; Through the above methods, this invention provides an intelligent leakage current type identification method based on CNN and FiLM. The iLM intelligent leakage current type identification method uses environmental factors (humidity, temperature, grounding resistance, noise level, power factor, etc.) as conditional vectors to perform FiLM conditional modulation on the waveform channels. It also introduces multi-task joint learning to ensure that the feature representation converges consistently to both operating condition changes and mechanism labels. The feature extraction process is simplified by using the original multi-channel waveform as input, combined with standardization (z-score) and lightweight data augmentation (Gaussian noise, waveform mixup, and environmental vector mixup). The network automatically learns the key time-frequency / morphological features that distinguish different leakage current types, avoiding tedious manual feature engineering and subjective threshold setting. By explicitly encoding operating condition differences into the feature channels through conditional modulation FiLM, the model can quickly adapt to new scenarios with a small amount of new environmental data or a small amount of gradient updates. It achieves high-precision identification of multiple types of faults such as single-phase grounding, arc-type leakage, and DC system leakage, and can adapt to different grounding systems, improving the accuracy and robustness of system diagnosis. Attached Figure Description
[0030] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 This is a flowchart illustrating a method for intelligent identification of leakage current types based on CNN and FiLM.
[0032] Figure 2 This is a schematic diagram of the test curve loss in an embodiment of a smart leakage current type identification method based on CNN and FiLM.
[0033] Figure 3 This is a schematic diagram of the test accuracy curve in an embodiment of a smart leakage current type identification method based on CNN and FiLM.
[0034] Figure 4 This is a schematic diagram of the confusion matrix visualization in an embodiment of a smart leakage current type identification method based on CNN and FiLM.
[0035] Figure 5 This is a schematic diagram of the Precision scores for each category in an embodiment of a smart leakage current type identification method based on CNN and FiLM.
[0036] Figure 6 This is a schematic diagram of the Recall scores for each category in an embodiment of a smart leakage current type identification method based on CNN and FiLM.
[0037] Figure 7 This is a schematic diagram of the F1 scores for each category in an embodiment of a smart leakage current type identification method based on CNN and FiLM. Detailed Implementation
[0038] The present invention will now be further described with reference to the accompanying drawings.
[0039] It should be understood that the specific embodiments described herein are for illustrative purposes only and are not intended to limit the scope of the invention.
[0040] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0041] It should be noted that in the embodiments of the present invention, all directional indications (such as up-down-left-right-forward-backward...) are only used to explain the relative positional relationship and movement between the components in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indication will also change accordingly. The connection can be a direct connection or an indirect connection.
[0042] like Figure 1 As shown, the present invention provides a method for intelligent identification of leakage current type based on CNN and FiLM, comprising the following steps:
[0043] S1. Collect real-time operating data of typical power supply areas, obtain leakage current waveforms and related environmental characteristic parameters under different operating conditions, and construct the original leakage current sample dataset.
[0044] S2. Construct a CNN-based leakage current classification model, introduce the FiLM conditional modulation module, and use a multi-task learning framework at the end of the network. The main task is leakage current type identification, and the auxiliary task is grounding system discrimination to enhance the discriminativeness of feature representation.
[0045] S3. Use the weighted cross-entropy loss function to alleviate the class imbalance problem; introduce the OneCycleLR dynamic learning rate scheduling strategy to improve convergence efficiency and prevent overfitting, and use the early stopping strategy to automatically save the model parameters that perform best on the validation set.
[0046] S4. Evaluate the model's performance on the test set, using accuracy and confusion matrix as evaluation metrics.
[0047] Furthermore, step S1, which involves collecting real-time operating data from typical power supply areas, obtaining leakage current waveforms and related environmental characteristic parameters under different operating conditions, and constructing an original leakage current sample dataset, also includes:
[0048] The dataset is preprocessed and labeled, and divided into training, validation and test sets according to a certain ratio to provide basic data support for subsequent model training and validation.
[0049] The system acquires multi-channel waveforms composed of three-phase voltage, current, and zero-sequence (or residual) current, reads auxiliary feature fields and label fields aligned with the samples, performs channel-by-channel normalization on each waveform channel, and adds small-amplitude Gaussian noise and waveform mixup to enhance robustness.
[0050] The multi-channel waveform may include channels va, vb, vc, ia, ib, ic, and ires. Auxiliary feature fields include humidity, moisture_factor, and temperature. Tag fields include leakage type (class) and grounding system (grounding).
[0051] Furthermore, step S1, which involves collecting real-time operating data from typical power supply areas, obtaining leakage current waveforms and related environmental characteristic parameters under different operating conditions, and constructing an original leakage current sample dataset, also includes:
[0052] The samples are divided into input features and output labels. The input includes multi-channel time-series waveforms and four-dimensional auxiliary features; the output labels include the leakage type of the main task and the grounding system of the auxiliary task. A hierarchical strategy is adopted to divide the data into training set, validation set and test set, with the training set accounting for 60%, the validation set for 20%, and the test set for 20%. The output labels use integer encoding to adapt to cross-entropy loss. When needed, one-hot encoding can be generated during the evaluation stage for confusion matrix display.
[0053] Furthermore, in step S2, constructing a CNN-based leakage current classification model and introducing a FiLM conditional modulation module includes:
[0054] The specific steps for constructing a network structure that includes residual one-dimensional convolutional blocks and FiLM are as follows.
[0055] (1) Perform backbone extraction, including two levels of residual convolutional blocks (with GroupNorm, GELU, Dropout), kernel length 5–7, emphasizing short-term local patterns and transients;
[0056] (2) Perform conditional modulation, take four-dimensional auxiliary features as input, generate channel-level scaling or translation parameters (γ, β) through a multilayer perceptron, perform channel-level affine transformation on the convolutional features, and realize working condition adaptation;
[0057] (3) Perform feature aggregation, and combine adaptive average pooling and max pooling in parallel to obtain the global representation;
[0058] (4) Perform dual-head output, classify the leakage current type of the output head, and the grounding system (TN / TT / IT) of the output head.
[0059] Furthermore, in step S3, a weighted cross-entropy loss function is used to alleviate the class imbalance problem; the OneCycleLR dynamic learning rate scheduling strategy is introduced, including:
[0060] Cross-entropy with class-imbalanced weights is used as the loss for the main task, while standard cross-entropy is used for the auxiliary task. The optimizer is AdamW, combined with OneCycleLR for learning rate scheduling and gradient pruning. The four-dimensional auxiliary features are standardized only using training set statistics to avoid data leakage, and the early stopping criterion is based on the accuracy of the validation set.
[0061] Further, step S4 evaluates the model's performance on the test set, using accuracy and confusion matrix as evaluation metrics, including:
[0062] The accuracy, macro-average precision, recall, and F1 score of the primary task are evaluated on the test set, and a confusion matrix is generated. The accuracy of the secondary task is also given to demonstrate its positive transfer effect.
[0063] In online or offline scenarios, input real-time acquired multi-channel waveforms and four-dimensional auxiliary features, and obtain the discrimination results of leakage current type and grounding system through model forward propagation;
[0064] When the accuracy of the main task or the macro average F1 score does not reach the preset threshold, adjust the learning rate, data augmentation intensity or number of convolution channels, or perform subset selection and retraining within the four-dimensional auxiliary features according to the on-site sensing configuration until the target is met.
[0065] The present invention will be further described below through specific embodiments.
[0066] In one embodiment, the process of the intelligent leakage current type identification method based on CNN and FiLM of the present invention in practical application is as follows:
[0067] 1. Data and Library Environment Preparation
[0068] The dataset utilizes Python and the PyTorch ecosystem, along with NumPy, Pandas, and scikit-learn. Data is indexed in metadata.csv, and waveforms are stored in .npz files. Each sample includes: multi-channel waveforms (va, vb, vc, ia, ib, ic, ires), 3D auxiliary features (humidity, moisture_factor, temperature), primary labels (leakage type: single-phase grounding / arc leakage / DC system leakage), and secondary labels (grounding system: TN / TT / IT). Example sampling frequency and duration: 10kHz, 0.25s.
[0069] 1-1. Divide the collected data into input features and output labels; the input features are waveform tensors of shape [C,T] and three-dimensional auxiliary feature vectors; where C is the number of channels and T is the number of sampling points. The output labels include main labels and auxiliary labels.
[0070] 1-2. The model has a dual-head structure. The main head outputs leakage current type discrimination, and the auxiliary head outputs grounding system discrimination. During training, a multi-task joint optimization is adopted with weighted cross-entropy and auxiliary loss weight λ. During the inference stage, the class label is obtained by the argmax function, and the probability distribution can be obtained by the softmax function as needed.
[0071] 1-3. The data after step 1-1 is further divided into training set, validation set and test set in a ratio of 6:2:2.
[0072] 2. Model Structure and Compilation
[0073] In this embodiment, Python and the PyTorch framework are used to write program code, define functions to build and return model instances, and configure the loss function, optimizer, and learning rate scheduler. The specific steps are as follows:
[0074] 2-1. Import the required libraries. Import torch, torch.nn, torch.optim, torch.utils.data, etc.; import numpy, pandas, and sklearn as needed for data processing and evaluation.
[0075] 2-2. Define a CNN model based on FiLM. Define the model construction parameters, which accept three parameters: input_shape_wave, input_shape_env, and output_size. input_shape_wave represents the shape of the multi-channel waveform input, input_shape_env represents the shape of the auxiliary feature input, denoted as (3,), i.e., the three-dimensional environment features, and output_size represents the output size. The main task (leakage type) has 3 classes, and the auxiliary task (grounding system) has 3 classes, denoted as (3,3).
[0076] 2-3. Input Layer Setup. Tensor input is used to receive multi-channel voltage / current sequences as the main input to the model (shape (C,T)), while simultaneously receiving 3D auxiliary feature vectors as conditional input. For example, each waveform length T ≈ 10000Hz × 0.25s = 2500 sampling points;
[0077] 2-4. Feature Encoding and Conditional Fusion Structure. A two-stage residual one-dimensional convolutional block is used to encode the signal, and FiLM conditional modulation is introduced after each convolutional stage to achieve adaptive feature fusion based on operating conditions.
[0078] 2-4-1, First-level residual convolutional block: The number of channels changes from C to 64, the kernel length k = 7, and it includes one-dimensional convolution Conv1d + group normalization GroupNorm + activation function GELU + random deactivation layer Dropout and residual shortcut;
[0079] 2-4-2, FiLM Conditional Modulation-1: Using 3D auxiliary features, channel-level scaling / translation parameters (γ, β) are generated through a multilayer perceptron (MLP). The convolutional features are then subjected to a channel-level affine transformation as follows:
[0080] x′=(1+γ)⊙x+β
[0081] Where x represents the input feature of the FiLM module; γ represents the scaling factor, used to scale the intensity of each channel of the input feature x; and β represents the offset factor, used to offset the baseline of each channel of the input feature x.
[0082] 2-4-3. Second-level residual convolutional block: number of channels 64→128, kernel length k=5, also using residual structure;
[0083] 2-4-4, FiLM Conditional Modulation-2: The 128-channel features are conditionalized again by generating (γ, β) with the same four-dimensional auxiliary features through another set of MLPs;
[0084] 2-4-5. Feature aggregation: Adaptive average pooling (AdaptiveAvgPool1d(1)) and adaptive max pooling (AdaptiveMaxPoolld(1)) are used in parallel to compress the temporal dimension to 1. The two are concatenated to form a 256-dimensional global representation, which is used as the input of the classification head.
[0085] 2-5. Dual-head output and activation settings. This task is divided into a main task and a secondary task. The main task has 3 classification heads, and the secondary task has 3 classification heads. Cross-entropy loss is used during training, and there is no need to explicitly apply the softmax function in the forward pass; if probability is required during the inference phase, the softmax function can be applied to the logits function.
[0086] 2-6. Model Construction and Compilation. The model is constructed using the data obtained from the input layer and the classification results output by the output layer; the model is compiled using the cross-entropy loss function and the AdamW optimizer, with accuracy as the evaluation metric.
[0087] 2-7. Return the model and provide input / output examples.
[0088] 3. A multi-task joint learning approach is adopted, with the main task being a three-class classification of leakage current types and the auxiliary task being a three-class classification of grounding systems. End-to-end training is achieved through weighted cross-entropy and the weight coefficients of the auxiliary task, improving the model's robustness and generalization ability under complex operating conditions. The specific steps are as follows:
[0089] 3-1. Import the required libraries, including torch, torch.nn, torch.optim, torch.utils.data, and sklearn (for hierarchical partitioning and index calculation).
[0090] 3-2. Based on metadata.csv, read the sample index and perform hierarchical partitioning according to leakage type to obtain training set / validation set / test set; use only the training set to calculate the mean and standard deviation of the three-dimensional auxiliary features, and perform consistent standardization on the three (train / validation / test); construct DataLoader (e.g., training batch size = 32, validation and test are not shuffled).
[0091] 3-3. Configure the model and loss function, and instantiate the CNN+FiLM dual-head model. The main task loss function uses weighted cross-entropy (class weights are adaptively calculated based on the frequency of the training set), and the auxiliary task loss uses standard cross-entropy; the total loss is defined as:
[0092]
[0093] Where L is the total loss function, used to jointly optimize the main task and auxiliary tasks; CE clsThe main task loss is the cross-entropy loss function, which is used for classifying leakage current types. Let y be the probability distribution of the main task category predicted by the model. cls is the true class label for the main task; w is the class weight vector for the main task, used to address class imbalance; λ is the loss weight for the auxiliary task, controlling the proportion of the ground truth classification loss in the total loss; CE gnd The auxiliary task loss is the grounding system classification cross-entropy loss function. The probability distribution of the grounding system predicted by the model; y gnd For auxiliary tasks, use real labels (grounding system real categories).
[0094] 3-4. Optimizer and learning rate: The AdamW optimizer is used, and the OneCycleLR learning rate strategy is employed (e.g., pct_start = 0.2, cosine annealing). To improve stability, gradient clipping is implemented (e.g., clip_grad = 0.5).
[0095] 3-5. Iterate and validate in rounds, assuming 40 rounds, with each round divided into a training phase and a validation phase. Training phase: For each batch, calculate the primary / secondary logits forward, calculate the total loss according to the aforementioned formula and backpropagate, and perform optimizer updates and learning rate scheduling;
[0096] Validation phase: Calculate loss and accuracy on the validation set, using only forward pass and without enabling gradient descent. If the validation set accuracy does not improve within a preset "patience epoch" (e.g., 12 epochs), the process terminates early; save the model state with the best validation accuracy as the final weights.
[0097] 3-6. Save the training output and reproducible records, and record the validation loss, validation accuracy and learning rate for each round to metrics.csv; save the optimal model weight file and configuration parameters for subsequent deployment and comparative experiments; if performing ablation experiments, save result.json and ablation_summary.csv for each group.
[0098] 4. Objectively evaluate the primary task on the test set, and report the performance of the auxiliary tasks to verify the positive transfer effect of multiple tasks on the primary task. This specifically includes:
[0099] 4-1. Import the evaluation library, including `classification_report` and `confusion_matrix` from `sklearn.metrics`;
[0100] 4-2. Perform tests and calculate metrics;
[0101] 4-2-1. Prediction Output: Calculate the main task logits forward on the test set samples, and take argmax to obtain the integer class label (0 / 1 / 2). For probability display, apply softmax to logits;
[0102] 4-2-2, True Labels: Integer labels (with encoding consistent with the training phase) are read from the test set metadata;
[0103] 4-2-3. Accuracy: Calculate the overall accuracy (number of correctly predicted samples / total number of samples);
[0104] 4-2-4. Confusion Matrix: Generate confusion matrices for the three types of leakage current and save them as data files (e.g., cm_cnn.npy) for visualization;
[0105] 4-2-5. Macro Average Indicators: Provides macro averages Precision / Recall / F1, used to measure class balance performance.
[0106] Practical applications show that this invention, employing a CNN and FiLM-based architecture, can fully utilize the local patterns and global trend features of multi-channel voltage and current waveforms. It also incorporates auxiliary features such as humidity, temperature, and environmental noise to adaptively modulate the network's internal features, thereby achieving high-precision leakage current type identification in complex operating conditions and low signal-to-noise ratio environments. This method differs from traditional leakage current detection schemes based on manual experience thresholds or frequency domain features, which typically fail to effectively utilize the temporal structure information of waveforms and are sensitive to different scenarios and noise levels. Through the stacking design of residual one-dimensional convolutional networks and parallel pooling strategies, the model can extract key features such as transient pulses, arc waveforms, and steady-state leakage currents. The FiLM conditionalization mechanism further adjusts the channel response according to the characteristics of the on-site environment, achieving adaptive representation of multi-condition samples and improving the model's robustness and generalization ability.
[0107] This invention introduces a multi-task joint learning strategy, simultaneously training the main task (leakage current type classification) and the auxiliary task (grounding system identification). Information from the auxiliary task provides positive transfer to the main task during the feature extraction stage, enabling the model to maintain stable performance under limited sample sizes and varying distribution scenarios. This design differs from traditional single-task models or fixed-parameter classifiers, allowing for rapid adaptation to different sites, seasons, or grounding methods, thus reducing the risk of false alarms and false negatives.
[0108] The weighted cross-entropy loss and weight balancing parameter λ mechanism employed in this invention effectively mitigate training bias caused by class imbalance in leakage current samples. Combined with OneCycleLR learning rate scheduling and gradient pruning strategies, it achieves rapid convergence and training stability. Compared to complex recurrent networks or meta-learning optimizers, the network structure of this invention is lightweight and computationally inexpensive, enabling real-time deployment on embedded devices or edge computing nodes, thus meeting the speed and reliability requirements of power system operation.
[0109] This invention proposes a solution that can classify leakage current types and identify grounding methods in real time and accurately in complex electrical environments by combining techniques such as CNN, conditional feature fusion, and multi-task joint optimization. This method combines high accuracy, strong robustness, and low computational cost, significantly improving the intelligence level of leakage current detection and alarm in power systems, and is of great significance for the safe operation of the power grid, equipment maintenance, and operational efficiency.
[0110] This invention achieves high-precision real-time identification of leakage current types under different grounding methods and complex operating conditions by combining deep learning, conditional feature modulation, and multi-task joint optimization. In the measured data, the average identification accuracy of the method in this embodiment is 95.6%. The identification comparison results with the comparative scheme on the test set are shown in Table 1 below, and the performance curves on the test set are attached. Figure 2-7 As shown in Table 1, the recognition comparison results of the comparison scheme on the test set are as follows.
[0111] Performance indicators SVM CNN (without environmental features) This patented method accuracy 86.67% 90% 95% Accuracy 89.51% 92.31% 95.65% Recall rate 86.67% 90% 95% F1 score 86.76% 90.25% 94.97%
[0112] In summary, this invention provides an intelligent leakage current type identification method based on CNN and FiLM, comprising the following steps: S1, collecting real-time operating data of typical power supply areas to obtain leakage current waveforms and related environmental characteristic parameters under different operating conditions, and constructing an original leakage current sample dataset; S2, constructing a CNN-based leakage current classification model, introducing a FiLM conditional modulation module, and using a multi-task learning framework at the end of the network, with the main task being leakage current type identification and the auxiliary task being grounding system discrimination, to enhance the discriminative power of feature representation; S3, using a weighted cross-entropy loss function to alleviate the class sample imbalance problem; introducing a OneCycleLR dynamic learning rate scheduling strategy to improve convergence efficiency and prevent overfitting, combined with early stopping (Early Stop)... The Stopping strategy automatically saves the model parameters that perform best on the validation set; S4, evaluate the model's performance on the test set, using accuracy and confusion matrix as evaluation metrics; Through the above methods, this invention provides an intelligent leakage current type identification method based on CNN and FiLM, which uses environmental factors (humidity, temperature, grounding resistance, noise level, power factor, etc.) as conditional vectors to perform FiLM conditional modulation on the waveform channels, and introduces multi-task joint learning to promote the feature representation to converge consistently with both operating condition changes and mechanism labels; it simplifies the feature extraction process, using the original multi-channel waveform as input, and in conjunction with... Standardization (z-score) and lightweight data augmentation (Gaussian noise, waveform mixup, and environment vector mixup) enable the network to automatically learn key time-frequency / morphological features that distinguish different leakage types, avoiding tedious manual feature engineering and subjective threshold settings. Conditional modulation (FiLM) explicitly encodes operating condition differences into the feature channels, allowing the model to quickly adapt to new scenarios with a small amount of new environmental data or gradient updates. This achieves high-precision identification of multiple types of faults, such as single-phase grounding, arc-type leakage, and DC system leakage, and can adapt to different grounding systems, improving the accuracy and robustness of system diagnosis.
[0113] In the description of this specification, references to terms such as "an embodiment," "example," "specific example," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0114] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention.
Claims
1. A method for leakage current type intelligent identification based on CNN and FiLM, characterized in that, The method comprises the following steps: S1, collecting real-time operation data of a typical power supply station area, obtaining leakage current waveforms and related environmental characteristic parameters under different working conditions, and constructing an original leakage current sample data set; S2, constructing a leakage current classification model based on CNN, introducing a FiLM conditional modulation module, and using a multi-task learning framework at the tail of the network, with the main task being leakage current type identification and the auxiliary task being grounding system discrimination; S3, using a weighted cross-entropy loss function to alleviate the class sample imbalance problem; introducing a OneCycleLR dynamic learning rate scheduling strategy, and cooperating with an early stopping strategy to automatically save the model parameters with the best performance on the validation set; S4, evaluating the performance of the model on the test set, and using accuracy and a confusion matrix as evaluation indicators.
2. The CNN and FiLM based leakage current type intelligent identification method according to claim 1, wherein, The step S1 of collecting real-time operation data of a typical power supply station area, obtaining leakage current waveforms and related environmental characteristic parameters under different working conditions, and constructing an original leakage current sample data set further comprises: The data set is preprocessed and labeled, and is divided into a training set, a validation set and a test set according to a certain proportion, thereby providing basic data support for subsequent model training and verification; Three-phase voltage, current and zero-sequence current constitute a multi-channel waveform, auxiliary characteristic fields and label fields aligned with the sample are read, and each waveform channel is subjected to channel-by-channel standardization, superimposed with small amplitude Gaussian noise and waveform Mixup to enhance robustness.
3. The CNN and FiLM based leakage current type intelligent identification method of claim 2, wherein, The step S1 of collecting real-time operation data of a typical power supply station area, obtaining leakage current waveforms and related environmental characteristic parameters under different working conditions, and constructing an original leakage current sample data set further comprises: The sample is divided into input features and output labels, the input includes multi-channel time series waveforms and four-dimensional auxiliary features; the output label includes the main task of leakage type and the auxiliary task of grounding system; a hierarchical strategy is adopted to divide the data into a training set, a validation set and a test set, wherein the training set is 60%, the validation set is 20%, and the test set is 20%; the output label is encoded by integers.
4. The CNN and FiLM based leakage current type intelligent identification method of claim 1, wherein, The step S2 of constructing a leakage current classification model based on CNN and introducing a FiLM conditional modulation module comprises: A network structure containing residual one-dimensional convolution blocks and FiLM is built, and the specific steps are as follows, (1) performing backbone extraction, including two levels of residual convolution blocks with a kernel length of 5-7, emphasizing short-time local patterns and transients; (2) performing conditional modulation, taking four-dimensional auxiliary features as input, generating channel-level scaling or translation parameters (γ, β) through a multi-layer perceptron, and performing channel-level affine transformation on the convolution features; (3) performing feature aggregation, with adaptive average pooling and maximum pooling in parallel, and obtaining global representation by concatenation; (4) performing double-head output, with the classification head outputting the leakage type and the auxiliary head outputting the grounding system.
5. The CNN and FiLM based leakage current type intelligent identification method of claim 1, wherein, The step S3 of using a weighted cross-entropy loss function to alleviate the class sample imbalance problem; introducing a OneCycleLR dynamic learning rate scheduling strategy comprises: Cross-entropy with class imbalance weight is used as the main task loss, and standard cross-entropy is used for the auxiliary task; the optimizer uses AdamW, cooperates with OneCycleLR learning rate scheduling and gradient clipping; only the training set is used to standardize the four-dimensional auxiliary features to avoid data leakage, and the validation set accuracy is used as the early stopping criterion.
6. The CNN and FiLM based leakage current type intelligent identification method of claim 1, wherein, The step S4 evaluates the performance of the model on the test set, using accuracy and confusion matrix as evaluation indexes, including: Evaluating the main task accuracy, macro-averaged precision, recall, F1 on the test set, and generating a confusion matrix; At the same time, the accuracy of the auxiliary task is given to prove its positive transfer effect; In online or offline scenarios, input real-time collected multi-channel waveforms and four-dimensional auxiliary features, and get the discrimination results of the type of electric leakage and grounding system through forward modeling; When the main task accuracy or macro-averaged F1 does not reach the preset threshold, adjust the learning rate, data enhancement strength or convolution channel number, or select a subset in the four-dimensional auxiliary features according to the on-site sensor configuration and retrain until the indicators meet the standards.