Contrast learning-based photovoltaic anomaly detection method, system and device, and medium
By combining contrastive learning and heterogeneous graph convolutional networks with data augmentation techniques, a feature learning model is constructed, which solves the problems of false alarms, missed alarms, and scarce data in photovoltaic system anomaly detection. This achieves efficient and intelligent photovoltaic anomaly detection, improving the system's stability and detection accuracy.
Patent Information
- Application Number
- CN202511079346.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-03
- Publication Date
- 2025-11-18
AI Technical Summary
Existing photovoltaic anomaly detection methods lack intelligent and efficient automatic detection mechanisms when facing dynamically changing photovoltaic systems and environmental conditions, resulting in frequent false alarms and missed alarms. Furthermore, their detection accuracy is low under conditions of scarce data and complex nonlinear relationships, making it difficult to address the stability and efficiency issues of photovoltaic systems.
A contrastive learning-based approach is adopted, combining heterogeneous graph convolutional networks and data augmentation techniques. Through data cleaning, normalization, and time series enhancement, a feature learning model is constructed. The feature representation is optimized using graph convolutional networks and contrastive learning models. The model is further optimized by combining a joint loss function and an end-to-end backpropagation mechanism. Finally, it is deployed to a real-time monitoring platform for anomaly detection.
It significantly improves the accuracy and robustness of anomaly detection in photovoltaic systems, reduces false alarms and false negatives, enhances the model's ability to generalize to unseen anomaly patterns, solves the problems of data scarcity and imbalance, and improves the system's automation level and operating efficiency.
Smart Images

Figure CN120974266A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of photovoltaic detection, and particularly relates to a photovoltaic anomaly detection method, system, device and medium based on contrast learning. BACKGROUND
[0002] With the continuous expansion of photovoltaic power generation scale, the application of photovoltaic systems in the global range gradually increases. However, in the process of operation of photovoltaic systems, it is often difficult to achieve timely and accurate anomaly detection due to the influence of weather, equipment aging and external environmental changes. The existing photovoltaic panel wind damage prediction methods can be roughly divided into the following types:
[0003] 1. Anomaly detection method based on rules and threshold setting: The traditional photovoltaic anomaly detection method mainly relies on manually set threshold and rules. These methods monitor the operating parameters such as voltage and current of photovoltaic components, and set a threshold value. When the parameter exceeds the threshold, it is determined as an anomaly. For example, if the current value is below a certain level, it is determined as a fault. The advantage of this method is that it is simple to implement and does not require a large amount of data training. However, the disadvantage is that it relies on manually set threshold for detection, lacks intelligent and efficient automatic detection mechanism, and thus lacks sufficient adaptability when facing dynamic changes of photovoltaic systems and environmental conditions, which easily leads to false positives and false negatives. Moreover, when the system environment changes, the threshold setting is often difficult to adapt to new abnormal patterns, and needs to be adjusted manually, which leads to low detection accuracy and inability to cope with complex photovoltaic system operating conditions, seriously affecting the stability and efficiency of photovoltaic power generation.
[0004] 2. Anomaly detection method based on statistical analysis: The anomaly detection method based on statistical model analyzes the historical data, extracts typical abnormal patterns, and then uses statistical methods (such as mean, standard deviation, etc.) to judge whether the current data is consistent with the historical pattern. Although this method can capture anomalies to some extent, it usually relies on a large amount of historical data for modeling. In actual application, the abnormal data of photovoltaic system is relatively rare, which makes it difficult for statistical model to effectively detect anomalies in the case of insufficient data. Moreover, due to the large changes in the operating environment of photovoltaic system, statistical methods often cannot handle complex nonlinear relationships, and are difficult to cope with real-time changes, which easily leads to deviation.
[0005] 3. Deep learning-based anomaly detection methods: In recent years, deep learning techniques such as Convolutional Neural Networks (CNN), Long Short-Term Memory Networks (LSTM), and others have been introduced into the field of anomaly detection in photovoltaic systems. Deep learning can extract deep-level features from data through multi-layer network structures, improving the accuracy and robustness of detection. For example, CNN can extract useful features from image data of photovoltaic systems, while LSTM can model time-series data and identify abnormal patterns in the data. However, these methods usually require a large amount of data, need a large number of training samples, and have a complex training process. At the same time, deep learning models consume high computational resources, making it difficult to apply them in real-time monitoring and resource-limited environments.
[0006] In summary, existing anomaly detection methods rely heavily on rules based on threshold settings or simple statistical analysis, lacking intelligent and efficient automatic detection mechanisms, resulting in frequent false positives and false negatives, seriously affecting the stability and efficiency of photovoltaic power generation. At the same time, traditional methods show low detection accuracy and flexibility when faced with low sample, unbalanced data, and complex fault patterns. SUMMARY
[0007] The purpose of the present application is to overcome the existing defects and provide a photovoltaic anomaly detection method, system, device and medium based on contrast learning.
[0008] To solve the above technical problems, the present application provides the following technical solutions:
[0009] The first purpose of the present application is to provide a photovoltaic anomaly detection method based on contrast learning, comprising:
[0010] Step one, data preprocessing and data enhancement: collect the running data of the photovoltaic system, clean and denoise the sensor data in the collected data, normalize all collected data, and enhance the time series data in the collected data;
[0011] Step two, constructing a feature learning model based on contrast learning: using a heterogeneous graph convolutional network to obtain feature representation of the collected data, using a graph convolutional network to learn features of the photovoltaic system data, and using a contrast learning model to optimize the feature learning effect, inputting the feature vectors generated by the graph convolutional network and the contrast learning model into a convolutional neural network for anomaly detection classification, and outputting probability values of normal or abnormal;
[0012] Step three, using a joint loss function combining contrast loss and classification loss and an end-to-end backpropagation mechanism to collaboratively optimize the feature learning model and the model used for anomaly classification;
[0013] Step four, model deployment and real-time anomaly detection: evaluate and verify the trained and optimized convolutional neural network model, and deploy it to the real-time monitoring platform of the photovoltaic system after verification. The deployed convolutional neural network model receives real-time data streams from the photovoltaic system, and when the output result is greater than the preset threshold, the photovoltaic system triggers the alarm mechanism.
[0014] Further, in step one, the types of collected data include: output voltage data of photovoltaic modules, output power data of photovoltaic modules, environmental light intensity data, photovoltaic panel surface temperature data, photovoltaic system output power data and inverter efficiency data.
[0015] Further, in the data cleaning and denoising of the sensor data in the collected data, a median filter is used to remove sharp noise in the sensor data, and the filter window size is set to 5 points, and the calculation formula is as follows:
[0016]
[0017] Wherein, is the denoised signal value. For missing values that occur during the data collection process, linear interpolation is used for filling.
[0018] Further, in the data normalization processing of all collected data, the maximum and minimum normalization method is used for all collected data, and each data is normalized to the [0, 1] interval, which is specifically expressed as:
[0019]
[0020] Wherein, x is the original data, min(x) and max(x) are the minimum and maximum values of the data, respectively.
[0021] Further, in the data enhancement processing of the time series data in the collected data, first, the time series data is randomly scaled in the time window, a 10-second time window is selected, and the data is resampled in the time window. Then, Gaussian noise is added to the data to enhance the training data, and the noise standard deviation is set to 10% of the maximum value of the original data, and the injection formula is as follows:
[0022] x' = x + ∈, ∈ ~ N(0, 0.1 x max(x))
[0023] Wherein, ∈ is Gaussian noise, x' is the enhanced training data, and x is the original time series data.
[0024] Further, the contrast learning model uses positive sample pairs and negative sample pairs to train the model to learn more distinctive feature representations, and the loss function is defined as follows:
[0025]
[0026] wherein sim(f(x), f(x')) represents cosine similarity, and tau is a temperature parameter;
[0027] The convolutional neural network model is represented as:
[0028] y=CNN(GCN(x))
[0029] The loss function is defined as follows:
[0030]
[0031] wherein y i is the true label of the sample, and p i is the abnormal probability predicted by the model.
[0032] Further, in the training and optimization of the convolutional neural network model, a joint loss function is used, combining the contrast loss and the classification loss, and the loss function is defined as follows:
[0033] L total = alpha L contrast + beta L classification
[0034] wherein alpha=0.7, and beta=0.3.
[0035] The Adam optimizer is used for optimization, the learning rate is set to 0.001, and the hyperparameters are set to beta1=0.9 and beta2=0.999, respectively.
[0036] Another purpose of the present application is to provide a photovoltaic anomaly detection system based on contrast learning, comprising:
[0037] A data acquisition module is used to acquire the operation data of the photovoltaic system by using a plurality of different functional sensors.
[0038] A data preprocessing module is used to clean, denoise and normalize the collected operation data.
[0039] A data enhancement module is used to perform data enhancement processing on the time series data in the collected data.
[0040] A model construction module is used to construct a feature learning model based on contrast learning: a heterogeneous graph convolutional network is used to obtain the feature representation of the collected data, a graph convolutional network is used to perform feature learning on the photovoltaic system data, and a contrast learning model is used to optimize the feature learning effect, and the deep features obtained after optimization of the contrast learning model are used as the input of the convolutional neural network model, and the probability value of normal or abnormal is output.
[0041] a model training and optimization module configured to train and optimize the constructed model;
[0042] a model deployment and detection module configured to evaluate and verify the trained and optimized convolutional neural network model, deploy the model to a real-time monitoring platform of the photovoltaic system after verification, and receive real-time data streams from the photovoltaic system using the deployed convolutional neural network model, and trigger an alarm mechanism of the photovoltaic system when an output result is greater than a preset threshold.
[0043] Another object of the present application is to provide an electronic device comprising a processor and a memory storing a computer program, wherein the processor implements the photovoltaic anomaly detection method based on contrast learning provided in the first object of the present application when executing the computer program.
[0044] Another object of the present application is to provide a computer readable storage medium storing a computer program, wherein the computer program implements the photovoltaic anomaly detection method based on contrast learning provided in the first object of the present application when executed by a processor.
[0045] In combination with the above technical solutions, the present application has the following beneficial effects compared with the prior art:
[0046] 1. Feature learning is performed by introducing contrast learning:
[0047] The present application uses a contrast learning algorithm (such as SimCLR) to optimize feature representation, which is different from the direct classification training of most existing deep learning methods. Traditional methods often have difficulty in fully learning the subtle differences between normal and abnormal states when dealing with problems such as the scarcity of photovoltaic system anomaly data and data imbalance, and have poor generalization ability for new types of abnormal patterns. Contrast learning promotes the model to learn a more discriminative feature space by constructing positive and negative sample pairs, so that the feature distance of the same class samples is closer and the feature distance of different class samples is farther.
[0048] Direct technical effect one: significantly improve the accuracy and robustness of anomaly detection. Contrast learning enables the model to adaptively capture the intrinsic features of normal behavior patterns, so that it can still maintain high precision when facing complex and dynamically changing photovoltaic operating environments and slight or hidden abnormalities, reducing false positives and false negatives caused by relying on manually set thresholds.
[0049] Direct technical effect two: enhanced generalization detection ability of the model for unseen abnormal patterns. The feature representation trained by contrast learning has better semantic invariance, so that the model can not only recognize trained abnormal types, but also effectively identify new or variant abnormalities that have not appeared in the training set based on the distance relationship in the feature space.
[0050] Direct technical effect three: effectively deal with data scarcity and imbalance. Contrastive learning can learn high-quality features from a large amount of unlabeled normal data in an unsupervised or self-supervised manner, greatly reducing the dependence on a large amount of labeled abnormal data, and reducing the data threshold and cost of model training.
[0051] 2. Adopting heterogeneous graph convolutional network (HGCN) to fuse multi-modal data:
[0052] In the prior art, most methods often use simple splicing or independent processing when dealing with multi-sensor data, which is difficult to effectively mine the complex interdependent relationships and structural information between different types of data (such as voltage, current, temperature, and illumination intensity). The present application innovatively introduces HGCN, which regards different sensor data in the photovoltaic system as nodes in the heterogeneous graph, and captures their physical association and logical relationship through graph convolution operation.
[0053] Direct technical effect one: comprehensively improves the recognition ability of the photovoltaic system abnormal state. HGCN can deeply fuse and utilize multi-dimensional data such as current, voltage, temperature, and illumination intensity, analyze the overall operation status of the photovoltaic system from a more macro and correlated perspective, effectively capture abnormal patterns that cannot be revealed by a single data source, and greatly improve the comprehensiveness and reliability of abnormal detection.
[0054] Direct technical effect two: accurately capture the complex correlation between multi-dimensional data. Compared with traditional methods, HGCN can model and learn the nonlinear and dynamic relationships between parameters in the photovoltaic system, such as the nonlinear relationship between illumination intensity and output power, the influence of temperature on component performance, etc., so that the model's judgment of abnormalities is based on a more comprehensive evidence chain.
[0055] 3. Combined with data augmentation technology:
[0056] Abnormal data of photovoltaic systems is usually scarce and difficult to obtain in actual operation, which poses a challenge to model training. The present application generates more diversified training samples by means of random time window scaling and Gaussian noise injection on time series data, while ensuring the physical properties of the data.
[0057] Direct technical effect: effectively alleviates the problem of scarcity and imbalance of abnormal data, and significantly improves the generalization ability of the model. Data augmentation expands the size and diversity of the training data set, so that the model can fully learn the distribution characteristics of the limited real abnormal data, avoid overfitting, and enhance the robustness of the model when facing actual complex and variable working conditions.
[0058] The application improves the accuracy and reliability of photovoltaic system anomaly detection through deep feature learning and enhancement of multi-modal data, automatically identifies and distinguishes normal and abnormal states using a contrast learning algorithm, reduces human intervention, and improves the automation level and operation efficiency of the system, thereby providing technical support for efficient management and maintenance of photovoltaic systems. By introducing a contrast learning algorithm, the similarity relationship between normal and abnormal data can be automatically learned, eliminating the defects of manually setting thresholds, not only improving the adaptability of the model in different photovoltaic systems, but also significantly enhancing the detection ability in unobserved abnormal patterns, thereby improving the precision and robustness of anomaly detection.
[0059] The application effectively alleviates the problems of abnormal data scarcity and data imbalance through data enhancement technology. Data enhancement methods such as noise injection and time disturbance can generate more training samples, especially in the case of abnormal data scarcity, which helps to improve the model's learning ability for abnormal patterns. Compared with traditional methods, the application can maintain high detection accuracy with less labeled data, avoiding the drawbacks of relying on a large amount of manually labeled data, so that the model can maintain high detection accuracy even in the case of insufficient data. The problems of low prediction accuracy, poor real-time performance, and insufficient generalization ability in the prior art are solved.
[0060] The application can comprehensively consider current, voltage, temperature, and light intensity through the fusion of multi-modal data in photovoltaic systems by a heterogeneous graph convolution network (HGCN), and can comprehensively improve the recognition ability of abnormal states of photovoltaic systems. Traditional methods usually only rely on a single data source or static features, while the application effectively captures the complex relationship between different data sources through deep learning of multi-dimensional data, thereby improving the comprehensiveness and accuracy of detection. BRIEF DESCRIPTION OF DRAWINGS
[0061] The accompanying drawings are used to provide a further understanding of the application, and constitute a part of the specification, together with the embodiments of the application, to explain the application, and do not constitute a limitation on the application. In the drawings:
[0062] Figure 1 is a flowchart of the photovoltaic anomaly detection method based on contrast learning provided by the embodiment of the application;
[0063] Figure 2 is a structural principle diagram of the feature learning model based on contrast learning provided by the embodiment of the application;
[0064] Figure 3 is a structural block diagram of the photovoltaic anomaly detection system based on contrast learning provided by the embodiment of the application.
[0065] In the figure: 1, data acquisition module; 2, data preprocessing module; 3, data enhancement module; 4, model construction module; 5, model training and optimization module; 6, model deployment and detection module. DETAILED DESCRIPTION
[0066] The preferred embodiments of the present application are described below in conjunction with the accompanying drawings, and it should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application.
[0067] Embodiment 1:
[0068] As Figure 1 shown, one embodiment of the photovoltaic anomaly detection method based on contrast learning provided by the present application, specifically comprising the following steps:
[0069] S1: data preprocessing and data enhancement: collecting the operation data of the photovoltaic system, performing data cleaning and denoising on the sensor data in the collected data, performing data normalization processing on all collected data, and performing data enhancement processing on the time series data in the collected data;
[0070] S2: constructing a feature learning model based on contrast learning: using a heterogeneous graph convolution network to obtain feature representation of the collected data, using a graph convolution network to learn features of the photovoltaic system data, and using a contrast learning model to optimize the feature learning effect, inputting the feature vectors generated by the graph convolution network and the contrast learning model into a convolutional neural network for anomaly detection classification, and outputting probability values of normal or abnormal;
[0071] S3: using a joint loss function combining contrast loss and classification loss and an end-to-end back propagation mechanism to collaboratively optimize the feature learning model and the model used for anomaly classification;
[0072] S4: model deployment and real-time anomaly detection: evaluating and verifying the trained and optimized convolutional neural network model, deploying the convolutional neural network model to the real-time monitoring platform of the photovoltaic system after passing the verification, and the deployed convolutional neural network model receiving real-time data stream from the photovoltaic system, and when the output result is greater than a preset threshold, the photovoltaic system triggers an alarm mechanism.
[0073] The technical solutions of the embodiments of the present application will be described in detail below in conjunction with specific implementation steps.
[0074] Step one: data preprocessing and data enhancement:
[0075] 1. Raw data collection:
[0076] To ensure the accuracy of the anomaly detection of the photovoltaic system, the raw data collection must cover the most common operating parameters in the photovoltaic system. Specifically, using a data collection device with a high sampling frequency (1 Hz), real-time tracking of all parameters, data collection every 5 minutes, recording 24 hours of photovoltaic system operation data, the types of data collected include:
[0077] Output voltage of photovoltaic module (Voltage): voltage data of each photovoltaic panel, unit: volt (V).
[0078] Output current of photovoltaic module (Current): current data of each photovoltaic panel, unit: ampere (A).
[0079] Output power of photovoltaic module (Power): power data calculated from current and voltage, unit: watt (W).
[0080] Ambient light intensity (Irradiance): solar radiation intensity reaching the photovoltaic panel per unit time, unit: watt per square meter (W / m 2 ).
[0081] Module temperature (Temperature): surface temperature data of photovoltaic panel, unit: Celsius (℃).
[0082] System output power (System Power Output): output power of the entire photovoltaic system, unit: kilowatt (kW).
[0083] 2. Data cleaning and denoising:
[0084] A median filter is used to remove sharp noise in sensor data, with a filter window size of 5 points. This can remove high-frequency noise caused by sensor errors or transient interference, and the calculation formula is as follows:
[0085]
[0086] where, is the denoised signal value. For missing values that may occur during data collection, linear interpolation is used to fill in the missing values to ensure data integrity.
[0087] 3. Data normalization
[0088] All collected data is normalized to the [0, 1] interval using the maximum and minimum normalization method. The specific method is as follows:
[0089]
[0090] where x is the original data, min(x) and max(x) are the minimum and maximum values of the data, respectively.
[0091] 4. Data augmentation:
[0092] To increase the generalization ability of the model through data augmentation, first, the time series data is randomly scaled in time window. A 10-second time window is selected, and the data is resampled within the window. Then, the training data is augmented by adding Gaussian noise to the data. The noise standard deviation is set to 10% of the maximum value of the original data. The injection formula is as follows:
[0093] x' = x + ∈, ∈ ~ N(0, 0.1 x max(x))
[0094] where ∈ is the Gaussian noise, x' is the augmented training data, and x is the original time series data.
[0095] It should be noted that in the photovoltaic anomaly detection method, the time series data is continuously recorded and changed over time, including the output voltage, output current, output power, environmental light intensity, photovoltaic panel surface temperature, photovoltaic system output power, and inverter efficiency data of the photovoltaic assembly. Sensor data is obtained directly by physical sensor measurement, including output voltage, output current, environmental light intensity, and photovoltaic panel surface temperature data of the photovoltaic assembly.
[0096] Step 2: Constructing a feature learning model based on contrastive learning:
[0097] 1. Graph construction:
[0098] Graph construction is a key step to associate photovoltaic data with environmental data. The present application uses a heterogeneous graph convolutional network (HGCN) to process data from different sources, thereby obtaining rich feature representations.
[0099] Node definition: The collected sensor data in each photovoltaic system is taken as a node in the graph. For example, the voltage, current, power, temperature, etc. of each photovoltaic panel can be taken as an independent node. Environmental data is also taken as a node of the graph.
[0100] Edge definition: The edge represents the relationship between nodes. The current node and the voltage node of the photovoltaic panel can establish an edge through a physical model, reflecting their mutual influence relationship. Similarly, edges are established between environmental data nodes through similarity.
[0101] Adjacency matrix construction: The adjacency matrix A is obtained by calculating the similarity between different nodes, and the cosine similarity is used as the similarity measure between nodes, and the calculation formula is as follows:
[0102]
[0103] where ||x i || and ||x j || is the L2 norm of node x i and x j .
[0104] 2. Graph Convolutional Network (GCN) construction:
[0105] By constructing the graph structure, the photovoltaic system data is learned using the graph convolutional network (GCN), and the specific formula is as follows:
[0106] H( l+1) = σ(A^H (l) W (l) )
[0107] where A^ is the normalized adjacency matrix, H (l) is the node representation of the l-th layer, W (l) is the weight matrix of the l-th layer, and σ is the ReLU activation function.
[0108] 3. Contrastive Learning Module (SimCLR) construction:
[0109] Using the SimCLR framework, the effect of feature learning is further improved through contrastive learning. SimCLR uses positive sample pairs and negative sample pairs to train the model to learn more discriminative feature representations. The loss function is defined as follows:
[0110]
[0111] where sim(f(x), f(x')) represents the cosine similarity, and τ is the temperature parameter.
[0112] Specifically, the core function of this loss function is to encourage the model to learn more discriminative feature representations, and this purpose is achieved through the following mechanisms:
[0113] Close positive sample pairs: Encourage different augmented views (i.e. positive sample pairs) from the same original data sample to be as close as possible (similarity as high as possible) in the feature space. For example, for a normal PV system running data sample x, after two different data augmentations (such as random scaling and noise injection), x and x' are obtained, L contrast to ensure that f(x) and f(x') are maximized.
[0114] Push-away negative sample pair distance: penalize the distance of feature representations (i.e. negative sample pairs) from different original data samples in the feature space, so that they are as far as possible (similarity is as low as possible). For example, for sample x, any other sample x j (j = i) is considered as a negative sample, L contrast to ensure that the similarity of f(x) and f(x j ) is minimized.
[0115] Through this mechanism of "pulling the same and pushing the different", the model can learn a feature space in which normally running data samples are clustered together, while abnormal data samples maintain a significant distance from normal data samples, thereby enhancing the model's ability to identify abnormalities. This is particularly important in photovoltaic anomaly detection, as it helps the model effectively distinguish abnormalities by learning the distribution characteristics of normal data even with only a small amount of abnormal data.
[0116] 2. The full meaning of sim(f(x), f(x')) is to calculate the cosine similarity between the feature representation f(x) of the original data sample x and the feature representation f(x') of its enhanced view x'. The higher this similarity value, the better the model learns the feature representation that captures the common and invariant features of x and x' (which are essentially the same sample).
[0117] 4. Anomaly detection classification:
[0118] Take the features generated by GCN and SimCLR as input, pass them through a convolutional neural network (CNN) for classification, and output the probability of being normal or abnormal.
[0119] Input: feature vectors generated by GCN and SimCLR.
[0120] Convolutional layer: use 3 layers of convolutional layer with kernel size 3x3, stride 1, and ReLU activation function.
[0121] Pooling layer: use 2x2 max pooling layer with stride 2.
[0122] Fully connected layer: 2 layers of fully connected layer, output the probability value of being normal or abnormal.
[0123] In the entire anomaly detection classification process, the output calculation formula of the convolutional neural network (CNN) combined with the graph convolutional network (GCN) or the representation of the overall classification process is as follows:
[0124] y = CCNN(GCN(x))
[0125] x represents the original input data, GCN(x) denotes the feature representation extracted from the original data x after processing by the graph convolutional network (GCN). CNN(GCN(x)) represents the processing of the features extracted by GCN(x) as input through the convolutional neural network (CNN), and finally outputs y. y is the probability value of normal or abnormal predicted by the model. This formula accurately expresses the entire classification link from the original data to the final abnormal probability output, that is, CNN receives the features extracted by GCN (optimized by contrast learning) for classification.
[0126] The classification loss function is defined as follows:
[0127]
[0128] where y i is the true label of the sample, and p i is the abnormal probability predicted by the model.
[0129] The role of the classification loss function in this step (i.e., the training and optimization of the convolutional neural network model, and the final anomaly detection classification) is:
[0130] (1) Measure the accuracy of classification prediction: quantify the difference between the abnormal probability p i predicted by the model (especially the CNN part) and the true label y i of the sample.
[0131] (2) Drive the model to learn correct classification: during the model training process, the optimizer (such as Adam) will try to minimize this loss function. Minimizing the loss means that when the true label y i is 1 (abnormal), the model will strive to make the predicted probability p i close to 1.
[0132] Step three: model training and optimization:
[0133] 1. Data division:
[0134] Divide the data into a training set (70%), a validation set (15%), and a test set (15%).
[0135] 2. Loss function:
[0136] Use the joint loss function, combining the contrast loss and the classification loss, and the loss function is finally defined as follows:
[0137] L total = αL contrast + βL classification
[0138] where α = 0.7, β = 0.3. L contrastThe contrastive loss is the optimization objective of the contrastive learning model (SimCLR), aiming to make the model learn more discriminative feature representations. classification The classification loss is the optimization objective of the final convolutional neural network (CNN), aiming to make the model accurately classify anomalies.
[0139] By linearly combining these two loss functions, the model optimizes both the quality of features and the accuracy of classification during training. This means that the HGCN, GCN, and SimCLR part of the feature extraction network are optimized according to the contrastive loss, while the CNN is optimized according to the classification loss, both of which work together to optimize the parameters of the entire model.
[0140] The core role of the joint loss function is to synergistically optimize the entire photovoltaic anomaly detection model, achieving the following two main goals:
[0141] (1) Improve the quality of feature representations (through L contrast ): L contrast The contrastive loss aims to make the model learn more discriminative feature representations. It pulls the distance between different augmented views of the same original data sample (positive sample pairs) in the feature space, while pushing the distance between different samples (negative sample pairs), so that the model can better understand the intrinsic structure and similarity of the data. This is crucial for anomaly detection, as it allows the model to tightly cluster normal patterns in the feature space, making it easier to identify anomalies that deviate from these clusters.
[0142] (2) Ensure the accuracy of classification (through L classification ): L classification The classification loss, i.e., binary cross-entropy loss, aims to ensure that the model's final classifier (CNN) can accurately classify input data into "normal" or "abnormal" categories. It directly measures the difference between the model's predicted probabilities and the true labels.
[0143] By linearly combining these two loss functions, the joint loss function enables end-to-end training. This means that during optimization, the model not only learns how to classify, but also simultaneously learns how to extract high-quality features and how to accurately classify based on these features. This joint optimization is particularly suitable for photovoltaic anomaly detection scenarios where data is imbalanced (abnormal data is rare), as contrastive learning can learn general and robust features from a large amount of normal data, while the classification loss guides the model to specialize in learning for the anomaly detection task. Through the weight settings of α and β, the optimization objectives of these two aspects can be balanced.
[0144] 3. Optimization algorithm:
[0145] Using the Adam (Adaptive Moment Estimation) optimizer with a learning rate set to 0.001, β1 = 0.9, and β2 = 0.999.
[0146] β1 and β2 are hyperparameters of the Adam optimizer. In the Adam optimizer, β1 is the exponential decay rate of the first moment estimate (i.e., the first-order exponentially weighted moving average of the gradients). It controls the degree of influence of previous gradient information on the current update. A higher β1 value (close to 1) means that the first moment estimate of the gradient retains more historical information, making the parameter update smoother. β2 is the exponential decay rate of the second moment estimate (i.e., the second-order exponentially weighted moving average of the gradient squares). It controls the degree of influence of previous gradient square information on the current update. A higher β2 value (close to 1) means that the second moment estimate of the gradient retains more historical information, helping to provide a more stable adaptive learning rate for each parameter.
[0147] It should be noted that the deep features obtained after optimizing the contrastive learning model in the present application are explicitly used as the "input of the convolutional neural network model". This indicates that the output of HGCN, GCN and SimCLR (i.e., the feature learning module) is the input of CNN, and they form a complete computational graph when calculating the joint loss.
[0148] Through the Adam optimizer, the backpropagation algorithm calculates and updates the gradients of all trainable parameters on the entire computational graph, including all layers of HGCN, GCN, SimCLR and CNN, thereby achieving joint training and optimization of the entire model.
[0149] In summary, the training and optimization of the present application is a holistic process. Through the joint loss function and the end-to-end backpropagation mechanism, the collaborative optimization of parameters between the feature learning module (HGCN, GCN, SimCLR) and the classification module (CNN) is ensured, so that the model can learn more effective and discriminative features to improve the accuracy and reliability of photovoltaic anomaly detection.
[0150] Step four: model deployment and real-time anomaly detection:
[0151] 1. Model deployment:
[0152] Once the model has been optimized and validated in the training phase, it can be deployed to the real-time monitoring platform of the photovoltaic system. The deployment process is as follows:
[0153] Deployment platform: Select a server hardware platform to run the model and support the connection with the real-time data interface of the photovoltaic system. The deployed model should be able to receive real-time data streams from the photovoltaic system.
[0154] API Interface: Build a data interface with photovoltaic system devices, the model can receive real-time data from photovoltaic system devices. The interface uses RESTful API for communication.
[0155] Inference Engine: Use optimized inference engine during deployment to accelerate inference process and improve real-time response capability.
[0156] 2. Real-time data input:
[0157] After the system is deployed, the real-time data input processing flow is as follows:
[0158] Data collection: The sensors of the photovoltaic system start real-time data collection, including voltage, current, power, temperature, light intensity, inverter efficiency, etc. shown in step one. The data collection frequency is every 30 seconds (anomaly detection frequency).
[0159] 3. Feature learning and contrastive learning:
[0160] GCN module: GCN module learns the relationship between node features in graph structure, extracts the correlation between different sensors and environmental data. GCN extracts valuable features from each photovoltaic component and environmental parameters, and performs graph convolution calculation.
[0161] SimCLR module: SimCLR module further optimizes the feature representation obtained from GCN module. It generates positive and negative sample pairs and calculates contrastive loss to maximize the similarity between normal state samples and minimize the similarity between abnormal state and normal state samples, thereby enhancing the discriminative ability of feature learning.
[0162] The contrastive loss is defined as follows:
[0163]
[0164] Where sim(f(x), f(x')) represents the cosine similarity, and τ is the temperature parameter.
[0165] 4. Anomaly detection classification:
[0166] CNN classification module: Based on the deep features generated by SimCLR, use convolutional neural network (CNN) for anomaly detection. CNN module learns anomaly patterns from feature vectors output by GCN and SimCLR through convolution, pooling and fully connected layers, and outputs anomaly detection results. Compare the anomaly score output by the model with the set threshold. If the anomaly score is greater than the threshold, the system determines that the current data point is abnormal. Specifically, the threshold is set to 0.7. The classification loss is defined as follows:
[0167]
[0168] where y i is the true label of the sample, p i is the abnormal probability predicted by the model.
[0169] 5. Abnormal alarm and feedback:
[0170] If an anomaly is detected (the model output result is greater than the threshold value), the system will trigger an alarm mechanism to notify the maintenance personnel.
[0171] The present application has made significant progress in the field of photovoltaic anomaly detection, and its core innovation lies in the deep integration of heterogeneous graph convolution network (HGCN) and contrastive learning, supplemented by data enhancement technology, thereby realizing efficient and robust anomaly detection of multi-modal photovoltaic data. In order to verify the significant technical effects brought by the technical scheme of the present application, a series of experiments are carried out in the embodiments of the present application, and the present application scheme is compared with two typical methods in the prior art: one is the traditional method based on threshold value (representing rule and statistical analysis method), and the other is the anomaly detection method based on traditional CNN (representing general deep learning method, not containing the synergistic effect of contrastive learning and HGCN).
[0172] 1. Experimental setup:
[0173] Dataset: The experiment uses real operation data of a large photovoltaic power station, covering multi-modal sensor data for one year, totaling about several million data points. The data contains normal operation modes under different seasons and weather conditions, as well as various typical abnormal events annotated by experts (such as component failure, inverter abnormality, sensor drift, line aging, etc.). The abnormal data samples account for about 2% of the total data volume.
[0174] Evaluation index: General evaluation index of anomaly detection, including accuracy (Accuracy), recall (Recall), F1-Score, and AUC-ROC value for measuring the overall performance and generalization ability of the model. At the same time, attention is also paid to the false positive rate (False Positive Rate) and the false negative rate (False Negative Rate).
[0175] Comparison method:
[0176] Traditional threshold method: Based on historical data statistical analysis and industry experience, set fixed thresholds for key parameters of photovoltaic systems, and trigger abnormal alarm when the thresholds are exceeded.
[0177] Traditional CNN method: build a multi-layer convolutional neural network to directly classify the pre-processed multi-modal time series data to distinguish normal and abnormal patterns. This method does not contain a contrast learning module and does not specifically model the graph structure between data.
[0178] Invention scheme: according to the method of constructing, training and optimizing the model of the heterogeneous graph convolutional network (HGCN) combined with the convolutional neural network (CNN) based on the contrast learning described in this patent.
[0179] 2. Comparison of experimental results:
[0180] The following table shows the comparison results of the three methods in photovoltaic anomaly detection performance under the same data set and evaluation criteria:
[0181]
[0182] 3. Analysis of experimental results:
[0183] The above experimental data clearly demonstrates the significant technical effects brought by the invention:
[0184] The invention is significantly better than the traditional threshold method and the traditional CNN method in terms of accuracy, recall rate and F1-Score, etc. core detection indicators, which directly indicates its excellent performance in accurately identifying photovoltaic system anomalies. For example, the F1-Score of the invention reaches 93.7%, which is much higher than the 69.5% and 80.5% of the traditional methods, which verifies its effectiveness in accurately discovering anomalies while keeping low false positives.
[0185] The significant improvement in AUC-ROC value (from 0.71 / 0.84 to 0.95) is particularly important, which strongly proves the superiority of the invention scheme in generalization ability and ability to distinguish normal and abnormal patterns. This is mainly due to the contrast learning that enables the model to learn more discriminative feature representations, even if it faces new or variant abnormal patterns that have never appeared in the training set, it can be effectively identified through the relationship in the feature space, enhancing the robustness of the model.
[0186] At the same time, the false positive rate and the false negative rate of the invention scheme are significantly reduced. The false positive rate is reduced from 11.2% / 8.5% to 2.5%, which means that unnecessary on-site inspection and maintenance costs are greatly reduced; the false negative rate is reduced from 36.2% / 22.8% to 9.5%, which ensures that critical anomalies are not missed, avoids potential power generation loss or equipment damage, and ensures the safe and stable operation of the photovoltaic system.
[0187] In addition, the deep fusion of multi-modal data by the heterogeneous graph convolution network (HGCN) enables the model to comprehensively consider the operation states of the photovoltaic system in all aspects, avoids the limitation of a single data source, and thus exhibits more comprehensive recognition capability in complex abnormal scenarios.
[0188] In summary, the present application realizes the intelligentization, high precision and high reliability of photovoltaic system anomaly detection by integrating innovative technologies such as contrast learning, heterogeneous graph convolution network and data enhancement. Experimental data fully prove that the core problems such as low prediction accuracy, poor generalization ability and insensitivity to data scarcity in the prior art are effectively solved, providing strong technical support for efficient operation and maintenance of photovoltaic systems.
[0189] Embodiment 2
[0190] As shown in Figure 3 , the present application provides a photovoltaic anomaly detection system based on contrast learning, which comprises:
[0191] A data acquisition module 1 is used to acquire the operation data of the photovoltaic system by using a plurality of sensors with different functions;
[0192] A data preprocessing module 2 is used to clean, denoise and normalize the acquired operation data;
[0193] A data enhancement module 3 is used to perform data enhancement processing on the time series data in the collected data;
[0194] A model construction module 4 is used to construct a feature learning model based on contrast learning: a heterogeneous graph convolution network is used to obtain the feature representation of the collected data, a graph convolution network is used to learn the features of the photovoltaic system data, and a contrast learning model is used to optimize the feature learning effect. The deep features obtained after optimization of the contrast learning model are used as the input of the convolutional neural network model, and the probability value of normal or abnormal is outputted;
[0195] A model training and optimization module 5 is used to train and optimize the constructed model;
[0196] A model deployment and detection module 6 is used to evaluate and verify the trained and optimized convolutional neural network model, and after verification, it is deployed to the real-time monitoring platform of the photovoltaic system, and the real-time data stream from the photovoltaic system is received by using the deployed convolutional neural network model. When the output result is greater than the preset threshold, the photovoltaic system triggers the alarm mechanism.
[0197] Embodiment 3
[0198] The embodiment of the present application provides an electronic device, comprising a processor and a memory storing a computer program, and characterized in that the processor implements the photovoltaic anomaly detection method based on contrast learning provided by the embodiment 1 of the present application when executing the computer program.
[0199] Embodiment 4:
[0200] The embodiment of the present application provides a computer readable storage medium, which stores a computer program, and characterized in that the computer program is executed by a processor to implement the photovoltaic anomaly detection method based on contrast learning provided by the first purpose of the present application.
[0201] It should be understood that, although each step in the flowchart of each embodiment of the present application is displayed in sequence according to the arrow, these steps are not necessarily executed in sequence according to the arrow. Unless otherwise specified in the present application, the execution of these steps has no strict sequence limitation, and these steps can be executed in other orders. Moreover, at least part of the steps in each embodiment can include multiple sub-steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these sub-steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least part of other steps or sub-steps or stages of other steps.
[0202] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by a computer program instructing related hardware, and the program can be stored in a non-volatile computer readable storage medium. When the program is executed, it can include the processes of the above-mentioned embodiments of each method. Any reference to memory, storage, database or other medium used in each embodiment of the present application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration but not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0203] Finally, it should be noted that the above only describes the preferred embodiments of the present application and is not intended to limit the present application. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art will appreciate that the technical solutions described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalent ones. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A photovoltaic anomaly detection method based on contrastive learning, characterized in that, The method includes: Step 1, Data Preprocessing and Data Augmentation: Collect the operating data of the photovoltaic system, clean and denoise the sensor data in the collected data, normalize all the collected data, and augment the time series data in the collected data. Step 2: Construct a feature learning model based on contrastive learning: Use a heterogeneous graph convolutional network to obtain feature representations of the collected data, use the graph convolutional network to learn features of the photovoltaic system data, and use a contrastive learning model to optimize the effect of feature learning. Input the feature vectors generated by the graph convolutional network and the contrastive learning model into the convolutional neural network for anomaly detection and classification, and output the probability value of normal or abnormal. Step 3: Optimize the feature learning model and the anomaly classification model by using a joint loss function that combines contrastive loss and classification loss, and an end-to-end backpropagation mechanism. Step 4, Model Deployment and Real-time Anomaly Detection: The trained and optimized convolutional neural network model is evaluated and verified. After verification, it is deployed to the real-time monitoring platform of the photovoltaic system. The deployed convolutional neural network model receives real-time data streams from the photovoltaic system. When the output result is greater than the preset threshold, the photovoltaic system triggers an alarm mechanism.
2. The photovoltaic anomaly detection method based on contrastive learning according to claim 1, characterized in that, In step one, the types of data collected include: output voltage data of photovoltaic modules, output power data of photovoltaic modules, ambient light intensity data, surface temperature data of photovoltaic panels, output power data of photovoltaic systems, and inverter efficiency data.
3. The photovoltaic anomaly detection method based on contrastive learning according to claim 1, characterized in that, In the data cleaning and noise reduction process for the sensor data collected, a median filter is used to remove sharp noise from the sensor data. The filter window size is set to 5 points, and the calculation formula is as follows: in, The signal value is the denoised value. For missing values that occur during the data acquisition process, linear interpolation is used to fill them in.
4. The photovoltaic anomaly detection method based on contrastive learning according to claim 1, characterized in that, In the process of normalizing all collected data, the maximum-minimum normalization method is used to normalize all data to the [0,1] interval.
5. The photovoltaic anomaly detection method based on contrastive learning according to claim 1, characterized in that, In the data augmentation process for the time series data in the collected data, the time series data is first scaled by a random time window, and the data is resampled within the time window. Then, Gaussian noise is added to the data to augment the training data. The standard deviation of the noise is set to 10% of the maximum value of the original data. The injection formula is as follows: x′=x+∈,∈~N(0,0.1×max(x)) where, ∈ represents Gaussian noise, x' represents the enhanced training data, and x represents the original time series data.
6. The photovoltaic anomaly detection method based on contrastive learning according to claim 1, characterized in that, The contrastive learning model uses positive and negative sample pairs to train the model to learn more discriminative feature representations. The loss function is defined as follows: Where sim(f(x), f(x′)) represents the cosine similarity, and τ is the temperature parameter; The overall process of anomaly detection and classification is represented as follows: y = CNN(GCN(x)) The loss function is defined as follows: Among them, y i p is the true label of the sample. i This represents the probability of anomalies predicted by the model.
7. The photovoltaic anomaly detection method based on contrastive learning according to claim 1, characterized in that, In step three, the joint loss function is defined as follows: L total =αL contrast +βL classification Among them, α=0.7, β=0.3; The Adam optimizer was used for optimization, with a learning rate of 0.001 and hyperparameters set to β1 = 0.9 and β2 = 0.
999.
8. A photovoltaic anomaly detection system based on contrastive learning, characterized in that, The system includes: The data acquisition module is used to collect operating data of the photovoltaic system using several sensors with different functions; The data preprocessing module is used to clean, denoise, and normalize the collected operational data. The data augmentation module is used to perform data augmentation processing on the time series data in the collected data; The model building module is used to build a feature learning model based on contrastive learning: a heterogeneous graph convolutional network is used to obtain feature representations of the collected data, graph convolutional networks are used to learn features of photovoltaic system data, and the contrastive learning model is used to optimize the effect of feature learning. The deep features obtained after the contrastive learning model is optimized are used as input to the convolutional neural network model, and the output is a probability value of normal or abnormal. The model training and optimization module is used to train and optimize the constructed model; The model deployment and detection module is used to evaluate and verify the trained and optimized convolutional neural network model. After verification, it is deployed to the real-time monitoring platform of the photovoltaic system and uses the deployed convolutional neural network model to receive real-time data streams from the photovoltaic system. When the output result is greater than a preset threshold, the photovoltaic system triggers an alarm mechanism.
9. An electronic device comprising a processor and a memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the reservoir monitoring data synchronization method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the reservoir monitoring data synchronization method according to any one of claims 1 to 7.