Training method applied to construction of AI foundation of power system
The flicker characteristics of the power system are extracted through high-frequency sampling and adaptive quantization processing, and the detection model is established based on long-term and short-term memory neural network and attention mechanism. The model is optimized through knowledge distillation and model cutting technology, which solves the flicker detection accuracy in the power system. and inefficiency problems, real-time flicker detection on edge devices is achieved.
Patent Information
- Application Number
- CN202411471501.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-10-21
AI Technical Summary
The flicker detection method in the power system has problems with insufficient data and model complexity, which leads to low detection accuracy and efficiency, making it difficult to adapt to the flicker characteristics of different scenarios.
High-frequency sampling and adaptive quantization processing are used to obtain voltage data, flicker features are extracted through wavelet denoising and maximum and minimum value normalization, and flicker detection model is established based on long and short-term memory neural network and attention mechanism, and knowledge distillation and Model cutting technology optimizes the model to adapt to edge device resource limitations.
It improves the accuracy and efficiency of flicker detection, simplifies the model structure, reduces the dependence of training data, and realizes real-time data acquisition and flicker detection on resource-constrained edge devices.
Smart Images

Figure CN119513650A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of information technology, and in particular to a training method for building an AI foundation for a power system. Background Art
[0002] In power systems, voltage flicker is a common power quality problem. It is a change in the brightness of a light source caused by fluctuations in the power supply voltage. Flicker can have adverse effects on electrical equipment and human vision, so it is necessary to detect and identify flicker anomalies in a timely and accurate manner. Traditional flicker detection methods rely on dedicated flicker meters and other equipment, but these devices are expensive and lack flexibility. With the development of artificial intelligence technology, AI-based anomaly detection methods have provided new ideas for solving this problem. However, the flicker scenarios in power systems are complex and diverse, and the characteristics of flicker in different scenarios vary greatly, making it difficult for general AI models to adapt to all scenarios. In order to improve the accuracy and efficiency of flicker anomaly detection, it is necessary to build specialized AI models for specific segmented scenarios. However, training these segmented scenario models often faces the problem of insufficient available data, and the complex model structure also increases 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 facing AI-based power system flicker anomaly detection. Summary of the invention
[0003] The present invention provides a training method for building an AI foundation for a power system, which mainly includes:
[0004] Obtain voltage data in the power system, convert the voltage data into digital signals through high-frequency sampling and adaptive quantization processing, and thus construct a voltage time series data set containing harmonic content and voltage variation amplitude and frequency characteristics;
[0005] The voltage time series data is subjected to wavelet denoising and maximum and minimum value normalization. Based on flicker amplitude judgment and flicker frequency analysis, the characteristic vectors of short-term flicker and long-term 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.
[0006] Long short-term memory neural network is used for anomaly detection. The feature vectors of short-term flicker and long-term flicker that reflect the increase of power system loss are trained to establish a flicker detection model for power equipment that can judge the severity of flicker. During the training process, the attention mechanism is introduced to enhance the model's ability to capture key features including noise level.
[0007] The established power equipment flicker detection model is pre-trained on large-scale power system historical data, and a small amount of labeled data is used to fine-tune the pre-trained model so that the model can adapt to specific scenarios where transformers and generators cause flicker due to voltage fluctuations.
[0008] The knowledge distillation method is used to transfer the knowledge of the pre-trained power equipment flicker detection model to a small and simple model. Through the training method of soft label distillation, the small and simple model inherits the flicker feature recognition ability of the complex model, and the prediction accuracy is close to the original large model, which meets the resource constraints of edge devices.
[0009] Based on model distillation, model pruning methods are used, including structured sparse pruning and filter pruning, to compress the number of model parameters and computational complexity. By setting the sparsity threshold, neurons and connections that are critical to the task are retained and redundant structures are cut.
[0010] The trimmed lightweight flicker anomaly detection model is retrained and the model parameters are fine-tuned to enable real-time data collection and flicker detection on resource-constrained edge devices. The trained lightweight flicker anomaly detection model is deployed in the edge devices of the substation and the portable power flicker meter to achieve real-time monitoring and early warning of equipment operation failures and power quality degradation caused by flicker.
[0011] The technical solution provided by the embodiment of the present invention may have the following beneficial effects:
[0012] The present invention discloses a training method for building an AI foundation for power systems. In response to the problem of flicker caused by transformers and generators due to voltage fluctuations in power systems, the present invention first obtains high-frequency sampled voltage data and constructs a time series data set containing harmonics and voltage change characteristics. 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 adaptability is improved through pre-training and fine-tuning. In order to meet the resource limitations of edge devices, the present invention uses knowledge distillation to migrate complex model knowledge to a lightweight model, and combines model clipping and quantization technology to further compress the model. Finally, the optimized lightweight model is deployed in the substation edge device and portable flicker meter 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 level of the power system. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] Figure 1 The present invention is a flow chart of a training method for building an AI foundation for a power system.
[0014] Figure 2A schematic diagram of a training method for building an AI foundation for a power system according to the present invention. DETAILED DESCRIPTION
[0015] In order to further understand the content of the present invention, the present invention is described in detail in conjunction with the accompanying drawings and embodiments. The present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It is understood that the specific embodiments described herein are only used to explain the relevant inventions, rather than to limit the invention. It is also necessary to explain that, for ease of description, only the parts related to the invention are shown in the accompanying drawings.
[0016] like Figure 1-2 In this embodiment, a training method for building an AI foundation for a power system may specifically include:
[0017] S101. Obtain voltage data in the power system, convert the voltage data into digital signals through high-frequency sampling and adaptive quantization processing, and thus construct a voltage time series data set containing harmonic content and voltage variation amplitude and frequency characteristics.
[0018] The voltage signal in the power system is acquired, and the voltage signal is collected by a high-speed data acquisition card at a preset sampling frequency; the voltage signal is converted into a digital signal by an analog-to-digital converter to obtain an original voltage data sequence; the original voltage data sequence is adaptively quantized, and the adaptive quantization process 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 a fast Fourier transform algorithm, and harmonic component information is extracted from the spectrum; the short-term change rate and fluctuation range of the original voltage data sequence are calculated by a sliding window method, and the sliding window method uses a preset window size and step size; the original voltage data sequence is multi-layered decomposed in combination with a wavelet transform to identify voltage mutation events; the time series characteristics of the original voltage data sequence are fused 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, and the voltage signal is acquired at a sampling frequency of 10kHz using a high-speed data acquisition card. The analog signal is converted into a digital signal through a 16-bit analog-to-digital converter to obtain the original voltage data sequence. The original voltage data sequence is adaptively quantized, and 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 achieved. Harmonic analysis is performed on the quantized voltage data, and the frequency spectrum of the voltage signal is calculated using the fast Fourier transform algorithm. The number of sampling points is set to 8192, and the Hanning window function is selected to extract the amplitude and phase information of the fundamental wave and the 2nd to 50th harmonic components from the frequency spectrum. The total harmonic distortion rate and the content rate of each harmonic are calculated to construct a voltage data set containing harmonic content characteristics. The time series features of the voltage data set are extracted, and the short-term voltage change rate and fluctuation range are calculated by the sliding window method. The window size is set to 10 power supply cycles and the step size is 1 power supply cycle. The voltage mutation events are identified by 4-layer decomposition combined with the db4 wavelet transform. The frequency is calculated by the zero crossing detection method, and the voltage amplitude change is extracted by the peak detection algorithm. The extracted time series features are fused with the harmonic features 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 10kHz and a sampling accuracy of 16 bits. The acquisition card is connected to the output end of the voltage transformer and transmits the analog signal through the BNC interface. The data acquisition software is implemented using LabVIEW programming, and the sampling time is set to 1 minute to obtain the original voltage data sequence of 600,000 sampling points. The adaptive quantization processing uses the Lloyd-Max quantizer. First, the probability density function of the original data is calculated, and the initial quantization level is set to 256. Through iterative optimization, the quantization threshold and reconstruction level are adjusted until the mean square quantization error is less than 0.01%. Compare the voltage difference between adjacent sampling points with the preset threshold 0.1% rated voltage, such as 0.23V. If it is greater than the threshold, increase the local quantization level, and finally obtain the quantized voltage data. Harmonic analysis uses the fast Fourier transform algorithm, selects 8192 data points, and applies the Hanning window function to reduce spectrum leakage. Calculate the spectrum in the range of 0-5000Hz, extract the amplitude and phase of the 50Hz fundamental wave and the 2-50th harmonic components. Calculate the total harmonic distortion rate THD and the content rate of each harmonic, such as the third harmonic content rate is 1.5% and the fifth harmonic content rate is 2.1%. Time series feature extraction uses 10 power supply cycles, such as 200ms, as the sliding window size, and the step size is 1 cycle, such as 20ms. Calculate the voltage mean, standard deviation, maximum and minimum values in each window. Use db4 wavelet for 4-layer wavelet decomposition, and identify voltage mutation events by comparing the mutation degree of different scale coefficients.The zero-crossing detection method is used for frequency calculation. The number of sampling points between two adjacent rising zero-crossing points is taken, divided by the sampling frequency to get the period, and the reciprocal is taken to get the frequency value. The peak detection algorithm uses the local maximum method to find the maximum sampling point as the peak value in each cycle, and calculates the deviation between the peak value and the rated voltage to get the voltage change amplitude. Finally, the harmonic characteristics, time series characteristics, frequency and amplitude change information are integrated to form a complete voltage time series data set containing fields such as timestamp, effective value, frequency, harmonic content of each order, THD, and voltage change rate.
[0020] S102. Perform wavelet denoising and maximum and minimum value normalization on the voltage time series data. According to flicker amplitude judgment and flicker frequency analysis, extract the characteristic vectors of short-term flicker and long-term flicker that reflect the increase in power system losses. If the voltage change amplitude exceeds the preset threshold and the frequency is high, it is judged that there is a serious flicker risk.
[0021] Wavelet denoising is performed on the voltage time series data, wavelet decomposition is performed using the db4 wavelet basis function, and high-frequency coefficients are denoised using a soft threshold function to obtain a denoised voltage data sequence; maximum and minimum value normalization is performed on the denoised voltage data sequence to obtain the maximum and minimum values in the sequence, the voltage data sequence is mapped to a specified interval, and data that exceeds the normal range is truncated to obtain a normalized voltage data sequence; the normalized voltage data sequence is segmented using a rectangular window method to calculate the interval between two adjacent samples in each window The absolute value of the difference between the point voltage values is taken as the voltage change amplitude, and the number of times the amplitude change exceeds the preset threshold is counted as the change frequency to obtain the short-time flicker characteristic vector; the short-time flicker characteristic vector is processed, and the cumulative probability distribution function is calculated using the five-point method in the IEC standard to extract the long-time flicker characteristic vector Plt, and the active power loss increment during the flicker is calculated at the same time; 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, and the db4 wavelet basis function is used for 5-layer wavelet decomposition. The high-frequency coefficients are denoised by the soft threshold function f(x)=sign(x)(|x|-λ)+, where λ is the threshold value, which is set to 0.1 times the standard deviation, and the denoised voltage data sequence is reconstructed. The maximum and minimum values of the denoised voltage data sequence are normalized to obtain the maximum and minimum values in the sequence, and the voltage data is mapped to the interval [0, 1]. For data beyond the normal range, the upper limit is set to 1.1 times the rated voltage and the lower limit is set to 0.9 times the rated voltage for truncation to obtain the normalized voltage data sequence. The flicker amplitude and frequency are calculated based on the normalized voltage data sequence, and the voltage data is segmented using the 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 change amplitude, and the number of times the amplitude changes by more than 0.1% is counted as the change frequency to obtain the short-term flicker feature vector. The short-time flicker feature vector is processed, and the flicker severity index Pst within 10 minutes is calculated. The five-point method in the IEC standard is used to calculate the cumulative probability distribution function, and the long-time flicker feature vector Plt is extracted. At the same time, the active power loss increment ΔP during the flicker period 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, reflecting the increase in power system losses. The voltage time series data is collected at a sampling frequency of 10kHz, forming a data segment every 10 minutes. Wavelet denoising is performed on each data segment, and the db4 wavelet function in the PyWavelets library is used to perform a 5-layer wavelet decomposition. A soft threshold function is applied to the high-frequency coefficient, and the threshold λ is set to 0.1 times the standard deviation of the coefficient of this layer. For example, for the third layer of high-frequency coefficients, if the standard deviation is 0.05, then λ=0.005. The denoised data is normalized to the maximum and minimum values. If the rated voltage of the power grid is 220V, the upper limit is 242V and the lower limit is 198V. Data out of range are truncated, such as 243V will be truncated to 242V. The normalized data is used to calculate the flicker characteristics. A 10-minute rectangular window with a sliding step of 1 minute is used to calculate the voltage change amplitude within the window. If the absolute value of the voltage difference between adjacent sampling points exceeds 0.22V, which can be 0.1% of the rated value, it is recorded as a change. Count the number of changes within 10 minutes, such as 300 times. Use the IEC standard five-point method to calculate the short-term flicker severity Pst, and take the weighted sum of the five percentiles of P0.1, P1, P3, P10, and P50. If Pst = 1.2 is obtained. The long-term flicker severity Plt is calculated for 12 consecutive Pst values, and the formula is the cube root average. At the same time, the active power loss increment ΔP during the flicker period is calculated. Assuming the rated power is 100MW, the measured ΔP is 2.5MW.If Pst exceeds 1.0 and Plt exceeds 0.8, or ΔP exceeds 2MW, it is determined that there is a serious flicker risk, indicating that the power system losses have increased significantly.
[0023] S103. Use long short-term memory neural network for anomaly detection, train the feature vectors of short-term flicker and long-term flicker that reflect the increase in power system losses, and establish a flicker detection model for power equipment that can determine the severity of flicker. During the training process, introduce the attention mechanism to enhance the model's ability to capture key features including noise levels.
[0024] A training data set is constructed, wherein the training data set includes feature vectors arranged in chronological order, and each sample includes feature data for 24 consecutive hours; a flicker severity label is set according to the IEC standard according to the training data set, and the Pst value is divided into a preset number of levels to obtain labeled training samples; a long short-term memory neural network structure is designed for the labeled training samples, and network parameters are determined by 5-fold cross-validation, wherein 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 jointly determined by the current hidden state and the decoder state; a back-propagation algorithm is used to train the long short-term memory neural network, and a learning rate decay strategy is used. If the validation set loss does not decrease for 5 consecutive epochs, the training is stopped to obtain a flicker detection model.
[0025] Specifically, a training data set is constructed based on the extracted short-term flicker and long-term flicker feature vectors, and the feature vectors are arranged in chronological order. Each sample contains feature data for 24 consecutive hours, including voltage fluctuation amplitude, frequency change rate, harmonic content, and power factor. The flicker severity label is set according to the IEC standard, and Pst values 0-0.5, 0.5-1.0, 1.0-2.0, and greater than 2.0 correspond to four levels: mild, moderate, severe, and extreme. A long short-term memory neural network structure is designed, and the network parameters are determined by 5-fold cross validation. The number of nodes in the input layer 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 containing 64 neurons and a 4-node softmax layer, which is used to predict the severity of flicker. The additive attention mechanism is introduced into the long short-term memory neural network, and the attention weight αt=softmax(vTtanh(W1ht+W2s+b)) of each time step is calculated, where ht is the current hidden state, s is the decoder state, and W1, W2, v and b are learnable parameters. Higher initial weights are given to key features such as voltage fluctuation amplitude and harmonic content to improve the model's ability to capture important features. The long short-term memory neural network is trained using the back propagation algorithm, with the initial learning rate set to 0.001 and a learning rate decay strategy of 10% every 10 epochs. The batch size is set to 64, the total number of training rounds is 200, and 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 the 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. If the highest category probability output by the model is lower than the threshold, it is judged as an abnormal sample, and a power equipment flicker detection model that can judge the severity of flicker is obtained. The implementation process of the power system flicker detection model begins with data preprocessing, extracting feature vectors 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 moment 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.05Hz / s, the total harmonic distortion rate is 3%, and the power factor is 0.98. 24 consecutive hours of data constitute a sample, with a total of 1440 feature points. According to the IEC standard, if the maximum Pst value within 24 hours is 1.5, it is marked as "severe" level. The LSTM network is constructed using the TensorFlow framework, and the optimal parameters are determined by grid search: 128 LSTM units and 64 fully connected layer neurons. During the training process, the initial learning rate was set to 0.001 and decayed by 10% every 10 epochs. The batch size was 64 and the training was performed for 200 rounds.The implementation of the additive attention mechanism involves calculating the attention weights, and initially assigning a 1.5-fold weight to the voltage fluctuation amplitude and harmonic content. The validation set loss is monitored during training, and the early stop mechanism is triggered when it does not decrease for five consecutive epochs. The final model achieved an accuracy of 95% on the test set, and samples with a predicted probability lower than 0.8 were marked as abnormal and manually reviewed. This method can not only accurately determine the severity of flicker, but also identify potential abnormal situations, providing strong support for power grid operation and maintenance.
[0026] S104. The established power equipment flicker detection model is pre-trained on large-scale power system historical data, and a small amount of labeled data is used to fine-tune the pre-trained model so that the model can adapt to specific scenarios where flicker is caused by transformers and generators due to voltage fluctuations.
[0027] Acquire large-scale power system historical data, the power system historical data includes 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 preset time sliding time window to obtain a pre-trained data set; the pre-trained data set includes voltage fluctuation amplitude, frequency change rate, harmonic content and power factor data; construct an autoencoder, the autoencoder includes a preset number of layers of convolutional neural network as an encoder and a decoder; train the autoencoder by minimizing the reconstruction error to obtain a pre-trained model; obtain relevant data on flicker caused by transformers and generators, The relevant data include voltage fluctuation amplitude, frequency, duration and corresponding flicker severity label; two fully connected layers and a softmax output layer are added to the pre-trained model to construct a fine-tuning model for flicker detection; the parameters of the pre-trained model are used as initial values, and the fine-tuning model is trained by the transfer learning method; the parameters of the pre-preset proportional layer of the pre-trained model are frozen, and only the parameters of the pre-preset proportional layer and the newly added output layer are trained; weights for transformer and generator related features are added to the loss function; the parameters of the fine-tuning model are optimized by the back propagation algorithm to obtain a detection model adapted to specific flicker scenarios.
[0028] Specifically, large-scale power system historical data, including voltage, current, power factor and other parameters, are collected, outliers are removed by the 3σ criterion, and features are extracted using a 5-minute sliding time window. A pre-training data set containing 1 million records is constructed, each of which contains voltage fluctuation amplitude, frequency change rate, harmonic content and power factor data at 288 time points. The pre-training data set is encoded using an unsupervised learning method, and an autoencoder is constructed using a five-layer convolutional neural network as an encoder and decoder. The number of nodes in the input and output layers is 288×4, and the number of nodes in the hidden layer is 1024, 512, 256, 512, and 1024, respectively. The autoencoder is trained by minimizing the reconstruction error to obtain a pre-training model that can represent the general characteristics of the power system. For the specific scenario of flicker caused by transformers and generators, 10,000 relevant data are collected and annotated, including voltage fluctuation amplitude, frequency, duration and other characteristics, as well as the corresponding flicker severity labels. According to the IEC standard, the flicker severity is divided into four levels: mild, moderate, severe and extreme. Two fully connected layers and a softmax output layer are added to the pre-trained model to build a fine-tuning model for flicker detection. 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 parameters of the first 80% of the pre-trained model are frozen, and only the parameters of the last 20% of the layers and the newly added output layer are trained. The weights of the transformer and generator related features are added to the loss function. The model parameters are optimized by the back propagation 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 operating data, including parameters such as voltage, current, and power factor, is extracted from the power grid monitoring system, with a sampling frequency of 1Hz. The Python Pandas library is used for data cleaning, and the 3σ criterion is applied to eliminate outliers, such as marking data points with voltage deviations exceeding ±7% as abnormal. 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-trained records. Each record contains 4 features at 288 time points: voltage fluctuation amplitude, frequency change rate, harmonic content, and power factor. A five-layer convolutional autoencoder was constructed using PyTorch. The input layer had 1152 nodes, the middle layers had 1024, 512, 256, 512, and 1024 nodes, and the output layer was the same as the input layer. The autoencoder was trained by minimizing the reconstruction error using the Adam optimizer. The learning rate was set to 0.001, the batch size was 128, and 50 epochs were trained. For transformer and generator flicker scenarios, 10,000 labeled data were collected from 10 substations, including equipment operating parameters and corresponding flicker levels. The flicker level is divided into four levels according to the IEC standard: Pst<1 is mild, 1≤Pst<2 is moderate, 2≤Pst<4 is severe, and Pst≥4 is extreme.Two fully connected layers with 128 and 64 nodes, and a 4-node softmax output layer were added to the pre-trained model. The transfer learning method was used to fine-tune the model, freezing the parameters of the first 80% of the layers, that is, only the last convolutional layer, two fully connected layers, and the output layer were trained. In the loss function, a 1.5-fold weight was given to the transformer excitation current and the generator rotor current to increase the model's sensitivity to these key features. Cross entropy was used as the loss function, the learning rate was set to 0.0001, the batch size was 32, and 100 epochs were trained. The final model achieved an accuracy of 93% on the test set, especially the recognition rate of severe and extreme flicker reached 97%, providing a reliable early warning tool for power grid operation and maintenance.
[0029] S105. Use the knowledge distillation method to transfer the knowledge of the pre-trained power equipment flicker detection model to a small and simple model. Through the training method of soft label distillation, the small and simple model inherits the flicker feature recognition ability of the complex model, and the prediction accuracy is close to the original large model, which meets the resource limitations of the edge device.
[0030] A small and simple model structure is designed, and a three-layer fully connected neural network is adopted, wherein 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 these data are predicted using the original large model to obtain soft label output; for the soft label output, a knowledge distillation loss function is defined, combining the cross entropy loss and the Kullback-Leibler divergence, wherein 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 and 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 back propagation; if the validation set loss no longer decreases for multiple consecutive epochs, the training is stopped, and the accuracy and inference time of the small and simple model structure are obtained to determine 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.
[0031] Specifically, a small and simple model structure is designed, using a three-layer fully connected neural network. The number of input layer nodes is set to 288, which is consistent with the number of input features of the original large model. The number of hidden layer nodes is set to 64 and 32, and the number of output layer nodes is 4, corresponding to the number of flicker levels. The activation function uses the ReLU function, and the total number of parameters is controlled within 100,000 to ensure that the model size does not exceed 10MB. Prepare a knowledge distillation training data set, randomly extract 50% of the samples from the original data set as unlabeled data, use the original large model to predict these data, and obtain soft label output. The soft label is in the form of a 4-dimensional probability vector, which represents the probability distribution of each flicker level, and construct a distillation data set containing input features and corresponding soft labels. The knowledge distillation loss function is defined, combining the cross entropy loss and the 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 KL divergence calculation formula is KL(P||Q)=ΣP(x)*log(P(x) / Q(x)), where P is the output of the large model and Q is the output of the small model. The weight coefficients α=0.7 and β=0.3 are determined by cross-validation. The small simple model is trained using a stochastic gradient descent optimizer, with a learning rate set to 0.01, a batch size of 32, and 100 training rounds. In each iteration, the knowledge distillation loss is calculated and back-propagated, the model parameters are updated, and an early stopping mechanism is set. When the validation set loss no longer decreases for 5 consecutive epochs, the training is stopped. The evaluation indicators include accuracy and inference time. The accuracy is required to be no less than 95% of the original large model and the inference time is no more than 100ms. The knowledge distillation process of the power equipment flicker detection model begins with the design of a small model. The PyTorch framework is used to build a three-layer fully connected neural network. The input layer is set with 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 with 64 and 32 nodes respectively, and the output layer is 4 nodes, corresponding to the four flicker levels of mild, moderate, severe and extreme. The ReLU activation function is used, the total number of parameters is 20,928, and the model size is about 0.8MB. 500,000 pieces of unlabeled data are randomly selected from 1 million pieces of original data as unlabeled data, and the pre-trained large model (accuracy 98%) is used to predict these data to obtain soft labels. The soft label is in the form of a 4-dimensional probability vector such as [0.05, 0.15, 0.75, 0.05]. The knowledge distillation loss function is constructed, combined with the cross entropy loss and KL divergence, and the optimal weight coefficients α=0.7 and β=0.3 are determined by grid search. The SGD optimizer of PyTorch is used for training, with an initial learning rate of 0.01 and a decay of 10% every 20 epochs. The batch size is set to 32. The validation set loss is monitored during training, and the early stopping mechanism is triggered when it stops decreasing for 5 consecutive epochs.Inference tests were conducted on NVIDIA Jetson Nano, with an average inference time of 78ms and an accuracy of 96.5%, meeting the resource constraints of edge devices. The resulting small model not only maintained a high prediction accuracy, but also greatly reduced computing resource requirements, providing an efficient flicker detection tool for power system edge computing.
[0032] According to the feature representation extracted by the pre-trained complex model, the original data is transformed to simulate various interference factors, generate a large amount of enhanced data, and combine the enhanced data and the original data to form a training set. A teacher model of knowledge distillation is constructed, and a lightweight student model is obtained by refining and condensing the key knowledge in the teacher model. The student model inherits the feature extraction capability of the teacher model and the model size is greatly reduced.
[0033] The output of the preset residual block in the pre-trained complex model is obtained as a feature map, and the feature map 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 is merged with the original data in a preset ratio to construct a knowledge distillation training set. According to the knowledge distillation training set, a deep residual network is used as a teacher model, and the teacher model includes a preset number of convolutional layers. A lightweight student model structure is designed, and the student model structure adopts a deep separable convolutional network, including a preset number of deep separable convolutional layers and a preset number of fully connected layers. Knowledge distillation is performed by soft label and feature matching, and the soft label is the probability distribution of the output category of the teacher model. The feature map of the middle layer of the teacher model is extracted, and the mean square error is calculated with the feature map of the corresponding layer of the student model. The student model is trained by combining the classification loss and the 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 weight is adaptively adjusted.
[0034] Specifically, feature representations are extracted from the pre-trained complex model, and the outputs of the 10th, 20th, 30th, and 40th layers are selected as feature maps. Gaussian noise is applied to the original data, with a range of mean 0, standard deviation 0.01, random rotation, range ±5 degrees, scaling, range 0.9-1.1 times, and translation, range ±5 pixels, etc., to simulate various interference factors in the power system, and generate an enhanced data set 10 times the amount of original data. The enhanced data is merged with the original data 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 residual block contains two 3×3 convolutional layers and a short-circuit connection, and finally connected to a global average pooling layer. The input layer is set to a 288×4 tensor, corresponding to 24 hours of voltage, current, frequency, and phase data. The lightweight student model structure is designed, using a deep separable convolutional network, which includes 8 deep separable convolutional layers, with a convolution kernel size of 3×3, and the number of channels is 32, 64, 128, 256, 256, 512, 512, 1024, and 1 fully connected layer. The fully connected layer has 128 nodes, the input layer is consistent with the teacher model, and the output layer is 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 by soft label and feature matching. The category probability distribution output by the teacher model is used as the soft label. At the same time, the feature map of the middle layer of the teacher model is extracted, and the mean square error is calculated with the feature map of the corresponding layer of the student model. Combined with the classification loss, such as cross entropy and feature matching loss, such as mean square error, the loss function weights are set to 0.7 and 0.3 to train the student model. The channel attention mechanism is used to highlight important features. A squeeze-and-excitation module is added after each convolution layer of the student model to adaptively adjust the weight of the feature channel. The knowledge distillation process of power system flicker detection begins with feature extraction and data enhancement. Using the pre-trained ResNet50 model, the outputs of the 10th, 20th, 30th, and 40th layers are selected as feature maps. The size of each feature map is 72×72×64.
[0035] 36×36×128, 18×18×256 and 9×9×512. The original 1 million power data are enhanced by applying Gaussian noise with mean 0, standard deviation 0.01, random rotation in the range of ±5 degrees, scaling in the range of 0.9-1.1 times and translation in the range of ±5 pixels to generate 10 million enhanced data. The enhanced data are mixed with the original data in a ratio of 7:3 to construct a training set of 7.7 million. The teacher model uses a 50-layer ResNet with 16 residual blocks, and the input is a 288×4 tensor corresponding to 24 hours of voltage, current, frequency and phase data. The student model uses the MobileNetV2 structure, which contains 8 depth-separable convolutional layers, the number of channels increases from 32 to 1024, and finally a 128-node fully connected layer. During the knowledge distillation process, the softmax output of the teacher model is used as the soft label, and the feature maps of the 10th, 20th, 30th, and 40th layers of the teacher model are compared with the 2nd, 4th, 6th, and 8th layers of the student model to calculate the mean square error. The loss function combines the cross entropy with a weight of 0.7 and the feature matching loss with a weight of 0.3. The SE module is added after each layer of the student model.
[0036] The compression ratio is 16, and the feature importance is adjusted adaptively. The training is performed for 100 epochs, with an initial learning rate of 0.01 and a 10-fold decay every 30 epochs. The student model finally achieves an accuracy of 96.5% on the test set, and the model size is compressed from 97MB of the teacher model to 5.8MB, and the inference time is reduced from 120ms to 18ms, achieving efficient and accurate flicker detection.
[0037] S106. Based on model distillation, model pruning methods are used, including structured sparse pruning and filter pruning, to compress the model parameters and computational complexity. By setting the sparsity threshold, neurons and connections that are critical to the task are retained and redundant structures are cut.
[0038] 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-order moment of the gradient of the loss function with respect to the parameters; neurons and connections are sorted according to the 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, and an L1 regularization term is introduced during the training process to modify the loss function to L=L original +λ||w|| 1 , where λ is the penalty factor; perform filter pruning on the convolutional layer, calculate the importance score of each filter, and use the evaluation method based on feature map energy. The feature map energy calculation formula is E = ||F|| 2, where F is the feature map; retain the top 60% of the filters according to the importance score, and delete the remaining filters and their corresponding feature map channels; reconstruct and fine-tune the pruned model, rebuild the network structure according to the retained neurons and filters, and adopt a layer-by-layer fine-tuning strategy to unfreeze one layer at a time from the output layer to the input layer; evaluate the model performance through the accuracy and F1 score on the validation set, stop fine-tuning when the performance does not improve for a preset number of consecutive cycles, and determine the final model structure.
[0039] Specifically, a sensitivity analysis is performed on the student model after knowledge distillation, and an algorithm based on Fisher information is used to calculate the degree of influence of each neuron and connection on the model output. Specifically, the Fisher information matrix is estimated by calculating the second-order moment of the gradient of the loss function with respect to the parameters, and neurons and connections are sorted according to the degree of influence. The retention ratio is set to 70%, and the target of structured sparse pruning is determined. The gradient-based structured sparse pruning method is used, and the L1 regularization term is introduced during the training process, and the loss function is modified to L = L original +λ||w|| 1 , where λ is the penalty factor, set to 0.0001, and the neuron weights are sparsed. The training is iterated for 50 cycles, and the neurons with absolute weight values less than 0.001 are set to zero every 10 cycles. The convolution layer is subjected to filter pruning, and the importance score of each filter is calculated. The evaluation method based on feature map energy is adopted. The feature map energy calculation formula is E = ||F|| 2, where F is the feature map, retain the top 60% of the filters, and delete the remaining filters and their corresponding feature map channels. The pruned model is reconstructed and fine-tuned. First, the network structure is rebuilt according to the retained neurons and filters, and then a layer-by-layer fine-tuning strategy is adopted. One layer is unfrozen from the output layer to the input layer at a time and trained for 10 cycles. The learning rate is set to 0.0001, the batch size is 32, and the total training cycle is 100. The model performance is evaluated by the accuracy and F1 score on the validation set. When the performance does not improve for 5 consecutive cycles, fine-tuning is stopped to determine the final model structure. In the compression process of the power system flicker detection model, the 5.8MB student model after knowledge distillation is first subjected to sensitivity analysis. The Fisher information algorithm implemented in PyTorch is used to calculate the impact of each parameter on the loss function. The analysis results show that in the 8-layer deep 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 later layers are more important. According to this result, a retention ratio of 70% was set, focusing on retaining the neurons and connections of the last 4 layers. Then, structured sparse pruning was performed, and the L1 regularization term was added on the basis of the original cross entropy loss, and the penalty factor was set to 0.0001. After 50 cycles of iterative training, the number of model parameters was reduced from 1.3 million to 910,000, of which the parameters of the second and third layers were reduced the most, reaching 45% and 38% respectively. Filter pruning was then performed on the convolutional layer, and the importance of each filter was evaluated using the feature map calculation function of TensorFlow. The results showed that among the 1024 filters, 386 had energy values lower than 50% of the average value, and these filters were deleted. After pruning, the model size was further reduced to 3.2MB. Finally, the model was reconstructed and fine-tuned, using a layer-by-layer unfreezing strategy, training each layer for 10 cycles, and a total of 100 cycles of fine-tuning. On the validation set, the model accuracy dropped slightly from the original 96.5% to 95.8%, the F1 score remained at 0.94, and the inference time was reduced from 18ms to 11ms, 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 numbers to low-bit integers. While keeping the accuracy loss controllable, the computational and storage overhead of the student model is reduced and the inference speed is accelerated.
[0041] The weights of the student model are statically quantized, and the weights are mapped from 32-bit floating point numbers to 8-bit signed integers using a symmetric linear quantization method. 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 quantized, and statistical information of the activation values, including the mean and standard deviation, is collected during the inference process. The statistics are updated using the exponential moving average method, and the quantized activation values are calculated according to the statistics and the quantization formula. Quantization-aware training is implemented, and the weights and activation values are quantized during the forward propagation process. The straight-through estimator is used to calculate the gradient during the back propagation, and the straight-through estimator is implemented by setting the gradient of the quantization operation to 1. The quantized student model is evaluated for accuracy, and the accuracy difference of the model on the test set before and after quantization is calculated. If the accuracy difference exceeds the preset accuracy loss threshold, a mixed precision quantization strategy is adopted. For the mixed precision quantization strategy, the high-sensitivity layer is determined by calculating the output change before and after quantization, and the high-sensitivity layer is quantized using a higher bit number such as 16 bits, and the other layers are kept 8 bits. Finally, a quantization model that meets the accuracy requirements is obtained.
[0042] Specifically, the weights of the student model are statically quantized, and the 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 the weights of each layer is calculated, and the quantization range is [-abs_max, abs_max]. Quantization is performed according to the formula Q = round (F * 127 / abs_max), where F is a floating-point number and Q is the integer value after quantization. The activation values of the model are dynamically quantized, and the statistical information of the activation values, including the mean and standard deviation, is collected during the inference process. The statistics are updated using the exponential moving average method. The update formula is new_mean = 0.9 * old_mean + 0.1 * current_mean, which is updated every 100 batches. The number of quantization bits is set to 8 bits, and the quantization formula is Q = round ((F-mean) / (std * scale_factor)), where the initial value of scale_factor is set to 1, and optimization is performed through back propagation. Implement quantization-aware training, quantize weights and activation values during forward propagation, and use the straight-through estimator to calculate gradients during backpropagation. This is achieved by setting the gradient of the quantization operation to 1 during backpropagation. During training, the quantization parameters, including the scaling factor and bias term, are gradually adjusted. The cross-entropy loss function is used, the learning rate is set to 0.0001, and the training is performed for 50 cycles. The model accuracy is evaluated on the validation set every 5 cycles. The accuracy of the quantized model is evaluated and the performance is optimized. The accuracy difference of the model on the test set before and after quantization is calculated. The acceptable accuracy loss threshold is set to 0.5%. If the threshold is exceeded, a mixed precision quantization strategy is adopted. For the layers with high sensitivity, the output change before and after quantization is determined by calculating the output change. A higher bit number such as 16 bits is used, and other layers are kept 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. Symmetric linear quantization is applied to the weights of each layer using the TensorFlowLite tool. Taking the first layer of convolution as an example, the absolute maximum value of the weight is 0.35, and the quantization range is determined to be [-0.35, 0.35], mapping the 32-bit floating point number to the 8-bit signed integer range [-127, 127]. Then the activation value is dynamically quantized. During the inference process of 100 batches, the mean of the first layer output is 0.12 and the standard deviation is 0.08. These statistics are updated using the exponential moving average method, and the initial value of scale_factor is set to 1. In quantization-aware training, quantization is performed during the forward propagation of each mini-batch, and the straight-through estimator is used for backpropagation. Training is performed for 50 cycles with a learning rate of 0.0001, and the accuracy is evaluated on a validation set of 1000 samples every 5 cycles.The final round of evaluation showed that the accuracy of the quantized model on the test set was 95.3%, which was 0.5% lower than the 95.8% of the original model, just reaching the preset threshold. 16-bit quantization was used for the 6th and 7th layers with large accuracy loss, and 8-bit was used for other layers. The size of the final quantized model was reduced to 0.9MB, and the inference time on RaspberryPi4 was reduced from 11ms to 6ms, achieving the goal of significantly improving efficiency with controllable accuracy loss.
[0043] S107. Retrain the pruned lightweight flicker anomaly detection model and fine-tune the model parameters to enable real-time data collection and flicker detection on resource-constrained edge devices. Deploy the trained lightweight flicker anomaly detection model in the edge devices and portable power flicker meters of the substation to achieve real-time monitoring and early warning of equipment operation failures and power quality degradation caused by flicker.
[0044] For the lightweight flicker anomaly detection model, fine-tune the parameters of the post-preset proportional layer with high sensitivity, 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, use an 8-bit integer quantization method to process most layers, and use 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 a first data cache window and a second data cache window; perform short-term feature extraction based on the first data cache window, and perform long-term feature extraction based on the second data cache 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 thresholds, and if the short-term flicker is greater than the first preset value or the long-term flicker is greater than the second preset value, trigger an early warning; 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, and if so, determine that the power quality has deteriorated.
[0045] Specifically, for the trimmed lightweight flicker anomaly detection model, the transfer learning method is used for retraining. The layers that need to be fine-tuned are determined through layer sensitivity analysis. 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 32, and the number of training rounds is 100. The Adam optimizer is used to minimize the cross entropy loss function. The fine-tuned model is processed with mixed precision, and the 8-bit integer quantization method is used to process most layers. The key layers such as the output layer are quantized using 16-bit floating point numbers. The quantized model file suitable for edge devices is generated by the TensorFlowLite tool, and the model size is controlled within 1.2MB. The edge device data acquisition and processing module is developed, and the Raspberry Pi is used as the edge computing platform. The voltage and current signals are collected through the ADC module. The sampling frequency is set to 10kHz. Two data cache 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 to the edge devices and portable power flicker meters of the substation. The communication between the edge devices and the cloud server is realized through the MQTT protocol. The flicker severity threshold is set. When the short-term flicker Pst>1.0 or the long-term flicker Plt>0.8, the warning is triggered. At the same time, the power factor <0.9 or the total harmonic distortion rate>5% is monitored as the power quality degradation indicator. When an event exceeding the threshold is detected, an alarm message is immediately sent to the cloud, including the timestamp, device ID, flicker severity and power quality indicators. If the network is disconnected, the data is stored in the local SD card and uploaded in batches after the network is restored. In the process of optimizing the deployment of the power system flicker detection model, the sensitivity analysis of the trimmed 0.9MB lightweight model is first performed. The SHAP (SHapley Additiveex Planations) value is used to calculate the contribution of each layer to the output. The results show that the sensitivity of the last three layers, which are the fully connected layer, the ReLU activation layer and the Softmax layer, are 0.42, 0.35 and 0.23 respectively, which are much higher than other layers. Based on this, the 30% sensitive layers were fine-tuned, using the Adam optimizer, with the learning rate set to 0.0001, and trained on 1000 samples for 100 rounds. After fine-tuning, the accuracy of the model on the validation set increased from 95.3% to 95.7%. Subsequently, mixed precision quantization was performed, using TensorFlowLite to quantize most layers to 8-bit integers, and the sensitive output layer remained 16-bit floating point numbers. The final model size was 1.15MB. The model was deployed on a Raspberry Pi 4B, and the MCP3008ADC was used to collect 10kHz voltage and current data.A double buffer window of 1 second and 10 minutes is set. The short-term window extracts features every 100ms to calculate the voltage fluctuation amplitude (standard deviation), frequency change rate and the first 5 harmonic contents; the long-term window extracts cumulative features every 10 minutes. The model inference time is 5.8ms on average. Use the PahoMQTT client to communicate with the cloud, set Pst>1.0 or Plt>0.8 as the flicker warning threshold, and power factor<0.9 or THD>5% as the power quality warning threshold. When the warning is triggered, a JSON message containing a timestamp, device ID such as "VF001", Pst / Plt value, power factor and THD is generated and sent to the cloud. In the event of a network interruption, the data is stored in a local 16GB SD card in CSV format, and the network is checked once an hour and retransmission is attempted, achieving stable and reliable edge flicker detection and warning.
[0046] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A training method for building an AI foundation for power systems, characterized in that: The method comprises: Obtain voltage data in the power system, convert the voltage data into digital signals through high-frequency sampling and adaptive quantization processing, and thus construct a voltage time series data set containing harmonic content and voltage variation amplitude and frequency characteristics; The voltage time series data is subjected to wavelet denoising and maximum and minimum value normalization. Based on flicker amplitude judgment and flicker frequency analysis, the characteristic vectors of short-term flicker and long-term 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. Long short-term memory neural network is used for anomaly detection. The feature vectors of short-term flicker and long-term flicker that reflect the increase of power system loss are trained to establish a flicker detection model for power equipment that can judge the severity of flicker. During the training process, the attention mechanism is introduced to enhance the model's ability to capture key features including noise level. The established power equipment flicker detection model is pre-trained on large-scale power system historical data, and a small amount of labeled data is used to fine-tune the pre-trained model so that the model can adapt to specific scenarios where transformers and generators cause flicker due to voltage fluctuations. The knowledge distillation method is used to transfer the knowledge of the pre-trained power equipment flicker detection model to a small and simple model. Through the training method of soft label distillation, the small and simple model inherits the flicker feature recognition ability of the complex model, and the prediction accuracy is close to the original large model, which meets the resource constraints of edge devices. Based on model distillation, model pruning methods are used, including structured sparse pruning and filter pruning, to compress the number of model parameters and computational complexity. By setting the sparsity threshold, neurons and connections that are critical to the task are retained and redundant structures are cut. The trimmed lightweight flicker anomaly detection model is retrained and the model parameters are fine-tuned to enable real-time data collection and flicker detection on resource-constrained edge devices. The trained lightweight flicker anomaly detection model is deployed in the edge devices of the substation and the portable power flicker meter to achieve real-time monitoring and early warning of equipment operation failures and power quality degradation caused by flicker.
2. The method according to claim 1, characterized in that The voltage data in the power system is obtained, and the voltage data is converted into a digital signal through high-frequency sampling and adaptive quantization processing, so as to construct a voltage time series data set containing harmonic content and voltage variation amplitude and frequency characteristics, including: Acquiring a voltage signal in the power system, wherein the voltage signal is acquired by a high-speed data acquisition card at a preset sampling frequency; Convert the voltage signal into a digital signal by an analog-to-digital converter to obtain an original voltage data sequence; Performing adaptive quantization processing on the original voltage data sequence, wherein 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; Calculating the frequency spectrum of the original voltage data sequence using a fast Fourier transform algorithm, and extracting harmonic component information from the frequency spectrum; Calculating the short-term change rate and fluctuation range of the original voltage data sequence by a sliding window method, wherein the sliding window method adopts a preset window size and step size; Performing multi-layer decomposition on the original voltage data sequence in combination with wavelet transform to identify voltage mutation events; The time series characteristics of the original voltage data sequence are fused with the harmonic component information to obtain a voltage time series data set.
3. The method according to claim 1, characterized in that The voltage time series data is subjected to wavelet denoising and maximum and minimum value normalization, and the characteristic vectors of short-term flicker and long-term flicker reflecting the increase of power system loss are extracted according to flicker amplitude judgment and flicker frequency analysis. If the voltage change amplitude exceeds a preset threshold and the frequency is high, it is judged that there is a serious flicker risk, including: According to the voltage time series data, wavelet denoising is performed, db4 wavelet basis function is used for wavelet decomposition, and the high-frequency coefficients are denoised by soft threshold function to obtain the denoised voltage data series; Performing maximum and minimum value normalization processing on the denoised voltage data sequence, obtaining the maximum and minimum values in the sequence, mapping the voltage data sequence to a specified interval, and performing truncation processing on data beyond a normal range to obtain a normalized voltage data sequence; The normalized voltage data sequence is processed in segments by using a 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 change amplitude, the number of times the amplitude change exceeds a preset threshold is counted as the change frequency, and a short-time flicker feature vector is obtained; The short-time flicker characteristic vector is processed, the cumulative probability distribution function is calculated using the five-point method in the IEC standard, the long-time flicker characteristic 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 characteristic vector Plt exceeds the second preset threshold, or the active power loss increment exceeds the third preset threshold, it is determined that there is a serious flicker risk.
4. The method according to claim 1, characterized in that: The long short-term memory neural network is used for anomaly detection, and the feature vectors of short-term flicker and long-term flicker reflecting the increase of power system loss are extracted for training, and a flicker detection model of power equipment that can judge the severity of flicker is established. During the training process, an attention mechanism is introduced to enhance the model's ability to capture key features including noise level, including: Constructing a training data set, wherein the training data set includes feature vectors arranged in chronological order, and each sample includes feature data for 24 consecutive hours; According to the training data set, flicker severity labels are set using 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 network parameters are determined by 5-fold cross validation, wherein the long short-term memory neural network structure includes an input layer, a hidden layer, and an output layer; Introducing an additive attention mechanism into the LSTM neural network to calculate the attention weight of each time step, where the attention weight is determined by the current hidden state and the decoder state; The long short-term memory neural network is trained by adopting the back propagation algorithm, and the learning rate decay strategy is used. If the validation set loss does not decrease for 5 consecutive epochs, the 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 power system historical data, and a small amount of labeled data is used to fine-tune the pre-trained model, so that the model can adapt to specific scenarios where transformers and generators cause flicker due to voltage fluctuations, including: Acquiring large-scale power system historical data, wherein the power system historical data includes voltage, current and power factor; removing abnormal values in the historical data of the power system according to the 3σ criterion; Extracting features from the power system historical data using a preset time sliding time window to obtain a pre-training data set; The pre-training data set includes voltage fluctuation amplitude, frequency change rate, harmonic content and power factor data; Constructing an autoencoder, wherein the autoencoder includes a preset number of layers of convolutional neural networks as encoders and decoders; The autoencoder is trained by minimizing the reconstruction error to obtain a pre-trained model; Obtain relevant data on flicker caused by transformers and generators, the relevant data including voltage fluctuation amplitude, frequency and duration and corresponding flicker severity labels; Add two fully connected layers and a softmax output layer on the basis of the pre-trained model to build a fine-tuning model for flicker detection; The parameters of the pre-trained model are used as initial values, and the fine-tuning model is trained using a transfer learning method; Freeze the pre-set scale layer parameters of the pre-trained model, and only train the post-set scale layer parameters and the newly added output layer; Add weights for transformer and generator related features into the loss function; The parameters of the fine-tuning model are optimized by a back-propagation algorithm to obtain a detection model adapted to a specific flicker scenario.
6. The method according to claim 1, characterized in that The knowledge distillation method is used to transfer the knowledge of the pre-trained power equipment flicker detection model to a small and simple model. Through the training method of soft label distillation, the small and simple model inherits the flicker feature recognition ability of the complex model, and the prediction accuracy is close to the original large model, which meets the resource constraints of the edge device, including: A small and simple model structure is designed, using a three-layer fully connected neural network, where the number of input layer nodes is consistent with the number of input features of the original large model, the number of hidden layer nodes is set separately, and the number of output layer nodes 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, combining the cross entropy loss and Kullback-Leibler divergence, where 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 and 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 back propagation; If the validation set loss does not decrease for multiple consecutive epochs, stop training, and obtain the accuracy and inference time of the small simple model structure to determine whether the accuracy is not lower than the preset ratio of the original large model and whether the inference time does not exceed the preset threshold; It also includes: extracting feature representations based on pre-trained complex models, transforming the original data, simulating various interference factors, generating a large amount of enhanced data, combining the enhanced data and the original data to form a training set, building 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 capability of the teacher model, and the model size is greatly reduced.
7. The method according to claim 6, characterized in that The feature representation extracted according to the pre-trained complex model is transformed on the original data to simulate various interference factors, generate a large amount of enhanced data, and form a training set with the enhanced data and the original data to build a teacher model of knowledge distillation. By refining and concentrating the key knowledge in the teacher model, a lightweight student model is obtained, wherein the student model inherits the feature extraction capability of the teacher model and the model size is greatly reduced, including: Obtaining a preset residual block output in a pre-trained complex model as a feature map, wherein the feature map is used for subsequent knowledge distillation; Perform Gaussian noise, random rotation, scaling and translation transformation operations on the original data to obtain an enhanced data set; The enhanced data set is combined with the original data in a preset ratio to construct a knowledge distillation training set; Using a deep residual network as a teacher model according to the knowledge distillation training set, the teacher model includes a preset number of convolutional layers; Designing a lightweight student model structure, wherein the student model structure adopts a depthwise separable convolutional network, including a preset number of depthwise separable convolutional layers and a preset number of fully connected layers; Knowledge distillation is performed by soft label and feature matching, wherein the soft label is the probability distribution of the category output by the teacher model; Extract the feature map of the middle layer of the teacher model and calculate the mean square error with the feature map of the corresponding layer of the student model; Combining classification loss and feature matching loss, training the student model; 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 are adaptively adjusted.
8. The method according to claim 1, characterized in that Based on the model distillation, the model pruning method is used, including structured sparse pruning and filter pruning, to compress the parameters and computational complexity of the model, wherein the neurons and connections that are critical to the task are retained and redundant structures are cut by setting the sparsity threshold, including: The influence of each neuron and connection on the model output is calculated using a Fisher information-based algorithm, wherein the Fisher information-based algorithm estimates the Fisher information matrix by calculating the second-order moment of the gradient of the loss function with respect to the parameter; The neurons and connections are ranked according to the influence degree, and the retention ratio is set to 70% of the total number of neurons and connections; The gradient-based structured sparse pruning method is adopted, and the L1 regularization term is introduced in the training process, and the loss function is modified to L = L original +λ||w||1, where λ is the penalty factor; Perform filter pruning on the convolutional layer and calculate the importance score of each filter. The evaluation method based on feature map energy is adopted. The feature map energy calculation formula is E=||F||2, where F is the feature map. Retain the top 60 percent of filters according to the importance score, and delete the remaining filters and their corresponding feature map channels; Reconstruct and fine-tune the pruned model, rebuild the network structure based on the retained neurons and filters, and adopt a layer-by-layer fine-tuning strategy, 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. When the performance does not improve for a preset number of consecutive cycles, fine-tuning is stopped and the final model structure is determined. It also includes: using model quantization methods to quantize the weights and activation values of the student model from floating point numbers to low-bit integers, reducing the computational and storage overhead of the student model and speeding up the inference speed while keeping the accuracy loss controllable.
9. The method according to claim 8, characterized in that The model quantization method is used to quantize the weights and activation values of the student model from floating point numbers to low-bit integers, thereby reducing the computational and storage overhead of the student model and speeding up the inference speed while keeping the precision loss controllable, including: Static quantization is performed on the weights of the student model, the weights are mapped from 32-bit floating point numbers to 8-bit signed integers using a symmetric linear quantization method, a quantization range is determined according to the absolute maximum value of the weights, and the quantized integer value is calculated according to a quantization formula; Dynamically quantize the activation value of the student model, collect statistical information of the activation value during the inference process, including the mean and standard deviation, update the statistic using the exponential moving average method, and calculate the quantized activation value according to the statistic and the quantization formula; Implementing quantization-aware training, performing a quantization operation on the weights and the activation values during forward propagation, and using a straight-through estimator to calculate gradients during backpropagation, and implementing the straight-through estimator by setting the gradient of the quantization operation to 1; Perform accuracy evaluation on the quantized student model and calculate the accuracy difference of the model on the test set before and after quantization. If the accuracy difference exceeds the preset accuracy loss threshold, a mixed precision quantization strategy is adopted. For the mixed precision quantization strategy, the high-sensitivity layer is determined by calculating the output change before and after quantization, and the high-sensitivity layer is quantized using a higher bit number such as 16 bits, while other layers are kept at 8 bits, and finally a quantization model that meets the accuracy requirements is obtained.
10. The method according to claim 1, characterized in that The trimmed lightweight flicker anomaly detection model is retrained and model parameters are fine-tuned to enable real-time data collection and flicker detection on resource-constrained edge devices. The trained lightweight flicker anomaly detection model is deployed in edge devices and portable power flicker meters in substations to achieve real-time monitoring and early warning of equipment operation failures and power quality degradation caused by flicker, including: For the lightweight flicker anomaly detection model, fine-tune the parameters of the highly sensitive post-preset proportional layer, set the learning rate to the preset value, the batch size to the preset value, and the number of training rounds to the preset value; The fine-tuned lightweight flicker anomaly detection model is subjected to mixed precision quantization, using 8-bit integer quantization for most layers and 16-bit floating point quantization for key layers; The voltage and current signals are collected by 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; Extract short-term features according to the first data cache window, and extract long-term features according to the second data cache window, wherein the features include voltage fluctuation amplitude, frequency change rate and harmonic content; Determine whether the short-term characteristics and long-term characteristics exceed the preset thresholds. If the short-term flicker is greater than the first preset value or the long-term flicker is greater than the second preset value, trigger an early warning; It is determined whether the power factor is less than a third preset value or whether the total harmonic distortion rate is greater than a fourth preset value. If so, it is determined that the power quality is degraded.
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
Cited By
Voltage flicker monitoring method and device for distribution transformer terminal and storage medium
CN120214389A
Intelligent electric energy meter remote monitoring device
CN120302188A
Cloud management platform charging strategy determination method
CN120410654A
Power task processing method and device, storage medium and electronic equipment
CN121660073A