A training method applied to construction of an AI foundation of a power system

By constructing a voltage time series dataset of a power system, a flicker detection model is established using a long short-term memory neural network and an attention mechanism. The model structure is optimized through knowledge distillation and model pruning, which solves the adaptability and resource constraints of flicker detection in power systems and enables real-time detection and early warning on edge devices.

CN119513650BActive Publication Date: 2025-12-09CHINA SOUTHERN POWER GRID COMPANY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411471501.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-12-09
Estimated Expiration
2044-10-21

AI Technical Summary

Technical Problem

AI models for flicker detection in power systems are difficult to adapt to different scenarios, and insufficient training data and complex model structures increase the difficulty of deployment, resulting in insufficient detection accuracy and efficiency.

Method used

A voltage time series dataset was constructed by high-frequency sampling and adaptive quantization. Feature vectors were extracted by combining wavelet denoising and maximum-minimum normalization. A detection model was built using a long short-term memory neural network and an attention mechanism. The model structure was optimized by knowledge distillation and model pruning methods to adapt to the resource constraints of edge devices.

Benefits of technology

It enables real-time detection and early warning of flicker on edge devices, improving the safe and stable operation of the power system and reducing model complexity and data dependence.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119513650B_ABST
    Figure CN119513650B_ABST
Patent Text Reader

Abstract

The application provides a training method applied to construction of an AI foundation of a power system, comprising: obtaining voltage data in the power system, converting the voltage data into digital signals through high-frequency sampling and adaptive quantization processing, so as to construct a voltage time series data set containing harmonic content and voltage change amplitude and frequency characteristics; inputting large-scale power system historical data into an established power equipment flicker detection model for pre-training, and fine-tuning the pre-training model by using a small amount of labeled data, so that the model can adapt to specific scenes caused by transformer and generator flicker due to voltage fluctuation; on the basis of model distillation, using model pruning methods, including structured sparse pruning and filter pruning, to compress the parameter quantity and calculation complexity of the model, wherein by setting a sparsity threshold, neurons and connections essential to the task are retained, and redundant structures are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to the field of information technology, and in particular to a training method applied to constructing an AI foundation of a power system. BACKGROUND

[0002] In a power system, voltage flicker is a common power quality problem, which is caused by power supply voltage fluctuation and leads to light source brightness change. Flicker will have adverse effects on electrical equipment and human visual perception, so it is necessary to detect and identify flicker abnormalities in a timely and accurate manner. Traditional flicker detection methods rely on dedicated flicker meters and other equipment, but these devices are costly and lack flexibility. With the development of artificial intelligence technology, AI-based anomaly detection methods provide a new way to solve this problem. However, the flicker scene in the power system is complex and diverse, and the characteristics of flicker in different scenes differ greatly, making it difficult for a general AI model to adapt to all scenarios. In order to improve the accuracy and efficiency of flicker anomaly detection, it is necessary to construct specialized AI models for specific sub-scenes. However, training these sub-scene models often faces the problem of insufficient available data, and complex model structures also increase the difficulty of deployment and application. How to simplify the model structure and reduce the dependence on training data while ensuring detection performance is a key technical challenge in AI-based flicker anomaly detection in power systems. SUMMARY

[0003] The application provides a training method applied to constructing an AI foundation of a power system, mainly comprising:

[0004] Obtain voltage data in the power system, convert the voltage data into digital signals through high-frequency sampling and adaptive quantization processing, and construct a voltage time series data set containing harmonic content and voltage change amplitude and frequency characteristics;

[0005] Perform wavelet denoising and maximum-minimum value normalization on the voltage time series data, extract feature vectors reflecting short-time flicker and long-time flicker of power system loss rise according to flicker amplitude judgment and flicker frequency analysis, and if the voltage change amplitude exceeds the preset threshold and the frequency is high, it is judged that there is a serious flicker risk;

[0006] Use a long short-term memory neural network for anomaly detection, train the feature vectors reflecting short-time flicker and long-time flicker of power system loss rise, and establish a power equipment flicker detection model that can judge the severity of flicker. In the training process, an attention mechanism is introduced to enhance the model's ability to capture key features including noise levels;

[0007] The established power equipment flicker detection model was pre-trained on large-scale historical power system data, and a small amount of labeled data was used to fine-tune the pre-trained model so that the model could adapt to specific scenarios where voltage fluctuations cause flicker in transformers and generators.

[0008] By employing the knowledge distillation method, the knowledge of the pre-trained power equipment flicker detection model is transferred to a small, simple model. Through soft-label distillation training, the small, simple model inherits the flicker feature recognition capability of the complex model, and the prediction accuracy approaches that of the original large model, thus meeting the resource constraints of edge devices.

[0009] Based on model distillation, model pruning methods, including structured sparse pruning and filter pruning, are used to compress the number of model parameters and computational complexity. Specifically, by setting a sparsity threshold, neurons and connections that are essential to the task are retained, and redundant structures are reduced.

[0010] The trimmed lightweight flicker anomaly detection model was retrained and its parameters were fine-tuned to enable real-time data acquisition and flicker detection on resource-constrained edge devices. The trained lightweight flicker anomaly detection model was then deployed on edge devices in substations and portable power flicker meters to achieve real-time monitoring and early warning of equipment malfunctions and power quality degradation caused by flicker.

[0011] The technical solutions provided by the embodiments of the present invention may include the following beneficial effects:

[0012] This invention discloses a training method for building the foundation of AI in power systems. Addressing the problem of flicker caused by voltage fluctuations in transformers and generators within power systems, this invention first acquires high-frequency sampled voltage data to construct a time-series dataset containing harmonics and voltage variation features. After wavelet denoising and normalization preprocessing, short-term and long-term flicker feature vectors reflecting the increase in system losses are extracted. Then, a flicker detection model is established using a long short-term memory neural network and an attention mechanism, and the model's adaptability is improved through pre-training and fine-tuning. To meet the resource constraints of edge devices, this invention employs knowledge distillation to transfer knowledge from complex models to lightweight models, and further compresses the model using model pruning and quantization techniques. Finally, the optimized lightweight model is deployed in substation edge devices and portable flicker meters to achieve real-time monitoring and early warning of equipment failures and power quality degradation caused by flicker, thereby improving the safe and stable operation of the power system. Attached Figure Description

[0013] Fig. 1 This is a flowchart of a training method for building the AI ​​foundation of a power system according to the present invention.

[0014] Fig. 2A schematic diagram of a training method applied to constructing an AI foundation of a power system. DETAILED DESCRIPTION

[0015] For a further understanding of the present application, reference will be made to the following detailed description of the application taken in conjunction with the accompanying drawings and embodiments. The following detailed description of the application is provided as an example for the purpose of illustration only. It will be understood by those skilled in the art that the specific example described herein do not limit the application as there are numerous modifications and variations that will be obvious to those skilled in the art. Additionally, it is to be understood that the application can only be limited by the claims. Further, it is to be understood that only the portions of the apparatuses that are pertinent to the application are shown in the drawings.

[0016] As Figs. 1-2 , the training method applied to constructing an AI foundation of a power system can specifically include:

[0017] S101, obtaining voltage data in a power system, converting the voltage data into digital signals through high-frequency sampling and adaptive quantization processing, thereby constructing a voltage time series data set containing harmonic content and voltage change amplitude and frequency characteristics.

[0018] Obtain a voltage signal in a power system, the voltage signal is collected by a high-speed data acquisition card at a preset sampling frequency; convert the voltage signal into a digital signal through an analog-to-digital converter to obtain an original voltage data sequence; perform adaptive quantization processing on the original voltage data sequence, the adaptive quantization processing uses a Lloyd-Max quantizer to dynamically adjust the quantization level according to the statistical characteristics of the original voltage data sequence; calculate the frequency spectrum of the original voltage data sequence using a fast Fourier transform algorithm, and extract harmonic component information from the frequency spectrum; calculate the short-time change rate and fluctuation range of the original voltage data sequence by a sliding window method, the sliding window method uses a preset window size and step; combine wavelet transform to perform multi-layer decomposition on the original voltage data sequence, and identify voltage sudden change events; fuse the time series characteristics of the original voltage data sequence with the harmonic component information to obtain a voltage time series data set.

[0019] Specifically, the voltage data acquisition parameters are set according to the operating characteristics of the power system, a high-speed data acquisition card is used to obtain voltage signals at a sampling frequency of 10 kHz, and a 16-bit analog-to-digital converter is used to convert the analog signals into digital signals to obtain the original voltage data sequence. The original voltage data sequence is subjected to adaptive quantization processing, the Lloyd-Max quantizer is used to dynamically adjust the quantization level according to the statistical characteristics of the voltage data, the optimal quantization level is determined by comparing the voltage difference between adjacent sampling points with the preset threshold of 0.1% rated voltage, and the accurate digital representation of the voltage data is realized. The quantized voltage data is subjected to harmonic analysis, the frequency spectrum of the voltage signal is calculated using the fast Fourier transform algorithm, the number of sampling points is set to 8192, the Hanning window function is selected, the amplitude and phase information of the fundamental wave and the 2-50th harmonic components are extracted from the frequency spectrum, the total harmonic distortion rate and the harmonic content rate of each harmonic are calculated, and the voltage data set containing the harmonic content characteristics is constructed. The voltage data set is subjected to time series feature extraction, the voltage short-time change rate and the fluctuation range are calculated by the sliding window method, the window size is set to 10 power supply periods, the step size is 1 power supply period, the voltage sudden change event is identified by 4-layer decomposition using the db4 wavelet transform, the frequency is calculated using the zero-crossing detection method, and the voltage amplitude change is extracted using the peak detection algorithm. The extracted time series features and harmonic features are fused to form a complete voltage time series data set. The power system voltage data acquisition uses a PCI-6259 high-speed data acquisition card with a sampling frequency of 10 kHz and a sampling accuracy of 16 bits. The acquisition card is connected to the output end of the voltage transformer and transmits analog signals through the BNC interface. The data acquisition software is programmed using LabVIEW, the sampling time is set to 1 minute, and 600,000 sampling points of original voltage data sequence are obtained. The adaptive quantization processing uses the Lloyd-Max quantizer, the probability density function of the original data is first calculated, and the initial quantization level is set to 256. Through iterative optimization, the quantization threshold and the reconstruction level are adjusted until the mean square quantization error is less than 0.01%. The voltage difference between adjacent sampling points is compared with the preset threshold of 0.1% rated voltage, such as 0.23V, if it is greater than the threshold, the local quantization level is increased, and finally the quantized voltage data is obtained. The fast Fourier transform algorithm is used for harmonic analysis, 8192 data points are selected, and the Hanning window function is applied to reduce spectral leakage. The frequency spectrum in the range of 0-5000 Hz is calculated, and the amplitude and phase of the 50 Hz fundamental wave and the 2-50th harmonic components are extracted. The total harmonic distortion rate THD and the harmonic content rate of each harmonic are calculated, such as the third harmonic content rate of 1.5% and the fifth harmonic content rate of 2.1%. The time series feature extraction uses a sliding window size of 10 power supply periods, such as 200 ms, and a step size of 1 period, such as 20 ms. The voltage mean, standard deviation, maximum and minimum values are calculated in each window. The db4 wavelet is used for 4-layer wavelet decomposition, and the voltage sudden change event is identified by comparing the sudden change degree of different scale coefficients.The zero-crossing detection method is used for frequency calculation, taking the number of sampling points between two adjacent rising zero-crossing points, dividing by the sampling frequency to get the period, and taking the reciprocal to get the frequency value. The peak detection algorithm uses the local maximum value method, finds the maximum sampling point in each cycle as the peak value, and calculates the deviation of the peak value from the rated voltage to get the voltage variation amplitude. Finally, the harmonic features, time series features, frequency and amplitude variation information are integrated to form a complete voltage time series dataset containing fields such as timestamp, effective value, frequency, harmonic content, THD, and voltage variation rate.

[0020] S102, wavelet denoising and maximum minimum value normalization are performed on the voltage time series data, and the characteristic vectors reflecting the short-time flicker and long-time flicker reflecting the power system loss increase are extracted according to the flicker amplitude judgment and flicker frequency analysis. If the voltage variation amplitude exceeds the preset threshold and the frequency is high, it is judged that there is a serious flicker risk.

[0021] According to the voltage time series data, wavelet denoising processing is performed, db4 wavelet basis function is used for wavelet decomposition, high frequency coefficients are denoised by soft threshold function, and denoised voltage data sequence is obtained; maximum minimum value normalization processing is performed on the denoised voltage data sequence, the maximum and minimum values in the sequence are obtained, the voltage data sequence is mapped to a specified interval, and data exceeding the normal range is truncated, to obtain the normalized voltage data sequence; the normalized voltage data sequence is segmented by rectangular window method, the absolute value of the difference between the voltage values of two adjacent sampling points in each window is calculated as the voltage variation amplitude, the number of amplitude variations exceeding the preset threshold is counted as the variation frequency, and the short-time flicker characteristic vector is obtained; the short-time flicker characteristic vector is processed, the five-point method in IEC standard is used to calculate the cumulative probability distribution function, the long-time flicker characteristic vector Plt is extracted, and the active power loss increment during flicker is calculated; if the flicker severity index Pst exceeds the first preset threshold and the long-time flicker characteristic vector Plt exceeds the second preset threshold, or the active power loss increment exceeds the third preset threshold, it is judged that there is a serious flicker risk.

[0022] Specifically, the voltage time series data is subjected to wavelet denoising processing, db4 wavelet basis function is adopted for 5-layer wavelet decomposition, high-frequency coefficients are denoised through a soft threshold function f(x)=sign(x)(|x|-λ)+, wherein λ is a threshold value, and is set to 0.1 times the standard deviation, and the denoised voltage data sequence is reconstructed. The maximum and minimum values in the denoised voltage data sequence are obtained through maximum and minimum value normalization processing, the voltage data is mapped to the interval [0, 1], and the data exceeding the normal range is subjected to truncation processing with the upper limit value being 1.1 times the rated voltage and the lower limit value being 0.9 times the rated voltage, thereby obtaining the normalized voltage data sequence. The flicker amplitude and frequency are calculated according to the normalized voltage data sequence, the voltage data is subjected to segmented processing through a rectangular window method, the window length is set to 10 minutes, the absolute value of the difference between the voltage values of two adjacent sampling points in each window is calculated as the voltage variation amplitude, the number of times of variation amplitudes exceeding 0.1% is counted as the variation frequency, and a short-time flicker feature vector is obtained. The short-time flicker feature vector is processed, the flicker severity index Pst in 10 minutes is calculated, the five-point method in the IEC standard is adopted to calculate the cumulative probability distribution function, the long-time flicker feature vector Plt is extracted, and the active power loss increment ΔP during the flicker is calculated. If Pst exceeds 1.0 and Plt exceeds 0.8, or ΔP exceeds 2% of the rated power, it is judged that there is a serious flicker risk, and the power system loss rises. The voltage time series data is collected at a sampling frequency of 10 kHz, and each 10-minute data segment is formed. The wavelet denoising processing is performed on each data segment, the db4 wavelet function in the PyWavelets library is used for 5-layer wavelet decomposition. The soft threshold function is applied to the high-frequency coefficients, and the threshold value λ is set to 0.1 times the standard deviation of the coefficients in this layer. For example, for the 3rd layer high-frequency coefficients, if the standard deviation is 0.05, then λ=0.005. The denoised data is subjected to maximum and minimum value normalization, and the rated voltage of the power grid is set to 220V, so the upper limit value is 242V and the lower limit value is 198V. The data exceeding the range is subjected to truncation processing, such as 243V being truncated to 242V. The normalized data is used to calculate the flicker features. A 10-minute rectangular window is adopted, the sliding step is 1 minute, and the voltage variation amplitude in the window is calculated. If the absolute value of the voltage difference between adjacent sampling points exceeds 0.22V, which is 0.1% of the rated value, it is recorded as one variation. The number of variations in 10 minutes is counted, such as 300 times. The short-time flicker severity Pst is calculated using the five-point method in the IEC standard, and the weighted sum of P0.1, P1, P3, P10 and P50 is taken. For example, Pst=1.2 is obtained. The long-time flicker severity Plt is calculated for 12 consecutive Pst values, and the formula is the cubic root average value. At the same time, the active power loss increment ΔP during the flicker is calculated, assuming that the rated power is 100MW and ΔP is 2.5MW.If Pst exceeds 1.0 and Plt exceeds 0.8, or ΔP exceeds 2 MW, it is determined that there is a serious flicker risk, indicating that the power system loss increases significantly.

[0023] In S103, a long short-term memory neural network is used for anomaly detection, the feature vectors reflecting short-time flicker and long-time flicker of the power system loss increase are trained, a power equipment flicker detection model capable of judging the severity of flicker is established, and in the training process, an attention mechanism is introduced to enhance the model's ability to capture key features including noise levels.

[0024] A training data set is constructed, which includes feature vectors arranged in chronological order, and each sample contains 24 hours of continuous feature data; according to the training data set, the flicker severity label is set according to the IEC standard, the Pst value is divided into a preset number of grades, and a labeled training sample is obtained; for the labeled training sample, a long short-term memory neural network structure is designed, network parameters are determined through 5-fold cross-validation, and the long short-term memory neural network structure includes an input layer, a hidden layer, and an output layer; an additive attention mechanism is introduced into the long short-term memory neural network to calculate the attention weight of each time step, wherein the attention weight is determined by the current hidden state and the decoder state; the long short-term memory neural network is trained using the back propagation algorithm, a learning rate decay strategy is used, and if the validation set loss does not decrease for 5 consecutive epochs, the training is stopped, and a flicker detection model is obtained.

[0025] Specifically, the training dataset is constructed according to the extracted short and long flicker feature vectors. The feature vectors are arranged in chronological order, and each sample contains 24 hours of continuous feature data, including voltage fluctuation amplitude, frequency change rate, harmonic content, and power factor. The flicker severity label is set according to the IEC standard, with Pst values of 0-0.5, 0.5-1.0, 1.0-2.0, and greater than 2.0 corresponding to the four levels of slight, moderate, severe, and extreme. The long and short-term memory neural network structure is designed, and the network parameters are determined through 5-fold cross-validation. The number of input layer nodes is the same as the dimension of the feature vector, the hidden layer contains 128 LSTM units, the output layer is a fully connected layer with 64 neurons and a 4-node softmax layer for predicting flicker severity. The additive attention mechanism is introduced into the long and short-term memory neural network, and the attention weight αt is calculated as softmax(vTtanh(W1ht+W2s+b)), where ht is the current hidden state, s is the decoder state, W1, W2, v, and b are learnable parameters. Higher initial weights are assigned to key features such as voltage fluctuation amplitude and harmonic content to improve the model's ability to capture important features. The long and short-term memory neural network is trained using the backpropagation algorithm, with an initial learning rate of 0.001 and a learning rate decay strategy that decays by 10% every 10 epochs. The batch size is set to 64, and the total training rounds are 200. The model parameters are optimized by minimizing the cross-entropy loss function. The attention weight is introduced into the loss function, L = -Σy_ilog(p_i) + λΣαtlog(αt), where λ is the attention regularization coefficient. The early stopping strategy is used to prevent overfitting, and training is stopped when the validation set loss does not decrease for 5 consecutive epochs. Finally, the prediction probability threshold is set to 0.8, and if the highest class probability output by the model is lower than the threshold, it is determined to be an abnormal sample, and the power equipment flicker detection model that can judge the severity of flicker is obtained. The implementation process of the power system flicker detection model starts with data preprocessing, and the feature vector is extracted from the original voltage data. 60 sample points are collected every hour, including voltage fluctuation amplitude, frequency change rate, harmonic content, and power factor. For example, the feature vector at a certain time may be [0.02, 0.05, 0.03, 0.98], indicating that the voltage fluctuation amplitude is 2% of the rated value, the frequency change rate is 0.05 Hz / s, the total harmonic distortion rate is 3%, and the power factor is 0.98. 24 hours of continuous data form a sample, with a total of 1440 feature points. According to the IEC standard, if the maximum Pst value in this 24-hour period is 1.5, it is labeled as "severe" level. The LSTM network is built using the TensorFlow framework, and the optimal parameters are determined through grid search: 128 LSTM units and 64 fully connected layer neurons. During training, the initial learning rate is set to 0.001, and it decays by 10% every 10 epochs. The batch size is 64, and a total of 200 rounds are trained.The implementation of the additive attention mechanism involves calculating attention weights, initially assigning a weight of 1.5 times to the voltage fluctuation amplitude and harmonic content. During training, the validation set loss is monitored, and when it does not decrease for 5 consecutive epochs, the early stopping mechanism is triggered. The final model achieves an accuracy of 95% on the test set, and for samples with a prediction probability less than 0.8, they are labeled as abnormal and subjected to manual review. This method not only accurately judges the severity of flicker, but also identifies potential abnormal situations, providing strong support for power grid operation and maintenance.

[0026] S104, inputting the established power equipment flicker detection model with large-scale power system historical data for pre-training, and fine-tuning the pre-trained model with a small amount of labeled data, so that the model can adapt to specific scenarios of flicker caused by voltage fluctuation of transformers and generators.

[0027] Obtain large-scale power system historical data, including voltage, current, and power factor; remove outliers in the power system historical data according to the 3σ criterion; extract features from the power system historical data using a pre-set time sliding time window to obtain a pre-training data set; the pre-training data set contains voltage fluctuation amplitude, frequency change rate, harmonic content, and power factor data; construct an autoencoder, which includes a pre-set number of layer convolutional neural networks as an encoder and a decoder; train the autoencoder by minimizing the reconstruction error to obtain a pre-trained model; obtain related data of flicker caused by transformers and generators, including voltage fluctuation amplitude, frequency, duration, and corresponding flicker severity labels; add two fully connected layers and a softmax output layer to the pre-trained model to build a fine-tuned model for flicker detection; use transfer learning method to train the fine-tuned model with the parameters of the pre-trained model as initial values; freeze the pre-set proportion of the pre-trained model parameters, only train the post-set proportion of the parameters and the newly added output layer; add the weight of the transformer and generator related features in the loss function; optimize the parameters of the fine-tuned model through the back propagation algorithm to obtain a detection model that adapts to specific flicker scenarios.

[0028] Specifically, historical data of large-scale power systems, including voltage, current, power factor, and other parameters, are collected. Abnormal values are removed using the 3σ criterion, and features are extracted using a 5-minute sliding time window. A pre-training dataset containing 1 million records is constructed, with each record containing voltage fluctuation amplitude, frequency change rate, harmonic content, and power factor data for 288 time points. An unsupervised learning method is used to encode the pre-training dataset, and a five-layer convolutional neural network is used as the encoder and decoder to construct an autoencoder. The input and output layer node numbers are 288x4, and the hidden layer node numbers are 1024, 512, 256, 512, and 1024, respectively. The autoencoder is trained by minimizing the reconstruction error to obtain a pre-trained model that can represent general characteristics of power systems. For specific scenarios of transformer and generator-induced flicker, 10,000 relevant data are collected and labeled, including voltage fluctuation amplitude, frequency, duration, and corresponding flicker severity labels. According to the IEC standard, flicker severity is divided into four levels: slight, moderate, severe, and extreme. A fine-tuning model for flicker detection is constructed by adding two fully connected layers and a softmax output layer to the pre-trained model. The parameters of the pre-trained model are used as the initial values, and the model is fine-tuned using the transfer learning method. The first 80% of the pre-trained model's layer parameters are frozen, and only the last 20% of the layer parameters and the newly added output layer are trained. The loss function includes weights for transformer and generator-related features, and the model parameters are optimized using the backpropagation algorithm to obtain a detection model that adapts to specific flicker scenarios. The implementation process of the power system flicker detection model begins with the collection and preprocessing of large-scale historical data. One year of operational data is extracted from the grid monitoring system, including voltage, current, and power factor parameters, with a sampling frequency of 1 Hz. Data cleaning is performed using the Pandas library in Python, and the 3σ criterion is applied to remove outliers, such as data points with voltage deviations exceeding ±7%. A 5-minute sliding window is used to extract features, and the mean, standard deviation, maximum, and minimum values within the window are calculated to form 1 million pre-training records. Each record contains 288 time points of four features: voltage fluctuation amplitude, frequency change rate, harmonic content, and power factor. A five-layer convolutional autoencoder is constructed using PyTorch, with an input layer of 1152 nodes, and intermediate layers of 1024, 512, 256, 512, and 1024 nodes, respectively. The output layer is the same as the input layer. The autoencoder is trained by minimizing the reconstruction error using the Adam optimizer, with a learning rate of 0.001, a batch size of 128, and 50 epochs. For transformer and generator flicker scenarios, 10,000 labeled data are collected from 10 substations, including device operating parameters and corresponding flicker levels. According to the IEC standard, flicker levels are divided into four levels: Pst<1 for slight, 1≤Pst<2 for moderate, 2≤Pst<4 for severe, and Pst≥4 for extreme.Two fully connected layers with 128 and 64 nodes respectively and a 4-node softmax output layer are added to the pre-trained model. The model is fine-tuned using the transfer learning method, and the first 80% of the layer parameters are frozen, i.e. only the last convolutional layer, two fully connected layers and the output layer are trained. The transformer excitation current and generator rotor current are given a weight of 1.5 times in the loss function to improve the sensitivity of the model to these key features. Cross-entropy is used as the loss function, the learning rate is set to 0.0001, the batch size is 32, and the model is trained for 100 epochs. The final model achieves an accuracy of 93% on the test set, especially for severe and extreme flicker, with an identification rate of 97%, providing a reliable early warning tool for power grid operation and maintenance.

[0029] In S105, the knowledge of the pre-trained power equipment flicker detection model is transferred to a small and simple model using a knowledge distillation method. Through soft label distillation training, the small and simple model inherits the flicker feature recognition ability of the complex model, and the prediction accuracy approaches that of the original large model, meeting the resource constraints of edge devices.

[0030] A small and simple model structure is designed, which adopts a three-layer fully connected neural network. The number of nodes in the input layer is consistent with the number of input features of the original large model, the number of nodes in the hidden layer is set respectively, and the number of nodes in the output layer corresponds to the number of flicker levels. According to the small and simple model structure, samples are randomly extracted from the original data set as unlabeled data, and the original large model is used to predict these data to obtain soft label output. For the soft label output, a knowledge distillation loss function is defined, which combines cross-entropy loss and Kullback-Leibler divergence. The cross-entropy loss is used to calculate the difference between the output of the small model and the true label, and the KL divergence is used to measure the difference between the output of the small model and the soft label of the large model. The stochastic gradient descent optimizer is used to train the small and simple model structure. By calculating the knowledge distillation loss and performing backpropagation, the model parameters are updated. If the validation set loss does not decrease for consecutive epochs, the training is stopped, and the accuracy and inference time of the small and simple model structure are obtained. It is determined whether the accuracy is not less than a preset proportion of the original large model and whether the inference time is not more than a preset threshold.

[0031] Specifically, a small and simple model structure is designed, a three-layer fully connected neural network is adopted, the number of nodes in the input layer is set to 288, which is consistent with the number of input features of the original large model, the number of nodes in the hidden layer is set to 64 and 32, and the number of nodes in the output layer is 4, corresponding to the number of flicker grades, the activation function uses ReLU function, and the total parameter quantity is controlled within 100,000 to ensure that the model size does not exceed 10 MB. Prepare the knowledge distillation training dataset, randomly extract 50% of the samples from the original dataset as unlabeled data, use the original large model to predict these data, obtain the soft label output, the soft label form is a 4-dimensional probability vector, representing the probability distribution of each flicker grade, and build a distillation dataset containing input features and corresponding soft labels. Define the knowledge distillation loss function, combining cross-entropy loss and Kullback-Leibler divergence, cross-entropy loss is used to calculate the difference between small model output and true label, KL divergence is used to measure the difference between small model output and large model soft label, KL divergence calculation formula is KL(P||Q)=ΣP(x)*log(P(x) / Q(x)), where P is the output of the large model, Q is the output of the small model, and the weight coefficients a=0.7 and b=0.3 are determined by cross-validation. Use the stochastic gradient descent optimizer to train the small and simple model, set the learning rate to 0.01, the batch size to 32, and the number of training rounds to 100, calculate the knowledge distillation loss and perform back propagation in each iteration, update the model parameters, and set the early stopping mechanism, stop training when the validation set loss does not decrease for 5 consecutive epochs, evaluation indicators include accuracy and inference time, accuracy is required to be no less than 95% of the original large model, and inference time is required to be no more than 100 ms. The knowledge distillation process of the power equipment flicker detection model begins with the design of the small model. A three-layer fully connected neural network is built using the PyTorch framework, the input layer is set to 288 nodes, corresponding to the number of features of the original large model, including voltage, current, frequency and other parameters. The hidden layer is set to 64 and 32 nodes respectively, and the output layer is 4 nodes, corresponding to the four flicker grades of slight, moderate, severe and extreme. Use the ReLU activation function, the total parameter quantity is 20,928, and the model size is about 0.8 MB. Randomly extract 500,000 samples from the 1 million original data as unlabeled data, use the pre-trained large model (accuracy 98%) to predict these data and get the soft label. The soft label form is a 4-dimensional probability vector such as [0.05, 0.15, 0.75, 0.05]. Build a knowledge distillation loss function combining cross-entropy loss and KL divergence, determine the optimal weight coefficients a=0.7 and b=0.3 by grid search. Use the SGD optimizer of PyTorch for training, the initial learning rate is 0.01, and it is attenuated by 10% every 20 epochs. The batch size is set to 32, and the early stopping mechanism is triggered when the validation set loss does not decrease for 5 consecutive epochs during the training process.The inference test was performed on the NVIDIA Jetson Nano, with an average inference time of 78 ms and an accuracy of 96.5%, meeting the resource limitation requirements of edge devices. The final small model not only maintains high prediction accuracy, but also greatly reduces the demand for computing resources, providing an efficient flicker detection tool for power system edge computing.

[0032] According to the feature representation extracted from the pre-trained complex model, a transformation operation is performed on the original data, interference factors are simulated, and a large amount of enhanced data is generated. The enhanced data and the original data form a training set, a teacher model of knowledge distillation is constructed, and the key knowledge in the teacher model is refined and concentrated to obtain a lightweight student model. The student model inherits the feature extraction ability of the teacher model, and the model size is greatly reduced.

[0033] The pre-trained complex model is obtained by extracting the preset residual block output as a feature map, which is used for subsequent knowledge distillation. Gaussian noise, random rotation, scaling and translation transformation operations are performed on the original data to obtain an enhanced data set. The enhanced data set and the original data are merged according to a preset ratio to construct a knowledge distillation training set. A deep residual network is used as a teacher model according to the knowledge distillation training set, and the teacher model includes a preset number of convolution layers. A lightweight student model structure is designed, which uses a depth separable convolution network and includes a preset number of depth separable convolution layers and a preset number of fully connected layers. Knowledge distillation is performed through soft labels and feature matching, and the soft labels are the class probability distribution output by the teacher model. The intermediate layer feature map of the teacher model is extracted, and the mean square error is calculated with the corresponding layer feature map of the student model. The student model is trained by combining the classification loss and the feature matching loss. A channel attention mechanism is used to highlight important features, and a squeeze-and-excitation module is added after each convolution layer of the student model. If the squeeze-and-excitation module is added, the feature channel weight is adaptively adjusted.

[0034] Specifically, the feature representation is extracted from the pre-trained complex model, and the outputs of the 10th, 20th, 30th and 40th layers are selected as the feature maps. Gaussian noise with a mean of 0 and a standard deviation of 0.01, random rotation with a range of ± 5 degrees, scaling with a range of 0.9-1.1 times, and translation with a range of ± 5 pixels are applied to the original data to simulate various disturbance factors in the power system and generate an enhanced data set 10 times larger than the original data. The enhanced data and the original data are merged in a ratio of 7:3 to construct a training set for knowledge distillation. A deep residual network is used as the teacher model, which contains 50 convolutional layers, including 16 residual blocks, each containing two 3x3 convolutional layers and a short circuit connection. Finally, a global average pooling layer is connected. The input layer is set to a tensor of 288x4, corresponding to 24 hours of voltage, current, frequency and phase data. A lightweight student model structure is designed, which uses a depth separable convolutional network containing 8 depth separable convolutional layers with a kernel size of 3x3 and channel numbers of 32, 64, 128, 256, 256, 512, 512, and 1024, respectively, and a fully connected layer with 128 nodes. The input layer of the student model is consistent with the teacher model, and the output layer has 4 nodes corresponding to the flicker level classification. The first 4 layers of the student model correspond to the 10th, 20th, 30th and 40th layers of the teacher model for feature matching. Knowledge distillation is performed through soft labels and feature matching. The class probability distribution output by the teacher model is used as a soft label, and the feature maps of the intermediate layers of the teacher model are extracted and compared with the feature maps of the corresponding layers of the student model to calculate the mean square error. The classification loss, such as cross-entropy, and the feature matching loss, such as mean square error, are combined, and the loss function weights are set to 0.7 and 0.3 to train the student model. Channel attention mechanism is used to highlight important features. A squeeze-and-excitation module is added after each convolutional layer in the student model to adaptively adjust the weights of the feature channels.

[0035] 36x36x128, 18x18x256 and 9x9x512. The original 1 million power data were augmented by applying Gaussian noise with mean 0 and standard deviation 0.01, random rotation with a range of ±5 degrees, scaling with a range of 0.9-1.1 times and translation with a range of ±5 pixels, generating 10 million augmented data. The augmented data were mixed with the original data at a ratio of 7:3 to construct a 770 million training set. The teacher model was a 50-layer ResNet containing 16 residual blocks, with an input of a 288x4 tensor corresponding to 24-hour voltage, current, frequency and phase data. The student model used a MobileNetV2 structure containing 8 depthwise separable convolution layers with the number of channels increasing from 32 to 1024, and finally a fully connected layer with 128 nodes. During the knowledge distillation process, the softmax output of the teacher model was used as a soft label, and the mean square error was calculated by comparing the feature maps of the 10th, 20th, 30th and 40th layers of the teacher model with those of the 2nd, 4th, 6th and 8th layers of the student model. The loss function combined cross-entropy with a weight of 0.7 and feature matching loss with a weight of 0.3. SE modules were added after each layer of the student model,

[0036] The compression ratio was 16, and the feature importance was adaptively adjusted. The model was trained for 100 epochs, with an initial learning rate of 0.01 and a decay of 10 times every 30 epochs. The final student model achieved an accuracy of 96.5% on the test set, with a model size of 5.8 MB, a reduction from 97 MB of the teacher model, and an inference time of 18 ms, a reduction from 120 ms, achieving efficient and accurate flicker detection.

[0037] S106, on the basis of model distillation, a model pruning method is used, including structured sparse pruning and filter pruning, to compress the parameter quantity and computational complexity of the model, wherein by setting a sparsity threshold, neurons and connections that are crucial to the task are retained, and redundant structures are pruned.

[0038] An algorithm based on Fisher information is used to calculate the degree of influence of each neuron and connection on the model output, which calculates the Fisher information matrix by estimating the second moment of the gradient of the loss function with respect to the parameters; the neurons and connections are sorted according to the degree of influence, and the retention ratio is set to 70% of the total number of neurons and connections; a gradient-based structured sparse pruning method is used to introduce an L1 regularization term in the training process, and the loss function is modified as L = L original+ lambda ||w||1, where lambda is a penalty factor; performing filter pruning on the convolutional layer, calculating an importance score of each filter, adopting an evaluation method based on feature map energy, the formula of feature map energy being E = ||F||2, where F is a feature map; retaining the top 60% of filters according to the importance score, deleting the remaining filters and their corresponding feature map channels; reconstructing and fine-tuning the pruned model, reconstructing the network structure according to the retained neurons and filters, and adopting a layer-by-layer fine-tuning strategy to unfreeze one layer at a time from the output layer to the input layer; evaluating the model performance through the accuracy and F1 score on the validation set, stopping fine-tuning when the performance no longer improves for a preset number of consecutive periods, and determining the final model structure.

[0039] Specifically, the student model after knowledge distillation is subjected to sensitivity analysis, an algorithm based on Fisher information is adopted to calculate the influence degree of each neuron and connection on the model output, specifically by calculating the second moment estimation Fisher information matrix of the parameter on the loss function gradient, the neurons and connections are sorted according to the influence degree, the retention ratio is set to 70%, and the target of structured sparse pruning is determined. A structured sparse pruning method based on gradient is adopted, an L1 regularization term is introduced in the training process, and the loss function is modified as L = L original+ λ||w||1, where λ is a penalty factor set to 0.0001, to sparsify neuron weights, and iterative training for 50 cycles, with neurons whose absolute weights are less than 0.001 being set to zero every 10 cycles. Filter pruning is performed on the convolutional layers, with the importance score of each filter being calculated, using an evaluation method based on feature map energy, with the formula for feature map energy being E = ||F||2, where F is a feature map, with the top 60% of filters being retained and the remaining filters and their corresponding feature map channels being deleted. The pruned model is then reconstructed and fine-tuned, with the network structure being reconstructed based on the retained neurons and filters, and a layer-by-layer fine-tuning strategy being used, with one layer being unfrozen at a time and trained for 10 cycles, with the learning rate being set to 0.0001, the batch size being 32, and the total training being 100 cycles, with the model performance being evaluated based on the accuracy and F1 score on the validation set, with the fine-tuning being stopped when the performance no longer improves for 5 consecutive cycles, and the final model structure being determined. In the compression process of the power system flicker detection model, first, the sensitivity analysis of the 5.8 MB student model after knowledge distillation is performed. The Fisher information algorithm implemented using PyTorch is used to calculate the influence of each parameter on the loss function. The analysis results show that in the 8-layer depth separable convolutional network, the average Fisher information value of the first 4 layers is 0.0015, while that of the last 4 layers is 0.0068, indicating that the parameters of the latter layers are more important. Based on this result, a retention ratio of 70% is set, with a focus on retaining the neurons and connections of the last 4 layers. Then, structured sparse pruning is performed, with an L1 regularization term being added to the original cross-entropy loss, with the penalty factor being set to 0.0001. After 50 cycles of iterative training, the number of model parameters is reduced from 1.3 million to 91 million, with the largest reductions being in the 2nd and 3rd layers, reaching 45% and 38%, respectively. Subsequently, filter pruning is performed on the convolutional layers, with the feature map calculation function of TensorFlow being used to evaluate the importance of each filter. The results show that among the 1024 filters, 386 have energy values lower than 50% of the average value, and these filters are deleted. After pruning, the model size is further reduced to 3.2 MB. Finally, model reconstruction and fine-tuning are performed, with a layer-by-layer unfreezing strategy being used, with each layer being trained for 10 cycles, with a total of 100 cycles of fine-tuning being performed. On the validation set, the model accuracy slightly decreases from 96.5% to 95.8%, with the F1 score remaining at 0.94, while the inference time is reduced from 18 ms to 11 ms, achieving the goal of significantly improving efficiency with a slight loss in performance.

[0040] The model quantization method is used to quantize the weights and activation values of the student model from floating-point to low-bit integers, which reduces the computational and storage overhead of the student model while keeping the accuracy loss controllable, and speeds up the inference.

[0041] The weights of the student model are statically quantized, a symmetric linear quantization method is used to map the weights from 32-bit floating-point numbers to 8-bit signed integers, the quantization range is determined according to the absolute maximum value of the weights, and the integer value after quantization is calculated according to the quantization formula. The activation value of the student model is dynamically quantized, the statistical information of the activation value is collected during the inference process, including the mean and the standard deviation, the statistical quantity is updated using the exponential moving average method, and the quantized activation value is calculated according to the statistical quantity and the quantization formula. Quantization-aware training is implemented, the weights and the activation value are quantized during the forward propagation process, the gradient is calculated using a pass-through estimator during back propagation, and the pass-through estimator is implemented by setting the gradient of the quantization operation to 1. The accuracy of the quantized student model is evaluated, the accuracy difference of the model before and after quantization on the test set is calculated, and if the accuracy difference exceeds the preset accuracy loss threshold, a mixed precision quantization strategy is used. For the mixed precision quantization strategy, the layers with high sensitivity are determined by calculating the output change before and after quantization, the layers with high sensitivity are quantized using a higher number of bits such as 16 bits, and the other layers remain quantized at 8 bits, finally obtaining a quantized model that meets the accuracy requirements.

[0042] Specifically, the weights of the student model are statically quantized, and a symmetric linear quantization method is used to map 32-bit floating-point numbers to 8-bit signed integers. The absolute maximum value abs_max of each layer of weights is calculated, and the quantization range is [-abs_max, abs_max]. According to the formula Q = round(F*127 / abs_max), quantization is performed, where F is the floating-point number and Q is the quantized integer value. The activation values of the model are dynamically quantized, and statistical information of the activation values is collected during the inference process, including the mean and standard deviation. The exponential moving average method is used to update the statistics, and the update formula is new_mean = 0.9*old_mean + 0.1*current_mean. The statistics are updated every 100 batches, and the quantization bit number is set to 8 bits. The quantization formula is Q = round((F-mean) / (std*scale_factor)), where the initial value of scale_factor is 1 and is optimized through backpropagation. Quantization-aware training is implemented, and quantization operations are performed on weights and activation values during forward propagation. The gradient is calculated using the Straight-Through Estimator during backpropagation. Specifically, the gradient of the quantization operation is set to 1 during backpropagation. The quantization parameters, including the scaling factor and the bias term, are adjusted gradually during training. The cross-entropy loss function is used, the learning rate is set to 0.0001, and the model accuracy is evaluated on the validation set every 5 cycles for 50 cycles. The accuracy of the quantized model is evaluated and the performance is optimized. The accuracy difference between the pre-quantization and post-quantization models on the test set is calculated. The acceptable accuracy loss threshold is set to 0.5%, and if the threshold is exceeded, a mixed precision quantization strategy is used. For layers with high sensitivity, the output change before and after quantization is calculated to determine the use of higher bits such as 16 bits, and the other layers remain at 8 bits. Finally, a quantized model that meets the accuracy requirements is obtained. In the quantization process of the power system flicker detection model, the 3.2MB student model is first statically quantized. TensorFlowLite tools are used to apply symmetric linear quantization to each layer of weights. Taking the first layer of convolution as an example, the absolute maximum value of the weights is 0.35, and the quantization range is determined as [-0.35, 0.35]. 32-bit floating-point numbers are mapped to the 8-bit signed integer range [-127, 127]. Then, dynamic quantization of activation values is performed. During the inference process of 100 batches, the mean of the first layer output is 0.12 and the standard deviation is 0.08. The exponential moving average method is used to update these statistics, and the initial value of scale_factor is set to 1. In quantization-aware training, quantization operations are performed during forward propagation of each mini-batch, and the Straight-Through Estimator is used for backpropagation. The learning rate is 0.0001, and the accuracy is evaluated on a validation set of 1000 samples every 5 cycles for 50 cycles.The last round of evaluation shows that the accuracy of the quantization model on the test set is 95.3%, which is 0.5% lower than the original model of 95.8%, just reaching the preset threshold. The 6th and 7th layers with larger accuracy loss are quantized to 16 bits, and the other layers remain 8 bits. The final quantized model size is reduced to 0.9MB, and the inference time on RaspberryPi4 is reduced from 11ms to 6ms, achieving the goal of significantly improving efficiency under controllable accuracy loss.

[0043] S107, retrain the cropped lightweight flicker anomaly detection model, fine-tune the model parameters, so that it can realize real-time data acquisition and flicker detection on resource-limited edge devices. Deploy the trained lightweight flicker anomaly detection model on the edge devices of the substation and the portable power flicker meter to realize real-time monitoring and early warning of equipment operation failure and power quality decline caused by flicker.

[0044] For the lightweight flicker anomaly detection model, fine-tune the high-sensitivity post-preset ratio layer parameters, set the learning rate to a preset value, the batch size to a preset value, and the number of training rounds to a preset value; perform mixed precision quantization processing on the fine-tuned lightweight flicker anomaly detection model, using 8-bit integer quantization method for most layers and 16-bit floating point quantization for key layers; collect voltage and current signals through the ADC module, set the sampling frequency to a preset value, and set the first data buffer window and the second data buffer window; extract short-term features according to the first data buffer window and long-term features according to the second data buffer window, the features including voltage fluctuation amplitude, frequency change rate and harmonic content; determine whether the short-term features and long-term features exceed the preset threshold, if the short-term flicker is greater than the first preset value or the long-term flicker is greater than the second preset value, an early warning is triggered; determine whether the power factor is less than a third preset value or the total harmonic distortion rate is greater than a fourth preset value, if so, the power quality is determined to be degraded.

[0045] Specifically, for the pruned lightweight flicker anomaly detection model, transfer learning method is used for retraining. The layers that need to be fine-tuned are determined by layer sensitivity analysis, and the parameters of the last 30% layers with high sensitivity are fine-tuned. The learning rate is set to 0.0001, the batch size is set to 32, the number of training rounds is set to 100, and the Adam optimizer is used to minimize the cross-entropy loss function. The fine-tuned model is quantized with mixed precision, and the 8-bit integer quantization method is used to process most layers, and the 16-bit floating-point quantization is used for key layers such as the output layer. The TensorFlowLite tool is used to generate a quantized model file suitable for edge devices, and the model size is controlled within 1.2MB. The edge device data acquisition and processing module is developed, and Raspberry Pi is used as the edge computing platform. The ADC module is used to collect voltage and current signals, and the sampling frequency is set to 10kHz. Two data buffer windows of 1 second and 10 minutes are set to capture short-term and long-term flicker phenomena. Short-term feature extraction is performed every 100ms, and long-term feature extraction is performed every 10 minutes. The features include voltage fluctuation amplitude, frequency change rate, and harmonic content. The quantized lightweight flicker anomaly detection model is deployed in the edge devices of the substation and the portable power flicker meter. The MQTT protocol is used to realize the communication between the edge devices and the cloud server. The flicker severity threshold is set, and the short-term flicker Pst>1.0 or the long-term flicker Plt>0.8 triggers an early warning. At the same time, the power factor <0.9 or the total harmonic distortion rate >5% is used as an indicator of power quality degradation. When an event exceeding the threshold is detected, an alarm message is sent to the cloud, including timestamp, device ID, flicker severity, and power quality indicators. If the network is disconnected, the data is stored in the local SD card, and the data is uploaded in batches when the network is restored. In the optimization and deployment process of the power system flicker detection model, the sensitivity of the pruned 0.9MB lightweight model is analyzed first. The SHAP(SHapley Additive ex Planations) value is used to calculate the contribution of each layer to the output. The results show that the sensitivity of the last 3 layers, which are fully connected layers, ReLU activation layers, and Softmax layers, is 0.42, 0.35, and 0.23 respectively, which is much higher than that of other layers. Accordingly, the last 30% sensitive layers are fine-tuned, and the Adam optimizer is used with a learning rate of 0.0001. The model is trained for 100 rounds on 1000 samples. After fine-tuning, the accuracy of the model on the validation set is improved from 95.3% to 95.7%. Then, mixed precision quantization is performed, and TensorFlowLite is used to quantize most layers to 8-bit integers, and the sensitive output layer is kept as a 16-bit floating-point number. The final model size is 1.15MB. The model is deployed on Raspberry Pi 4B, and MCP3008 ADC is used to collect 10kHz voltage and current data.The double cache window of 1 second and 10 minutes is set, the short-term window extracts features every 100 ms, and the voltage fluctuation amplitude (standard deviation), frequency change rate and the first 5 harmonic content are calculated; the long-term window extracts cumulative features every 10 minutes. The model inference time is 5.8 ms on average. The PahoMQTT client is used for communication with the cloud, and the Pst>1.0 or Plt>0.8 is set as the flicker warning threshold, and the power factor <0.9 or THD>5% is set as the power quality warning threshold. When the warning is triggered, a JSON message containing the timestamp, device ID such as "VF001", Pst / Plt value, power factor and THD is generated and sent to the cloud. When the network is interrupted, the data is stored in CSV format in the local 16 GB SD card, the network is checked every hour and retransmission is attempted, realizing stable and reliable edge flicker detection and warning.

[0046] The above merely describes the preferred embodiments of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can make equivalent replacements or changes to the technical solutions and the inventive concept of the present application within the technical range disclosed by the present application, which should be covered within the protection scope of the present application.

Claims

1. A training method for building the foundation of AI in power systems, characterized in that, The method includes: Voltage data in the power system is acquired, and through high-frequency sampling and adaptive quantization, the voltage data is converted into digital signals, thereby constructing a voltage time series dataset containing harmonic content and voltage change amplitude and frequency characteristics. Wavelet denoising and maximum / minimum normalization are performed on voltage time series data. Based on flicker amplitude judgment and flicker frequency analysis, feature vectors of short-time flicker and long-time flicker reflecting the increase in power system losses are extracted. If the voltage change amplitude exceeds the preset threshold and the frequency is high, it is judged that there is a serious flicker risk. Anomaly detection is performed using a long short-term memory neural network. Feature vectors of short-term and long-term flicker, which reflect the increase in power system losses, are extracted and trained to establish a flicker detection model for power equipment that can determine the severity of flicker. During the training process, an attention mechanism is introduced to enhance the model's ability to capture key features, including noise level. The established power equipment flicker detection model was pre-trained on large-scale historical power system data, and a small amount of labeled data was used to fine-tune the pre-trained model so that the model could adapt to specific scenarios where voltage fluctuations cause flicker in transformers and generators. By employing the knowledge distillation method, the knowledge of the pre-trained power equipment flicker detection model is transferred to a small, simple model. Through soft-label distillation training, the small, simple model inherits the flicker feature recognition capability of the complex model, and the prediction accuracy approaches that of the original large model, thus meeting the resource constraints of edge devices. Based on model distillation, model pruning methods, including structured sparse pruning and filter pruning, are used to compress the number of model parameters and computational complexity. Specifically, by setting a sparsity threshold, neurons and connections that are essential to the task are retained, and redundant structures are reduced. The trimmed lightweight flicker anomaly detection model was retrained and its parameters were fine-tuned to enable real-time data acquisition and flicker detection on resource-constrained edge devices. The trained lightweight flicker anomaly detection model was then deployed on edge devices in substations and portable power flicker meters to achieve real-time monitoring and early warning of equipment malfunctions and power quality degradation caused by flicker.

2. The method according to claim 1, characterized in that, The process involves acquiring voltage data from the power system, converting the voltage data into digital signals through high-frequency sampling and adaptive quantization, thereby constructing a voltage time-series dataset containing harmonic content and voltage variation amplitude and frequency characteristics, including: The voltage signal in the power system is acquired by a high-speed data acquisition card at a preset sampling frequency; The voltage signal is converted into a digital signal using an analog-to-digital converter to obtain the original voltage data sequence; The original voltage data sequence is subjected to adaptive quantization processing, which uses a Lloyd-Max quantizer to dynamically adjust the quantization level according to the statistical characteristics of the original voltage data sequence. The spectrum of the original voltage data sequence is calculated using the Fast Fourier Transform algorithm, and harmonic component information is extracted from the spectrum. The short-time rate of change and fluctuation range of the original voltage data sequence are calculated using the sliding window method, which employs a preset window size and step size. The original voltage data sequence is decomposed into multiple layers using wavelet transform to identify voltage abrupt events. The time series features of the original voltage data sequence are fused with the harmonic component information to obtain a voltage time series dataset.

3. The method according to claim 1, characterized in that, The voltage time series data is subjected to wavelet denoising and maximum / minimum normalization. Based on flicker amplitude judgment and flicker frequency analysis, feature vectors reflecting the increase in power system losses, including short-term and long-term flicker, are extracted. If the voltage change amplitude exceeds a preset threshold and the frequency is high, a serious flicker risk is judged, including: Wavelet denoising was performed on the voltage time series data. Wavelet decomposition was performed using the db4 wavelet basis function, and the high-frequency coefficients were denoised using a soft thresholding function to obtain the denoised voltage data series. The denoised voltage data sequence is subjected to maximum and minimum value normalization processing to obtain the maximum and minimum values ​​in the sequence, and the voltage data sequence is mapped to a specified interval. Data that exceeds the normal range is truncated to obtain the normalized voltage data sequence. The normalized voltage data sequence is segmented using the rectangular window method. The absolute value of the difference between the voltage values ​​of two adjacent sampling points within each window is calculated as the voltage change amplitude. The number of times the amplitude change exceeds a preset threshold is counted as the change frequency, thus obtaining the short-time flicker feature vector. The short-time flicker feature vector is processed, and the cumulative probability distribution function is calculated using the five-point method in the IEC standard. The long-time flicker feature vector Plt is extracted, and the active power loss increment during the flicker period is calculated. If the flicker severity index Pst exceeds the first preset threshold and the long-term flicker feature vector Plt exceeds the second preset threshold, or the active power loss increment exceeds the third preset threshold, then a serious flicker risk is determined to exist.

4. The method according to claim 1, characterized in that, The aforementioned method employs a Long Short-Term Memory (LSTM) neural network for anomaly detection. It trains the model by extracting feature vectors reflecting short-term and long-term flicker that indicate rising power system losses, establishing a flicker detection model for power equipment capable of assessing flicker severity. During training, an attention mechanism is introduced to enhance the model's ability to capture key features, including noise levels. Construct a training dataset, which includes feature vectors arranged in chronological order, with each sample containing feature data for 24 consecutive hours. Based on the training dataset, flicker severity labels are set according to the IEC standard, and the Pst value is divided into a preset number of levels to obtain labeled training samples. For the labeled training samples, a long short-term memory neural network structure is designed, and the network parameters are determined by 5-fold cross-validation. The long short-term memory neural network structure includes an input layer, a hidden layer, and an output layer. An additive attention mechanism is introduced into the long short-term memory neural network to calculate the attention weight at each time step, where the attention weight is jointly determined by the current hidden state and the decoder state. The long short-term memory neural network is trained using the backpropagation algorithm. A learning rate decay strategy is used. If the validation set loss does not decrease for 5 consecutive epochs, training is stopped to obtain the flicker detection model.

5. The method according to claim 1, characterized in that, The established power equipment flicker detection model is pre-trained on large-scale historical power system data, and fine-tuned using a small amount of labeled data to enable the model to adapt to specific scenarios where voltage fluctuations cause flicker in transformers and generators. This includes: Acquire historical data of a large-scale power system, including voltage, current, and power factor; Remove outliers from the historical power system data according to the 3σ criterion; Features are extracted from the historical data of the power system using a preset time sliding window to obtain a pre-training dataset; The pre-training dataset contains data on voltage fluctuation amplitude, frequency change rate, harmonic content, and power factor. Construct an autoencoder, wherein the autoencoder includes a predetermined number of layers of convolutional neural networks as an encoder and a decoder; The autoencoder is trained by minimizing the reconstruction error to obtain a pre-trained model; Acquire relevant data on flicker caused by transformers and generators, including voltage fluctuation amplitude, frequency, duration, and corresponding flicker severity labels; Two fully connected layers and a softmax output layer are added to the pre-trained model to construct a fine-tuned model for flicker detection; The parameters of the pre-trained model are used as initial values, and the fine-tuned model is trained using a transfer learning method. Freeze the pre-preset proportional layer parameters of the pre-trained model and train only the post-preset proportional layer parameters and the newly added output layer; Weights related to transformer and generator features are added to the loss function; The parameters of the fine-tuned model are optimized by backpropagation algorithm to obtain a detection model adapted to specific flicker scenarios.

6. The method according to claim 1, characterized in that, The method employs knowledge distillation to transfer knowledge from a pre-trained power equipment flicker detection model to a smaller, simpler model. Through soft-label distillation training, the smaller, simpler model inherits the flicker feature recognition capabilities of the complex model, and its prediction accuracy approaches that of the original large model, thus meeting the resource constraints of edge devices. This includes: We designed a small and simple model structure, using a three-layer fully connected neural network. The number of nodes in the input layer is the same as the number of input features in the original large model, the number of nodes in the hidden layer is set separately, and the number of nodes in the output layer corresponds to the number of flash levels. Based on the small and simple model structure, samples are randomly drawn from the original dataset as unlabeled data, and the original large model is used to predict these data to obtain soft label output; For the soft label output, a knowledge distillation loss function is defined, which combines cross-entropy loss and Kullback-Leibler divergence. The cross-entropy loss is used to calculate the difference between the output of the small model and the true label, and the KL divergence is used to measure the difference between the output of the small model and the soft label of the large model. The small, simple model structure is trained using a stochastic gradient descent optimizer, and the model parameters are updated by calculating the knowledge distillation loss and performing backpropagation. If the loss on the validation set no longer decreases after several consecutive epochs, training is stopped, and the accuracy and inference time of the small, simple model structure are obtained. It is then determined whether the accuracy is not lower than the preset proportion of the original large model and whether the inference time does not exceed the preset threshold. It also includes: extracting feature representations from pre-trained complex models, transforming the original data, simulating various interference factors, generating a large amount of augmented data, combining the augmented data with the original data to form a training set, constructing a knowledge distillation teacher model, and obtaining a lightweight student model by refining and condensing the key knowledge in the teacher model. The student model inherits the feature extraction capabilities of the teacher model, and the model size is significantly reduced.

7. The method according to claim 6, characterized in that, The process involves extracting feature representations from a pre-trained complex model, transforming the original data, simulating various interference factors, generating a large amount of augmented data, and combining the augmented data with the original data to form a training set. This sets are then used to construct a knowledge distillation teacher model. By refining and condensing key knowledge from the teacher model, a lightweight student model is obtained. The student model inherits the feature extraction capabilities of the teacher model, and its size is significantly reduced. The output of a preset residual block in a pre-trained complex model is obtained as a feature map, which is used for subsequent knowledge distillation. The original data is subjected to Gaussian noise, random rotation, scaling, and translation transformations to obtain an enhanced dataset. The augmented dataset is merged with the original data according to a preset ratio to construct a knowledge distillation training set. According to the knowledge distillation training set, a deep residual network is used as the teacher model, and the teacher model contains a preset number of convolutional layers. Design a lightweight student model structure, which adopts a depthwise separable convolutional network and includes a preset number of depthwise separable convolutional layers and a preset number of fully connected layers; Knowledge distillation is performed using soft labels and feature matching, where the soft labels are the class probability distributions output by the teacher model. Extract the feature map of the intermediate layer of the teacher model and calculate the mean square error with the corresponding layer feature map of the student model; The student model is trained by combining classification loss and feature matching loss; The channel attention mechanism is used to highlight important features, and a squeeze-and-excitation module is added after each convolutional layer of the student model; If the squeeze-and-excitation module is added, the feature channel weights will be adaptively adjusted.

8. The method according to claim 1, characterized in that, Based on model distillation, model pruning methods, including structured sparse pruning and filter pruning, are used to compress the number of model parameters and computational complexity. Specifically, by setting a sparsity threshold, neurons and connections crucial to the task are retained, and redundant structures are reduced. An algorithm based on Fisher information is used to calculate the influence of each neuron and connection on the model output. The algorithm based on Fisher information estimates the Fisher information matrix by calculating the second moment of the parameters with respect to the gradient of the loss function. The neurons and connections are ranked according to the degree of influence, and the retention ratio is set to 70% of the total number of neurons and connections. A gradient-based structured sparse pruning method is adopted, introducing an L1 regularization term during training to modify the loss function to L=L original +λ||w||1, where λ is the penalty factor; Filter pruning is performed on the convolutional layers, and the importance score of each filter is calculated. An evaluation method based on feature map energy is used, with the feature map energy calculated as E=||F|| 2 Where F is the feature map; Based on the importance score, retain the top 60% of filters and delete the remaining filters and their corresponding feature map channels. The trimmed model is reconstructed and fine-tuned. The network structure is reconstructed based on the retained neurons and filters. A layer-by-layer fine-tuning strategy is adopted, unfreezing one layer at a time from the output layer to the input layer. The model performance is evaluated by the accuracy and F1 score on the validation set. Fine-tuning is stopped when the performance no longer improves after a preset number of consecutive cycles, and the final model structure is determined. It also includes: using model quantization methods to convert the weights and activation values ​​of the student model from floating-point to low-bit integers, thereby reducing the computational and storage overhead of the student model and accelerating inference speed while keeping the loss of precision controllable.

9. The method according to claim 8, characterized in that, The aforementioned model quantization method converts the weights and activation values ​​of the student model from floating-point to low-bit integers. While maintaining controllable precision loss, this reduces the computational and storage overhead of the student model and accelerates inference speed. This includes: The weights of the student model are statically quantized. The symmetric linear quantization method is used to map the weights from 32-bit floating-point numbers to 8-bit signed integers. The quantization range is determined according to the absolute maximum value of the weights, and the quantized integer value is calculated according to the quantization formula. The activation values ​​of the student model are dynamically quantified. Statistical information of the activation values, including the mean and standard deviation, is collected during the inference process. The statistical measures are updated using the exponential moving average method. The quantified activation values ​​are calculated based on the statistical measures and the quantization formula. To achieve quantization-aware training, the weights and activation values ​​are quantized during forward propagation, and a pass-through estimator is used to calculate the gradient during backpropagation. The pass-through estimator is implemented by setting the gradient of the quantization operation to 1. The accuracy of the quantized student model is evaluated, and the difference in accuracy of the model before and after quantization on the test set is calculated. If the difference in accuracy exceeds a preset accuracy loss threshold, a hybrid accuracy quantization strategy is adopted. For the aforementioned mixed-precision quantization strategy, the layer with high sensitivity is determined by calculating the output change before and after quantization. The layer with high sensitivity is quantized using a higher bit depth of 16 bits, while other layers are quantized using 8 bits, thus obtaining a quantization model that meets the accuracy requirements.

10. The method according to claim 1, characterized in that, The lightweight flicker anomaly detection model, after being pruned, is retrained and its parameters are fine-tuned to enable real-time data acquisition and flicker detection on resource-constrained edge devices. The trained lightweight flicker anomaly detection model is then deployed on edge devices in substations and portable power flicker meters to achieve real-time monitoring and early warning of equipment malfunctions and power quality degradation caused by flicker, including: For the lightweight flicker anomaly detection model, the parameters of the highly sensitive post-preset proportional layer are fine-tuned, and the learning rate, batch size, and number of training rounds are set to preset values. The fine-tuned lightweight flicker anomaly detection model is subjected to mixed-precision quantization. Most layers are processed using 8-bit integer quantization, while key layers are quantized using 16-bit floating-point quantization. Voltage and current signals are acquired through the ADC module, the sampling frequency is set to a preset value, and a first data buffer window and a second data buffer window are set. Short-term features are extracted based on the first data cache window, and long-term features are extracted based on the second data cache window. The features include voltage fluctuation amplitude, frequency change rate, and harmonic content. Determine whether short-term and long-term characteristics exceed preset thresholds. If the short-term fluctuation exceeds the first preset value or the long-term fluctuation exceeds the second preset value, an alert is triggered. Determine whether the power factor is less than the third preset value or whether the total harmonic distortion rate is greater than the fourth preset value. If so, determine that the power quality has deteriorated.

Citation Information

Patent Citations

  • Power distribution system network loss prediction method based on long-term and short-term memory network

    CN110659779A

  • Data processing method and data processing device

    CN111291883A