Meteorological prediction method based on quantum convolution attention module
By introducing quantum convolutional attention module into the meteorological prediction model, combining quantum channels and spatial attention submodules, the problems of model complexity and computing resource limitations in numerical weather forecasts are solved, and more efficient meteorological prediction and accuracy are achieved promote.
Patent Information
- Application Number
- CN202411344253.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2044-09-25
AI Technical Summary
The existing numerical weather forecasting methods rely on complex mathematical models and are limited by computing resources, making it difficult to improve the accuracy of meteorological predictions.
Using a convolutional attention module based on quantum computing, the convolution processing and feature extraction of weather images is performed, and combined with quantum channels and spatial attention submodules, the channel and spatial attention characteristics are extracted, the model complexity is reduced, and the training convergence and Improve prediction accuracy.
It significantly improves the accuracy and training speed of the meteorological prediction model, achieves more efficient feature extraction and prediction results, and surpasses the performance of traditional SmaAt-UNet models.
Smart Images

Figure CN119247515A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of quantum computing technology, and more specifically, to a weather forecasting method based on a quantum convolutional attention module. Background Art
[0002] Accurate weather prediction is an important hallmark of modern industrialized society, and weather forecasts are widely used in the planning, organization, and management of personal and economic life. To date, the main method for weather forecasting is numerical weather prediction (NWP). NWP relies on mathematical models that take into account different physical properties of the atmosphere (such as air speed, pressure, and temperature). In related technologies, the mathematical models that can be used for NWP are relatively complex, and are limited by the consumption of computing resources, making it difficult to further improve the accuracy of weather forecasts. Summary of the invention
[0003] An embodiment of the present application provides a weather forecasting method based on a quantum convolution attention module.
[0004] The embodiment of the present application provides a weather forecasting method based on a quantum convolution attention module, and the weather forecasting method includes:
[0005] Input the meteorological image into the convolution module of the encoder of the pre-trained QCBAM-UNet model for convolution processing to obtain a preliminary feature map;
[0006] Inputting the preliminary feature map into a quantum convolution attention module of the encoder and processing it to obtain the meteorological feature map, wherein the quantum convolution attention module is configured to perform feature extraction based on quantum computing;
[0007] The meteorological feature map is jump-connected to the decoder of the QCBAM-UNet model and processed to obtain a prediction result.
[0008] In this way, the input image is input into the convolution module of the QCBAM-UNet model encoder to obtain a preliminary feature map, and the quantum convolution attention module is used to extract the features of the preliminary feature map to obtain an attention feature map, and the attention feature map is input into the decoder for processing to obtain the prediction result. By adding the quantum convolution attention module, the QCBAM-UNet model can be more focused on the target features, accelerate the convergence speed of the QCBAM-UNet model during training, and improve the accuracy of the prediction.
[0009] The present application embodiment provides a QCBAM-UNet model, and the QCBAM-UNet model includes:
[0010] An encoder, the encoder comprising a convolution module and a quantum convolution attention module, the convolution module is configured to perform convolution processing on an input image of the QCBAM-UNet model to obtain a preliminary feature map, and the quantum convolution attention module is configured to perform attention feature extraction on the preliminary feature map to obtain an attention feature map;
[0011] A decoder is used to process the attention feature map to obtain a prediction result.
[0012] In this way, by adding the quantum convolution attention module, the QCBAM-UNet model can be more focused on the target features, accelerate the convergence speed of the QCBAM-UNet model during training, and improve the accuracy of prediction.
[0013] In some embodiments, the quantum convolutional attention module includes:
[0014] A quantum channel attention submodule, wherein the quantum channel attention submodule is configured to extract a channel attention feature in the preliminary feature map to obtain a channel attention feature map;
[0015] A quantum spatial attention submodule, wherein the quantum spatial attention submodule is configured to extract spatial attention features in an intermediate feature map to obtain a spatial attention feature map, wherein the intermediate feature map is determined based on the preliminary feature map and the channel attention feature map, and the attention feature map is determined based on the spatial attention feature map and the intermediate feature map.
[0016] In combination with the maximum pooling process and the average pooling process, in some embodiments, the quantum channel attention submodule includes:
[0017] A first pooling unit, wherein the first pooling unit is configured to perform pooling processing on the spatial dimension features of the preliminary feature map;
[0018] A multi-layer perceptron is configured to extract channel attention features of the preliminary feature map after pooling.
[0019] In this way, the spatial dimension features in the preliminary feature map can be aggregated through the first pooling unit, so that the multilayer perceptron can better extract the channel attention features in the preliminary feature map.
[0020] In some embodiments, the multilayer perceptron includes a fully connected layer, an activation function, and a quantum neural network, and the quantum neural network is obtained according to a parameterized quantum circuit.
[0021] In this way, by adding a quantum neural network obtained based on parameterized quantum circuits to the multi-layer perceptron, the number of model parameters is effectively reduced, the training cost is reduced, and the convergence speed of the model is accelerated.
[0022] In certain embodiments, the quantum circuit comprises:
[0023] a mapping subunit, the mapping unit being configured to map an input parameter input into the quantum circuit to a quantum state;
[0024] A proposed subunit, wherein the proposed subunit is configured to process the input parameter of the quantum state to obtain a processing result;
[0025] A measurement subunit, wherein the measurement unit is configured to convert the processing result into a classical state to obtain the channel attention feature.
[0026] In some embodiments, the quantum spatial attention submodule includes:
[0027] A second pooling unit, wherein the second pooling unit is configured to perform channel dimension pooling processing on the intermediate feature map;
[0028] A quantum convolution unit, wherein the quantum convolution unit is configured to perform quantum convolution on the intermediate feature map after pooling through a quantum circuit to obtain the spatial attention feature map.
[0029] In this way, the introduction of quantum circuits improves the ability of quantum convolution units to express input features, allowing the model to extract and utilize features more accurately.
[0030] In some embodiments, the pooling process includes maximum pooling process and average pooling process.
[0031] In this way, combining maximum pooling and average pooling can enable the quantum attention module to better extract attention features.
[0032] In certain embodiments, the QCBAM-UNet model is trained by the following steps:
[0033] Inputting the meteorological training image into the convolution module of the encoder of the QCBAM-UNet model for convolution processing to obtain a preliminary training feature map;
[0034] Inputting the preliminary training feature map into a quantum convolution attention module of the encoder and processing it to obtain the meteorological training feature map, wherein the quantum convolution attention module is configured to perform feature extraction based on quantum computing;
[0035] Jump-connecting the meteorological training feature map to the decoder of the QCBAM-UNet model and processing it to obtain a predicted meteorological result;
[0036] Determine the loss function value according to the predicted meteorological results and the preset meteorological results;
[0037] The QCBAM-UNet model is adjusted according to the loss function value.
[0038] In this way, by determining the loss function value according to the predicted meteorological results and the preset meteorological results, and continuously adjusting the QCBAM-UNet model according to the loss function value, a pre-trained QCBAM-UNet model can be obtained.
[0039] In some embodiments, the loss function value is determined based on a loss weight, a mean square error loss value, and an absolute error loss value.
[0040] In this way, combining the mean square error and the mean absolute error can better evaluate the difference between the model prediction value and the actual observation value, so that it can be used to train the QCBAM-UNet model more effectively.
[0041] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0043] Figure 1 It is a schematic flow chart of a weather forecasting method according to an embodiment of the present application;
[0044] Figure 2 is a schematic diagram of a QCBAM-UNet model according to an embodiment of the present application;
[0045] Figure 3 is a schematic diagram of a quantum convolution attention module according to an embodiment of the present application;
[0046] Figure 4 is a schematic diagram of a quantum channel attention submodule of an embodiment of the present application;
[0047] Figure 5 is a schematic diagram of a quantum circuit according to an embodiment of the present application;
[0048] Figure 6 is a schematic diagram of a quantum spatial attention submodule of an embodiment of the present application;
[0049] Figure 7 is a schematic diagram of a quantum convolution unit according to an embodiment of the present application;
[0050] Figure 8 It is a schematic diagram of the training process of the QCBAM-UNet model in the implementation mode of the present application;
[0051] Fig. 9 It is a schematic diagram of the change of the training loss value with the number of training rounds in an implementation manner of the present application;
[0052] Fig.10 It is a schematic diagram of the change of the verification loss value with the number of training rounds in an implementation mode of the present application. DETAILED DESCRIPTION
[0053] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limiting the present application.
[0054] Accurately predicting the weather is an important hallmark of modern industrialized society, and weather forecasts are widely used in planning, organizing, and managing personal and economic life. To date, the main method for weather forecasting is numerical weather prediction (NWP). NWP relies on mathematical models that take into account different physical properties of the atmosphere, such as air speed, pressure, and temperature.
[0055] In the relevant technology, the mathematical models that can be used for NWP are relatively complex, and due to the consumption of computing resources, the accuracy of weather forecasts is difficult to further improve.
[0056] Based on the above possible problems, please refer to Figure 1 and Figure 2 The embodiment of the present application provides a weather forecasting method based on a quantum convolution attention module, the weather forecasting method comprising:
[0057] 011: Input the meteorological image into the convolution module 10 of the encoder 100 of the pre-trained QCBAM-UNet model 1000 for convolution processing to obtain a preliminary feature map;
[0058] 012: Input the preliminary feature map into the quantum convolution attention module 20 of the encoder 100 and process it to obtain a meteorological feature map, and the quantum convolution attention module 20 is configured to perform feature extraction based on quantum computing;
[0059] 013: Jump connect the meteorological feature map to the decoder 200 of the QCBAM-UNet model 1000 and process it to obtain the prediction result.
[0060] The embodiment of the present application provides a computer device, which includes one or more processors and a memory. The meteorological forecasting method of the embodiment of the present application can be implemented by the computer device of the embodiment of the present application. The processor can be used to input the meteorological image into the convolution module 10 of the encoder 100 of the pre-trained QCBAM-UNet model 1000 for convolution processing to obtain a preliminary feature map; and to input the preliminary feature map into the quantum convolution attention module 20 of the encoder 100 and process it to obtain a meteorological feature map, and the quantum convolution attention module 20 is configured to extract features based on quantum computing; It can also be used to jump connect the meteorological feature map to the decoder 200 of the QCBAM-UNet model 1000 and process it to obtain a prediction result.
[0061] The embodiment of the present application provides a weather forecasting device, which includes a first processing module, a second processing module and a third processing module. The weather forecasting method of the embodiment of the present application can be implemented by the weather forecasting device of the embodiment of the present application. The first processing module can be used to input the meteorological image into the convolution module 10 of the encoder 100 of the pre-trained QCBAM-UNet model 1000 for convolution processing to obtain a preliminary feature map; the second processing module can be used to input the preliminary feature map into the quantum convolution attention module 20 of the encoder 100 and process it to obtain a meteorological feature map, and the quantum convolution attention module 20 is configured to extract features based on quantum computing; the third processing module can be used to jump connect the meteorological feature map to the decoder 200 of the QCBAM-UNet model 1000 and process it to obtain a prediction result.
[0062] Specifically, the meteorological image includes multiple images containing precipitation data for a specified time period in the past. The meteorological image may include grid point data containing longitude and latitude, and each point represents the rainfall in a certain hour at the intersection of the longitude and latitude. For example, the meteorological image may be an image obtained by testing the rainfall in a certain place every hour for several consecutive months.
[0063] In some embodiments, hourly precipitation data from May to September in a certain place is collected as an image dataset, with a total of about 3,600 consecutive hours of rainfall data, that is, about 3,600 images. Three days of data are extracted from the image dataset as a test set, and the remaining images are divided into a training set and a validation set in a ratio of 8:2.
[0064] Furthermore, the meteorological images are preprocessed to avoid the appearance of zero values. The values contained in the training set and the validation set are added with preset values and then the logarithm is taken. Then the data are normalized according to the maximum and minimum values so that the data values are distributed in (0, 1]. The preset value is a preset smaller value, for example, it can be 0.001. The preset value can also be other values, which are not limited here.
[0065] For the prediction result, a sunny or rainy day threshold can be set. If the prediction result is greater than the sunny or rainy day threshold, it is predicted to be a rainy day. If it is less than the sunny or rainy day threshold, it is predicted to be a sunny day. In one embodiment, the sunny or rainy day threshold is set to 0.5, and the prediction result is greater than 0.5 and is considered to be a rainy day.
[0066] The performance of the QCBAM-UNet model 1000 (U-type network model based on quantum attention) can be measured by accuracy, which can represent the proportion of correct predictions made by the model in all predictions. Accuracy is applicable to classification problems, especially when the class distribution is relatively balanced, and can be used to evaluate the performance of the QCBAM-UNet model 1000 in predicting sunny and rainy days. In one embodiment, the accuracy of the QCBAM-UNet model 1000 on the test set reached 97.5%, which is higher than the SmaAt-UNet model without the quantum convolutional attention module 20.
[0067] In the related art, the conventional SmaAt-UNet model adds a convolutional block attention module (CBAM) to the U-type model (UNet) to enable the model to focus on target features. In addition, the conventional convolution operation is changed to a depth-separable convolution to reduce the number of parameters of the operation. However, when performing weather forecasting, the amount of calculation is large and the consumption of computing resources is large. Due to the complexity of the model and the consumption of computing resources, the accuracy of the prediction results obtained by using the conventional SmaAt-Unet model for weather forecasting is difficult to further improve.
[0068] The QCBAM-UNet model 1000 of the embodiment of the present application replaces the traditional attention module in the conventional SmaAt-UNet model with a quantum convolutional attention module (QCBAM), which significantly speeds up the training speed of the model while reducing the complexity of the model. The quantum convolutional attention module 20 can learn important features of different time and space regions. Since the quantum convolutional attention module 20 is based on quantum computing, adding the quantum convolutional attention module 20 to the model can reduce the complexity of the model and accelerate the convergence of the model.
[0069] Thus, the QCBAM-UNet model 1000, computer device, and computer-readable storage medium of the embodiment of the present application obtain a preliminary feature map by inputting the input image into the convolution module 10 of the QCBAM-UNet model 1000 encoder 100, and using the quantum convolution attention module 20 to extract features from the preliminary feature map to obtain an attention feature map, and the attention feature map is input into the decoder 200 for processing to obtain a prediction result. By adding the quantum convolution attention module 20, the QCBAM-UNet model 1000 can be more focused on the target features, accelerate the convergence speed of the QCBAM-UNet model 1000 during training, and improve the accuracy of the prediction.
[0070] See also Figure 2 In some embodiments, the QCBAM-UNet model 1000 includes an encoder 100 and a decoder 200, the encoder 100 includes a convolution module 10 and a quantum convolution attention module 20, the convolution module 10 is configured to perform convolution processing on the input image of the QCBAM-UNet model 1000 to obtain a preliminary feature map, and the quantum convolution attention module 20 is configured to extract attention features from the preliminary feature map to obtain an attention feature map; the decoder 200 is used to process the attention feature map to obtain a prediction result.
[0071] Specifically, see Figure 2 The QCBAM-UNet model 1000 of the implementation mode of the present application is designed based on the conventional SmaAt-Unet model.
[0072] The UNet model includes a multi-layer encoder 100 and a multi-layer decoder 200. The size of the preliminary feature map obtained by convolution of each layer of encoder 100 can be different, for example, it can be gradually reduced from top to bottom to form a U-shaped structure. The convolution module 10 of each layer of encoder 100 includes a dual depth-separable convolution. The quantum convolution attention module 20 is placed after each dual depth-separable convolution. It is worth noting that Figure 2 The number of layers and the size of the feature map of the encoder 100 and the decoder 200 are for illustration only, and the actual number of layers and the actual size can be set as required.
[0073] The quantum convolutional attention module 20 is a convolutional attention module designed based on quantum circuits. It can extract important features from the preliminary feature map to obtain an attention feature image, thereby suppressing redundant features while amplifying important features, effectively reducing training costs. Figure 2 The feature images filled with slashes in are the attention feature images.
[0074] Furthermore, the attention feature image can be fed back to the decoder 200 of the corresponding layer through a jump connection. The decoder 200 upsamples the attention feature image, splices the previous attention feature image output by the encoder 100 of the previous layer, performs convolution and other processing, and finally outputs the prediction result.
[0075] Thus, the QCBAM-UNet model 1000, computer device, and computer-readable storage medium of the embodiment of the present application obtain a preliminary feature map by inputting the input image into the convolution module 10 of the QCBAM-UNet model 1000 encoder 100, and using the quantum convolution attention module 20 to extract features from the preliminary feature map to obtain an attention feature map, and the attention feature map is input into the decoder 200 for processing to obtain a prediction result. By adding the quantum convolution attention module 20, the QCBAM-UNet model 1000 can be more focused on the target features, accelerate the convergence speed of the QCBAM-UNet model 1000 during training, and improve the accuracy of the prediction.
[0076] See also Figure 3 In some embodiments, the quantum convolution attention module 20 includes a quantum channel attention submodule 21 and a quantum spatial attention submodule 22. The quantum channel attention submodule 21 is configured to extract the channel attention features in the preliminary feature map to obtain a channel attention feature map; the quantum spatial attention submodule 22 is configured to extract the spatial attention features in the intermediate feature map to obtain a spatial attention feature map, the intermediate feature map is determined based on the preliminary feature map and the channel attention feature map, and the attention feature map is determined based on the spatial attention feature map and the intermediate feature map.
[0077] Specifically, the quantum convolutional attention module 20 includes a quantum channel attention submodule 21 and a quantum spatial attention submodule 22. The quantum channel attention submodule 21 is configured to learn the cross-channel features in the preliminary feature map to obtain a channel attention feature map. The channel attention feature map and the preliminary feature map are element-wise multiplied to obtain an intermediate feature map.
[0078] The quantum spatial attention submodule 22 is configured to learn the spatial features of the intermediate feature map to obtain a spatial attention feature map, and perform element-wise multiplication on the spatial attention feature map and the intermediate feature map to obtain an attention feature map.
[0079] The quantum spatial attention submodule 22 and the quantum channel attention submodule 21 are both implemented based on quantum circuits and can learn important features across channels and spatial regions without losing a large number of important features.
[0080] In this way, the quantum convolutional attention block learns important features across channels and spatial regions through the quantum spatial attention submodule 22 and the quantum channel attention submodule 21, effectively amplifying important features, suppressing redundant features, and improving the model's attention to key features.
[0081] See also Figure 4 In some embodiments, the quantum channel attention submodule 21 includes a first pooling unit 211 and a multi-layer perceptron 212. The first pooling unit 211 is configured to perform pooling processing on the spatial dimension features of the preliminary feature map; the multi-layer perceptron 212 is configured to extract the channel attention features of the preliminary feature map after pooling.
[0082] Specifically, the first pooling unit 211 is configured to perform pooling processing on the spatial dimension features of the preliminary feature map, compressing the spatial dimension of the preliminary feature map so that the channel attention features can be better inferred. The pooling processing includes maximum pooling processing and / or average pooling processing. In one embodiment, the first pooling unit 211 performs maximum pooling and average pooling on the spatial dimension features of the preliminary feature map.
[0083] The multi-layer perceptron 212 is configured to extract the channel attention features of the preliminary feature map after pooling to obtain a channel attention feature map, thereby realizing the extraction and learning of important features across channels.
[0084] In this way, the spatial dimension features in the preliminary feature map can be aggregated through the first pooling unit 211, so that the multi-layer perceptron 212 can better extract the channel attention features in the preliminary feature map.
[0085] In some embodiments, the multilayer perceptron 212 includes a fully connected layer, an activation function, and a quantum neural network 2121, where the quantum neural network 2121 is obtained based on a parameterized quantum circuit.
[0086] Specifically, the multilayer perceptron 212 includes a multilayer structure, and the neurons in each layer are connected to all the neurons in the previous layer, so that each neuron receives input from all the neurons in the previous layer and transmits its output to all the neurons in the next layer to form a fully connected layer, and an activation function is used on the neurons in each hidden layer and output layer.
[0087] The implementation method of the present application replaces part of the conventional multi-layer perceptron (MLP) with quantum neural networks (QNNs), which effectively reduces the number of parameters of the model and accelerates the convergence of the model.
[0088] Quantum neural network 2121 is a quantum algorithm based on parameterized quantum circuits, which can be trained in a variational manner using a classical optimizer, for example, Adam. The quantum circuit contains a feature map with input parameters and an ansatz with trainable weights.
[0089] Furthermore, in order to meet the needs of mapping different data features into quantum states, different feature mapping quantum circuits are implemented to map and transform quantum states. When there are multiple quantum bits, entanglement can be introduced through CNOT gates to improve the ability of quantum circuits to express attention features. In one embodiment, when the input feature is two-dimensional, the quantum circuit is as follows Figure 5 shown.
[0090] In this way, by adding the quantum neural network 2121 obtained according to the parameterized quantum circuit into the multi-layer perceptron 212, the number of model parameters is effectively reduced, the training cost is reduced, and the convergence speed of the model is accelerated.
[0091] In some embodiments, the quantum circuit includes: a mapping subunit, a hypothetical subunit and a measurement subunit, the mapping unit is configured to map the input parameters of the input quantum circuit to the quantum state; the hypothetical unit is configured to process the input parameters of the quantum state to obtain a processing result; the measurement unit is configured to convert the processing result to a classical state to obtain a channel attention feature.
[0092] Specifically, the mapping subunit is used to map the input parameters of the quantum circuit from the classical state to the quantum state, so as to realize the conversion from the classical state to the quantum state. The proposed subunit processes the input parameters of the quantum state and extracts the channel attention features. The proposed subunit includes trainable weights. When the QCBAM-UNet model 1000 is trained, the proposed trainable weights are also continuously adjusted so that the quantum neural network 2121 continuously adjusts the learning. The measurement subunit is used to measure the results obtained by the proposed subunit processing to convert the results into the classical state to obtain the channel attention features.
[0093] In this way, quantum circuits can be used to extract channel attention features using quantum computing and achieve conversion between classical and quantum states.
[0094] See also Figure 6 In some embodiments, the quantum spatial attention submodule 22 includes a second pooling unit 221 and a quantum convolution unit 222, the second pooling unit 221 is configured to perform channel dimension pooling processing on the intermediate feature map; the quantum convolution unit 222 is configured to perform quantum convolution on the intermediate feature map after pooling processing through a quantum circuit to obtain a spatial attention feature map.
[0095] Specifically, the second pooling unit 221 performs pooling processing on the channel features of the intermediate feature map. After the pooling processing, the channel feature dimension of the intermediate feature map is reduced. The quantum convolution unit 222 uses the quantum circuit as a convolution filter to extract the local sub-part of the intermediate feature map after the pooling processing and transform it, thereby realizing the extraction of spatial attention features and generating a spatial attention feature map. In one embodiment, the quantum convolution unit 222 is as follows: Figure 7 shown.
[0096] In this way, by introducing quantum circuits, the ability of the quantum convolution unit 222 to express input features is improved, so that the model can extract and utilize features more accurately.
[0097] In some embodiments, the pooling process includes a maximum pooling process and an average pooling process.
[0098] Specifically, the average pooling process can effectively learn the range of the target feature, and the maximum pooling process can better infer the channel attention. Combining the maximum pooling process and the average pooling process can make the quantum channel attention submodule 21 more focused on extracting the channel attention features, or make the quantum spatial attention submodule 22 more focused on extracting the spatial attention features.
[0099] In this way, combining maximum pooling and average pooling can enable the quantum attention module to better extract attention features.
[0100] See also Figure 8 In some embodiments, the QCBAM-UNet model 1000 is trained by the following steps:
[0101] 021: Input the meteorological training image into the convolution module 10 of the encoder 100 of the QCBAM-UNet model 1000 for convolution processing to obtain a preliminary training feature map;
[0102] 022: Input the preliminary training feature map into the quantum convolution attention module 20 of the encoder 100 and process it to obtain a meteorological training feature map, and the quantum convolution attention module 20 is configured to perform feature extraction based on quantum computing;
[0103] 023: Jump-connect the meteorological training feature map to the decoder 200 of the QCBAM-UNet model 1000 and process it to obtain the predicted meteorological result;
[0104] 024: Determine the loss function value according to the predicted meteorological results and the preset meteorological results;
[0105] 025: Adjust the QCBAM-UNet model 1000 according to the loss function value.
[0106] In certain embodiments, the training method of the QCBAM-UNet model 1000 of the embodiment of the present application can also be implemented by a processor, that is, the processor can be used to input the meteorological training image into the convolution module 10 of the encoder 100 of the QCBAM-UNet model 1000 for convolution processing to obtain a preliminary training feature map; input the preliminary training feature map into the quantum convolution attention module 20 of the encoder 100 and process it to obtain a meteorological training feature map, and the quantum convolution attention module 20 is configured to perform feature extraction based on quantum computing; jump connect the meteorological training feature map to the decoder 200 of the QCBAM-UNet model 1000 and process it to obtain a predicted meteorological result; determine the loss function value according to the predicted meteorological result and the preset meteorological result; and adjust the QCBAM-UNet model 1000 according to the loss function value.
[0107] In certain embodiments, the embodiments of the present application provide a training device, which includes a first training module, a second training module, a third training module, a determination module, and an adjustment module. Among them, the first training module can be used to input the meteorological training image into the convolution module 10 of the encoder 100 of the QCBAM-UNet model 1000 for convolution processing to obtain a preliminary training feature map; the second training module can be used to input the preliminary training feature map into the quantum convolution attention module 20 of the encoder 100 and process it to obtain a meteorological training feature map, and the quantum convolution attention module 20 is configured to extract features based on quantum computing; the third training module can be used to jump connect the meteorological training feature map to the decoder 200 of the QCBAM-UNet model 1000 and process it to obtain a predicted meteorological result; the determination module can be used to determine the loss function value according to the predicted meteorological result and the preset meteorological result; the adjustment module can be used to adjust the QCBAM-UNet model 1000 according to the loss function value.
[0108] Specifically, the training set used to train the QCBAM-UNet model 1000 includes a meteorological training image and a preset meteorological result, and the preset meteorological result is a meteorological result associated with the meteorological training image. The loss function can be a mean square error loss value, an absolute error loss, or a combination of a mean square error loss and an absolute error loss. The embodiment of the present application is described with the loss function as a combined loss. According to the error between the predicted meteorological result and the preset meteorological result, it can be determined whether the prediction of the QCBAM-UNet model 1000 is accurate, and the adjustable parameters of the QCBAM-UNet model 1000 can be fine-tuned according to the error function value so that the QCBAM-UNet model 1000 further meets the demand.
[0109] In one embodiment, the QCBAM-UNet model 1000 is trained using the Adam optimizer and setting the learning rate to 0.001 and the batch size to 32. After 200 training epochs, the mean square error of the QCBAM-UNet model 1000 on the test set is 0.29, the mean absolute error is 0.073, and the prediction accuracy of sunny and rainy days reaches 97.5%. The training loss value train_loss and the validation loss value val_loss in the training process are updated as the training epochs are updated as follows: Fig. 9 and Fig.10 As shown, it can be seen that the QCBAM-UNet model 1000 converges faster.
[0110] In this way, by determining the loss function value according to the predicted meteorological results and the preset meteorological results, and continuously adjusting the QCBAM-UNet model 1000 according to the loss function value, a pre-trained QCBAM-UNet model 1000 can be obtained.
[0111] In some embodiments, the loss function value is determined based on the loss weight, the mean square error loss value, and the absolute error loss value.
[0112] Specifically, the loss function value can be determined according to the loss weight, mean square error loss value and absolute error loss value loss function. The loss function value determination function is expressed as follows:
[0113] Loss combined =Loss mse *Weig t mse +(1-Weig t mse )*Loss mae
[0114] Among them, Loss mse is the mean square error loss value, Loss mae is the absolute error loss value, Weig t mse It is the loss weight to balance the two, and is set to 0.5 in this embodiment.
[0115] Mean Squared Error (MSE) is a commonly used indicator to measure the difference between the model prediction value and the actual observation value, and is used to evaluate the degree of fit of the model on the given data. MSE is obtained by taking the average of the squares of the difference between the preset meteorological results and the predicted meteorological results.
[0116] Mean Absolute Error eMAE is a commonly used indicator to measure the difference between the model prediction value and the actual observation value, which is used to evaluate the fit of the model on the given data. MAE is obtained by averaging the absolute value of the difference between the preset meteorological results and the predicted meteorological results.
[0117] In this way, combining the mean square error and the mean absolute error can better evaluate the difference between the model prediction value and the actual observation value, so that it can be used to train the QCBAM-UNet model 1000 more effectively.
[0118] An embodiment of the present application provides a computer device, which includes a weather forecasting system based on the QCBAM-UNet model 1000 of any of the above embodiments.
[0119] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "illustrative embodiments", "examples", "specific examples" or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiments or examples are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. In addition, those skilled in the art may combine and combine different embodiments or examples described in this specification and the features of different embodiments or examples without contradiction.
[0120] In addition, the term "connection" should be understood in a broad sense, for example, it can include fixed connection, detachable connection, or integral connection; it can include direct connection, indirect connection through an intermediate medium, and internal communication between two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0121] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0122] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0123] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A weather forecasting method based on quantum convolution attention module, characterized in that: The weather forecasting method comprises: The meteorological image is input into the convolution module of the encoder of the pre-trained QCBAM-UNet model for convolution processing to obtain a preliminary feature map; Inputting the preliminary feature map into a quantum convolution attention module of the encoder and processing it to obtain a meteorological feature map, wherein the quantum convolution attention module is configured to perform feature extraction based on quantum computing; The meteorological feature map is jump-connected to the decoder of the QCBAM-UNet model and processed to obtain a prediction result.
2. The weather forecasting method according to claim 1, characterized in that: The QCBAM-UNet model includes: An encoder, the encoder comprising a convolution module and a quantum convolution attention module, the convolution module is configured to perform convolution processing on an input image of the QCBAM-UNet model to obtain a preliminary feature map, and the quantum convolution attention module is configured to perform attention feature extraction on the preliminary feature map to obtain an attention feature map; A decoder is used to process the attention feature map to obtain a prediction result.
3. The weather forecasting method according to claim 1, characterized in that: The quantum convolution attention module includes: A quantum channel attention submodule, wherein the quantum channel attention submodule is configured to extract a channel attention feature in the preliminary feature map to obtain a channel attention feature map; A quantum spatial attention submodule, wherein the quantum spatial attention submodule is configured to extract spatial attention features in an intermediate feature map to obtain a spatial attention feature map, wherein the intermediate feature map is determined based on the preliminary feature map and the channel attention feature map, and the attention feature map is determined based on the spatial attention feature map and the intermediate feature map.
4. The weather forecasting method according to claim 3, characterized in that: The quantum channel attention submodule includes: A first pooling unit, wherein the first pooling unit is configured to perform pooling processing on the spatial dimension features of the preliminary feature map; A multi-layer perceptron is configured to extract channel attention features of the preliminary feature map after pooling.
5. The weather forecasting method according to claim 4, characterized in that: The multi-layer perceptron includes a fully connected layer, an activation function and a quantum neural network, and the quantum neural network is obtained according to a parameterized quantum circuit.
6. The weather forecasting method according to claim 5, characterized in that: The quantum circuit comprises: a mapping subunit, the mapping unit being configured to map an input parameter input into the quantum circuit to a quantum state; A proposed subunit, wherein the proposed subunit is configured to process the input parameter of the quantum state to obtain a processing result; A measurement subunit, wherein the measurement unit is configured to convert the processing result into a classical state to obtain the channel attention feature.
7. The weather forecasting method according to claim 3, characterized in that: The quantum spatial attention submodule includes: A second pooling unit, wherein the second pooling unit is configured to perform a channel dimension pooling process on the intermediate feature map to obtain a spatial pooling result; A quantum convolution unit, wherein the quantum convolution unit is configured to perform quantum convolution on the intermediate feature map after pooling processing through a quantum circuit to obtain the spatial attention feature map.
8. The weather forecasting method according to claim 7, characterized in that: The pooling process includes maximum pooling process and average pooling process.
9. The weather forecasting method according to any one of claims 1 to 8, characterized in that: The QCBAM-UNet model is trained by the following steps: Inputting the meteorological training image into the convolution module of the encoder of the QCBAM-UNet model for convolution processing to obtain a preliminary training feature map; Inputting the preliminary training feature map into a quantum convolution attention module of the encoder and processing it to obtain the meteorological training feature map, wherein the quantum convolution attention module is configured to perform feature extraction based on quantum computing; Jump-connecting the meteorological training feature map to the decoder of the QCBAM-UNet model and processing it to obtain a predicted meteorological result; Determine the loss function value according to the predicted meteorological results and the preset meteorological results; The QCBAM-UNet model is adjusted according to the loss function value.
10. The weather forecasting method according to claim 9, characterized in that: The loss function value is determined based on the loss weight, the mean square error loss value and the absolute error loss value.
Citation Information
Patent Citations
Meteorological data prediction method and device, storage medium and electronic device
CN116400430A
Meteorological prediction method and device, medium and electronic device
CN117148359A
Weather phenomenon forecast correction method based on improved UNet neural network
CN117391139A
EEG data classification method of hybrid convolutional neural network based on classical quantum
CN118035843A
Prediction method and device based on mixed quantum classical neural network
CN118133976A
Cited By
Short-time rainfall nowcasting method fusing quantum calculation and deep learning model
CN121009349A
