Method and device for detecting abnormal data of photovoltaic system
By using a multi-head self-attention mechanism to integrate variational autoencoder and bidirectional long and short-term memory network in the abnormality detection of photovoltaic systems, the problem of difficulty in capturing complex nonlinear relationships and high-dimensional data dependencies in photovoltaic systems is solved, and efficient anomaly detection is achieved, meeting the requirements of real-time and accuracy.
Patent Information
- Application Number
- CN202411669458.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-11
AI Technical Summary
Existing photovoltaic system anomaly detection methods are difficult to effectively capture the dependence between complex nonlinear relationships and high-dimensional data, resulting in high computational complexity and long time-consuming, and cannot meet the high requirements of real-time and accuracy.
Anomaly detection method based on the multi-head self-attention mechanism is adopted, and a two-way long and short-term memory network (BiLSTM) is characterized by extracting and reconstructing the timing data of the photovoltaic system through the encoder and decoder, and the dependency between the data is captured by the multi-head self-attention mechanism to realize abnormal detection.
The nonlinear relationship and contextual characteristics of the time sequence data of the photovoltaic system are improved, the ability to identify abnormal patterns is enhanced, and the real-time and accuracy requirements of abnormal detection of photovoltaic system are met.
Smart Images

Figure CN119598374A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the intersection of power systems and artificial intelligence, and specifically relates to a photovoltaic system anomaly detection technology based on a fusion variational autoencoder and a bidirectional long short-term memory network (BiLSTM) with a multi-head self-attention mechanism. Background Art
[0002] Clean energy such as solar energy and wind energy is the key to current construction and development. With the rapid development and widespread application of the domestic photovoltaic industry, the intelligent operation and maintenance of photovoltaic systems is an important part of ensuring the stable operation of photovoltaic systems.
[0003] Abnormal conditions in photovoltaic systems include abnormal ambient temperature, abnormal inverter temperature difference, unavailable sensor records, abnormal light intensity within a specific time, abnormal current and voltage, etc. The above abnormalities may cause a series of performance problems such as significant decrease in photovoltaic system power output, frequent inverter failures, and unstable voltage, which seriously affect the efficiency and long-term reliability of photovoltaic systems. In order to meet these challenges, scientific and systematic methods must be adopted for abnormality detection and fault diagnosis.
[0004] At present, the traditional methods used in the field of photovoltaic system anomaly detection include: photovoltaic system anomaly detection signal decomposition method based on the concept of low rank and sparse decomposition; photovoltaic system detection method based on local outlier factor algorithm (Local Outlier Factor); unsupervised photovoltaic system anomaly detection method with integrated distance metric, etc.; the above methods are often difficult to capture the complex nonlinear relationships in photovoltaic systems, and for the high-dimensional data of photovoltaic systems, the calculation complexity is high and the time consumption is long, which cannot meet the high requirements of real-time and accuracy for photovoltaic system anomaly detection.
[0005] In recent years, machine learning and deep learning methods have been applied to the field of photovoltaic system anomaly detection. Such as the unsupervised photovoltaic system anomaly monitoring method based on a one-class support vector machine (One-Class Support Vector Machine); photovoltaic system anomaly detection method based on a recurrent neural network (RNN). These methods solve the problem that traditional statistical methods are difficult to learn complex nonlinear relationships in photovoltaic systems, but it is still difficult to identify the contextual data features of photovoltaic time series data and the dependencies between data of each dimension. To this end, the present invention proposes a photovoltaic system anomaly detection method based on a fusion variational autoencoder (VAE) architecture, combined with a multi-head self-attention mechanism and a bidirectional long short-term memory network (BiLSTM). Among them, the bidirectional long short-term neural network can effectively learn the long-term dependencies in time series data, and the multi-head self-attention mechanism can process data of each dimension in parallel and capture the dependencies between them. Summary of the invention
[0006] The present invention aims to solve the problem of abnormal data detection in photovoltaic systems, discloses a method and device for abnormal data detection in photovoltaic systems, and realizes abnormal detection of electrical parameters (including DC voltage, current and AC voltage, current) and environmental parameters (relative humidity, wind direction, wind speed) and system parameters (including inverter error coding, inverter ambient temperature difference, module ambient temperature difference, etc.) in photovoltaic systems based on the abnormal detection technology of fused variational autoencoder and bidirectional long short-term memory network (BiLSTM) with multi-head self-attention mechanism.
[0007] In order to achieve the above purpose, a photovoltaic system abnormal data detection method and device disclosed in the present invention are implemented by the following technical solutions:
[0008] A photovoltaic system anomaly detection method based on a multi-head self-attention mechanism integrating a variational autoencoder (VAE) and a bidirectional long short-term memory network (BiLSTM) comprises the following steps:
[0009] (1) Photovoltaic system data collection and data processing
[0010] (2) Encoding photovoltaic system time series data
[0011] (3) Data sampling and data feature enhancement
[0012] (4) Data decoding operation
[0013] (5) Photovoltaic system abnormal value detection
[0014] In a possible implementation, the specific process of photovoltaic data collection and outlier classification is: using sensors to collect data from a real photovoltaic system within a certain period of time, the time interval between sampling points is 15 minutes, and each sampling record contains 13 features including electrical parameters, system parameters and environmental parameters in the photovoltaic system.
[0015] The detection model of the present invention requires that the input data format is a time series window format, so the window is set to slide with a step size of 1, and the most recent record can be input into the model in time for anomaly detection, thereby meeting the real-time requirements of photovoltaic system anomaly detection. In addition, since the model needs to be trained on normal data before anomaly detection, each time series window needs to be classified. The classification rules are as follows: as long as the records in the window contain abnormal records, the window is marked as -1, and the data in the window is normal and is marked as 1. After all windows are marked, all abnormal windows with a label of -1 and an equal number of normal windows with a label of 1 are selected as test data, and all other normal windows are used as training data.
[0016] In a possible implementation, the specific process of encoding the photovoltaic system time series data is as follows: the photovoltaic system time series data obtained after processing (1) is input into the model encoder, the encoder is composed of a bidirectional LSTM network and two fully connected layers, and the neural network is used to fit the probability distribution of the input data in the hidden layer.
[0017] In a possible implementation, the specific operation process of step (3) is as follows: sampling the probability distribution of the data obtained in step (2) in the hidden layer of the model to obtain the latent variable representation of the corresponding input data. Then, the intrinsic relationship between the latent variables is captured through the three-head self-attention mechanism. The weighted sum of the outputs of each attention head represents the integrated view of the feature subset it focuses on. These outputs are then aggregated in parallel and integrated into further network layers.
[0018] In a possible implementation, the specific process of the data decoding operation is: the model uses a bidirectional LSTM network as a decoder to decode the sampled values obtained in step (3) after self-attention processing. The decoding process is to restore the hidden layer sampled values to input data. Since the model is trained on normal data, through iterative optimization, the model's ability to understand and express normal photovoltaic system time series data is continuously improved, making the reconstructed data closer to the original input. When the model converges after multiple iterations, it can be used for subsequent anomaly detection.
[0019] In a possible implementation, the specific process of photovoltaic system abnormality detection in step (5) is as follows: input the data to be detected into the trained model. Since the abnormality detection algorithm adopted by the present invention is based on reconstruction error, the original model only learns the distribution and characteristics of normal time series data during training, and the distribution deviation between abnormal data and normal data is large. Therefore, when reconstructing abnormal data, its characteristics may not be correctly captured, resulting in a large reconstruction error. The reconstruction error threshold is set in combination with specific application requirements. When the reconstruction error exceeds the threshold, it is marked as abnormal data.
[0020] The present invention also discloses a photovoltaic system abnormal data detection device, including a collection and processing unit: used for photovoltaic system data collection and data processing; a photovoltaic system time series data encoding unit: used for encoding photovoltaic system time series data; an enhancement unit: used for data sampling and data feature enhancement; a data decoding unit: used for data decoding operations; and a photovoltaic system abnormality detection: used for photovoltaic system abnormal value detection.
[0021] The beneficial effects of the present invention are:
[0022] (1) The input data of the present invention is in the form of a sliding window, and the most recent records can be input into the model for anomaly detection in a timely manner, thereby meeting the real-time requirements of anomaly detection of the photovoltaic system.
[0023] (2) The multi-head self-attention mechanism used in the present invention enables the model to start from multiple feature dimensions, improve the ability to recognize features of different dimensions and key temporal dependencies, and improve the accuracy of anomaly detection results.
[0024] (3) The present invention uses BiLSTM as an encoder and decoder to perform forward and reverse feature extraction on the photovoltaic system time series data, so that the model can learn the nonlinear relationship and contextual data characteristics of the photovoltaic system time series data, enhance the ability to capture long-term dependencies in the photovoltaic system time series data, and help the model identify potential abnormal patterns. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 It is the BiLSTM-VAE encoder structure;
[0026] Figure 2 It is the hidden layer structure of BiLSTM-VAE;
[0027] Figure 3 It is the BiLSTM-VAE decoder structure;
[0028] Figure 4 This is the flow chart of the anomaly detection algorithm. DETAILED DESCRIPTION
[0029] The specific implementation of the present invention is described below in conjunction with the accompanying drawings and embodiments:
[0030] The present invention provides an efficient solution for photovoltaic system anomaly detection based on a fused variational autoencoder and a bidirectional long short-term memory network structure with an integrated multi-head self-attention mechanism.
[0031] The following are the main implementation methods, which are explained in combination with specific formulas:
[0032] 1. Photovoltaic system time series data encoding
[0033] The model of the present invention requires that the input data format is a time series window format. First, the photovoltaic system time series data is sent to the encoder for encoding. The designed encoder consists of BiLSTM and two fully connected layers, and a neural network is used to fit the probability distribution of the input data in the hidden layer. The encoder encoding process is as follows Figure 1 shown.
[0034] For each input data X i , the model assumes that there is a unique X i The true posterior distribution p(Z i |X i ), and use the encoder's neural network to fit the distribution, and then output X i The mean μ of the probability distribution i and log variance And sample from it to get the hidden variable Z i From X i to Z i The process satisfies the distribution Z i ~p(Z i |X i ).
[0035] The process of the encoder outputting probability model parameters is shown in formulas (1) to (2).
[0036] μ i =f1(X i ) (1)
[0037]
[0038] Among them, X i represents input data, f1 and f2 represent functions abstracted by neural networks, μ i represents the mean, represents the logarithmic variance.
[0039] The model uses BiLSTM as part of the encoder. The BiLSTM in the encoder consists of two layers of networks: forward LSTM and backward LSTM. The number of hidden layer units of each LSTM memory unit is set to 6, and the Leaky-ReLU function is uniformly used for nonlinear activation. The Leaky-ReLU function is defined as follows:
[0040]
[0041] where a (usually a small positive number) is the slope of the function for negative inputs.
[0042] The memory unit of BiLSTM learns the features of the input time series data from both the positive and negative directions, and concatenates the learning results of the two layers in the positive and negative directions to obtain the input time series data X i The low-dimensional representation H i The reason why BiLSTM is used in the encoder is that the bidirectional characteristics of BiLSTM enable it to effectively capture the forward and reverse context information in the encoding process of time series data, and extract rich time series features from the input data through the bidirectional learning mode, thereby building a more accurate and reliable latent variable probability model.
[0043] Get the low-dimensional representation H i After that, it needs to be processed by the neural network. The model sets two linear fully connected layers to represent H in low dimensions. i As input, we learn to get X i The mean μ of the probability distribution i and log variance
[0044] 2. Data sampling and data feature enhancement
[0045] After the encoder learns and reduces the dimension of the input time series data, the model of the present invention outputs the mean μ of the low-dimensional latent variable i and log variance After that, we need to sample the probability distribution in the hidden layer to get the corresponding input X i The hidden variable Z i The hidden layer processing process is as follows Figure 2 As shown. Among them, the hidden variable Z i The probability distribution p(Z i |X i ), with a mean value of μ i , the variance is Since the random sampling process of the probability model is not differentiable and cannot be learned using a neural network, the re-parameterization technique is used in this model to calculate Z using the method shown in formula (4). iThe probability distribution formula of is transformed to express the sampling step as a deterministic transformation.
[0046]
[0047] After the transformation of formula (4), it can be found that (Z i -μ i ) / σ i It follows the standard normal distribution N(0,1). So directly from Sampling can be transformed into sampling from N(0,1) first, and then obtaining The parameter transformation for obtaining the sampling value is shown in formula (5).
[0048] Z i =μ i +ε i ×σ i ,ε i ~N(0,1) (5)
[0049] In formula (5), ε i Represents the Gaussian noise sampling value that follows the standard normal distribution. i Add Gaussian noise ε i , and compare it with the standard deviation σ i Sum and get the sampling value Z of the hidden variable i The hidden layer parameters obtained by the encoder in the model are the mean μ i and log variance So the corresponding sampling value formula is shown in (6).
[0050]
[0051] In formula (6), ε i It has the same meaning as that in formula (5), and both represent Gaussian noise sampling values that obey the standard normal distribution.
[0052] The multi-head self-attention mechanism is used to capture the sampled value Z i The attention weights calculated by each head reflect the importance or correlation between different sample values. The weighted sum of the outputs of each attention head represents the integrated view of the feature subset it focuses on. These outputs are then aggregated in parallel and integrated in further network layers. i Perform multi-head self-attention processing to obtain the latent variable sampling value Z after temporal dependency enhancement i '.
[0053] 3. Data decoding
[0054] The decoding process is to restore the hidden layer sample value to the input data. The encoder obtains the hidden layer probability distribution p(Z i |X i ), the decoding process of the decoder is shown in formula (7), where Z is the hidden layer variable Z i Sample values of the distribution.
[0055]
[0056] In fact, it is difficult to use formula (7) to calculate p(X i ), because it is impossible to exhaustively enumerate all the sample values Z in the hidden layer. And because the true posterior distribution p(Z i |X i ) is expressed as shown in formula (8), it is impossible to calculate p(X i ) makes it impossible to calculate p(Z i |X i ).
[0057] To solve this problem, this model adopts another probability distribution q(Z i ) approximates the posterior distribution p(Z i |X i ), by minimizing the KL divergence (Kullback-Leibler divergence) to make p(Z i |X i ) and q(Z i ) is used for approximation. The calculation formula of KL divergence is shown in formula (9), which is an indicator to measure the degree of difference between probability models. The smaller the KL divergence, the smaller the difference between the two probability models.
[0058]
[0059] In formula (9), since the real input data X i Given, so logp(X i ) is a constant, the task of minimizing the KL divergence is transformed into minimizing the last two terms of equation (9). The last two terms are the evidence lower bound (ELBO), which can be further transformed into equation (10).
[0060]
[0061] At this time, minimizing ELBO is to minimize the first term KL(q(Z i )||p(Z i )), while maximizing the second term
[0062]
[0063] Since q(Zi ) is used to approximate p(Z i |X i ), so minimize KL(q(Z i )||p(Z i )) means that p(Z i |X i ) and p(Z i ) is close, thus transforming to let X i Generate Z i The distribution of Z is the same as the true i The difference between the distributions of i |X i ) belongs to the standard normal distribution, so that all p(Z i |X i ) is aligned with the standard normal distribution, so that the prior distribution p(Z i ) is also transformed into a standard normal distribution. The transformation process is shown in formula (11).
[0064]
[0065] After this treatment, the first term KL(q(Z i )||p(Z i )) can be transformed into KL(q(Zi)||N(0,1)), and through mathematical processing, it can be transformed into the form of formula (12).
[0066]
[0067] Maximize the second term in (10) This means that from q(Z i ) is sampled from i Generate input data X i The expectation is the largest. Since the expectation is not easy to find, this model is transformed into finding the minimum reconstruction loss between the input model and the output model data, and the mean square error MSE is used to measure this loss.
[0068] After the above transformation, the loss function expression of the model becomes as shown in (13). In the formula, X represents the input data, MSE represents the use of mean square error as the reconstruction loss, and d represents the dimension of the latent variable Z. i represents the mean, Represents variance.
[0069]
[0070] In the model of the present invention, the decoder also uses BiLSTM, and each LSTM memory unit of BiLSTM is activated by Leaky-ReLU function. The number of hidden layer units is set to 13, and the input data X i The characteristic dimension of is the same as that of i After multi-head self-attention processing, the temporal dependency and temporal features are strengthened, and the processed output Z i 'The input is re-decoded by the decoder composed of BiLSTM to obtain the input data X i Reconstructed value X i '. The structure of the decoder is as follows Figure 3 shown.
[0071] The reconstructed output value X i ' will be used to calculate the value of the loss function as shown in formula (13), and then the parameters of the model are updated through the Adam optimizer to accelerate the convergence of the model. The model is trained on a training set containing only normal data. Through iterative optimization, the model's understanding and expression capabilities of normal photovoltaic system time series data are continuously improved, making the reconstructed data closer to the original input. When the model converges after multiple iterations, it can be used for subsequent anomaly detection.
[0072] 4. Photovoltaic system anomaly detection
[0073] During anomaly detection, the input time series window data X is reconstructed by the BiLSTM-VAE model to obtain the reconstructed data X'. The reconstruction error between the input data X and the output data X' is calculated and compared with the threshold for determining the abnormal window to determine whether there is an abnormality in the time series window. The algorithm flow chart of anomaly detection is shown in the figure below. Figure 4 shown.
[0074] The threshold for abnormality determination required to detect abnormal windows can be obtained through the training set. After the model is trained on the training set, the reconstruction loss is recalculated for all window samples in the training set using the trained model, and then the reconstruction loss values are sorted. Combined with the set 5% abnormal value ratio, the 95% quantile in the reconstruction loss is used as the threshold for determining whether the window is an abnormal window. When used for anomaly detection, the window on the test set is input into the model for reconstruction, the reconstruction loss is calculated, and it is compared with the abnormal window determination threshold to determine whether the window contains an abnormality. In actual application, the determination threshold can be modified according to needs. .
[0075] The preferred embodiments of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above embodiments. Various changes can be made within the knowledge scope of ordinary technicians in the field without departing from the purpose of the present invention. These changes involve related technologies well known to those skilled in the art, which all fall within the scope of protection of the patent of the present invention.
[0076] Many other changes and modifications may be made without departing from the concept and scope of the present invention.It should be understood that the present invention is not limited to the specific embodiments, and the scope of the present invention is defined by the appended claims.
Claims
1. A method for detecting abnormal data in a photovoltaic system. Features: The following steps are involved: Step (1): Photovoltaic system data collection and data processing; Step (2): Encoding photovoltaic system time series data; Step (3): data sampling and data feature enhancement; Step (4): data decoding operation; Step (5): PV system abnormal value detection.
2. A photovoltaic system abnormal data detection method according to claim 1, Features: The step (1) includes photovoltaic data collection and outlier classification, and the specific process is as follows: Sensors are used to collect data from a real photovoltaic system within a certain period of time. The time interval between sampling points is 15 minutes. Each sampling record contains electrical parameters, system parameters and environmental parameters in the photovoltaic system.
3. A photovoltaic system abnormal data detection method according to claim 1, Features: In the step (2), the detection model requires that the input data format is a time series window format, so the window is set to slide with a step size of 1, so that the latest record can be input into the model in time for anomaly detection, thereby meeting the real-time requirements of photovoltaic system anomaly detection; in addition, since the model needs to be trained on normal data before anomaly detection, each time series window needs to be classified; the classification rules are as follows: as long as the records in the window contain abnormal records, the window is marked as -1, and the data in the window is marked as 1 only when they are normal; after all windows are marked, all abnormal windows with a label of -1 and an equal number of normal windows with a label of 1 are selected as test data, and all other normal windows are used as training data.
4. A photovoltaic system abnormal data detection method according to claim 1, Features: In the step (2), the specific process of encoding the photovoltaic system time series data is as follows: the photovoltaic system time series data obtained by processing in step (1) is input into the model encoder, the encoder is composed of a bidirectional LSTM network and two fully connected layers, and the neural network is used to fit the probability distribution of the input data in the hidden layer.
5. A photovoltaic system abnormal data detection method according to claim 1, Features: The specific operation process of step (3) is as follows: sampling the probability distribution of the data obtained in step (2) in the hidden layer of the model to obtain the latent variable representation of the corresponding input data; then capturing the intrinsic relationship between the latent variables through the three-head self-attention mechanism, and the weighted sum of the outputs of each attention head represents the integrated view of the feature subset it focuses on, and these outputs are then aggregated in parallel and integrated into further network layers.
6. A photovoltaic system abnormal data detection method according to claim 1, Features: In the step (4), the specific process of the data decoding operation is: the model uses the bidirectional LSTM network as a decoder to decode the sampled values obtained in step (3) after self-attention processing, and the decoding process is to restore the hidden layer sampled values to input data.
7. A photovoltaic system abnormal data detection method according to claim 1, Features: The specific process of abnormal value detection of the photovoltaic system in step (5) is as follows: The data to be detected is input into the trained model. Since the anomaly detection algorithm used is based on reconstruction error, the original model only learns the distribution and characteristics of normal time series data during training. The distribution deviation between abnormal data and normal data is large. Therefore, when reconstructing abnormal data, its characteristics may not be correctly captured, resulting in a large reconstruction error. The reconstruction error threshold is set according to specific application requirements. When the reconstruction error exceeds the threshold, it is marked as abnormal data.
8. A photovoltaic system abnormal data detection method according to claim 2, Features: The electrical parameters in the photovoltaic system include direct current voltage and current and alternating current voltage and current; Environmental parameters include relative humidity, wind direction, and wind speed; System parameters include inverter error code, inverter ambient temperature difference, and module ambient temperature difference.
9. A photovoltaic system abnormal data detection device, Features: Include: Acquisition and processing unit: used for photovoltaic system data acquisition and data processing; Photovoltaic system time series data encoding unit: used to encode photovoltaic system time series data; Enhancement unit: used for data sampling and data feature enhancement; Data decoding unit: used for data decoding operation; Photovoltaic system anomaly detection: used for photovoltaic system anomaly detection.
Citation Information
Cited By
Multi-energy microgrid intelligent control method and system based on large model
CN120127843A
Multi-energy microgrid intelligent control method and system based on large model
CN120127843B
Photovoltaic power generation equipment anomaly detection method based on time sequence state diagram
CN120512097A
A method for anomaly detection of photovoltaic power generation equipment based on time-series state diagrams
CN120512097B
Code evaluation and repair method based on large model technology
CN120541851A