Meteorological prediction method based on quantum convolution attention module
By introducing a quantum convolutional attention module into the UNet model, and utilizing quantum computing for feature extraction and prediction, the problems of high computational resource consumption and low accuracy in existing technologies are solved, achieving more efficient weather forecasting.
Patent Information
- Application Number
- CN202411344253.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2026-02-24
- Estimated Expiration
- 2044-09-25
AI Technical Summary
Existing numerical weather prediction methods rely on complex mathematical models, which consume a lot of computational resources, making it difficult to improve the accuracy of weather forecasts.
We employ the QCBAM-UNet model based on quantum convolutional attention modules, using quantum computing for feature extraction and prediction. This includes quantum channels and spatial attention submodules, combined with max and average pooling processing, and a multilayer perceptron with parameterized quantum circuitry to reduce model complexity and accelerate training.
It significantly improves the accuracy and training speed of weather forecasts, reduces computational costs, and achieves faster model convergence and higher prediction accuracy.
Smart Images

Figure CN119247515B_ABST
Abstract
Description
Technical Field
[0001] This 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 Technology
[0002] Accurate weather forecasting is a key characteristic of modern industrialized society, and weather forecasts are widely used for planning, organizing, and managing personal and economic life. To date, the primary method for weather forecasting is numerical weather prediction (NWP). NWP relies on mathematical models that consider various physical properties of the atmosphere, such as air velocity, pressure, and temperature. Among related technologies, the mathematical models applicable to NWP are relatively complex, and limitations in computational resources hinder further improvements in the accuracy of weather forecasts. Summary of the Invention
[0003] This application provides a weather forecasting method based on a quantum convolutional attention module.
[0004] This application provides a weather forecasting method based on a quantum convolutional attention module, the weather forecasting method comprising:
[0005] 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;
[0006] The preliminary feature map is input into the quantum convolutional attention module of the encoder and processed to obtain the meteorological feature map. The quantum convolutional attention module is configured to perform feature extraction based on quantum computing.
[0007] The meteorological feature map is then connected to the decoder of the QCBAM-UNet model and processed to obtain the prediction result.
[0008] Thus, by inputting the input image into the convolutional module of the QCBAM-UNet model encoder to obtain a preliminary feature map, and then using a quantum convolutional attention module to extract features from the preliminary feature map to obtain an attention feature map, which is then input into the decoder for processing to obtain the prediction result. By adding the quantum convolutional attention module, the QCBAM-UNet model can focus more on the target features, accelerate the convergence speed during QCBAM-UNet model training, and improve the prediction accuracy.
[0009] This application provides a QCBAM-UNet model, which includes:
[0010] The encoder includes a convolution module and a quantum convolution attention module. The convolution module is configured to perform convolution processing on the input image of the QCBAM-UNet model to obtain a preliminary feature map, and the quantum convolution attention module is configured to extract attention features from 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] Thus, by adding a quantum convolutional attention module, the QCBAM-UNet model can focus more on the target features, accelerate the convergence speed during QCBAM-UNet model training, and improve the prediction accuracy.
[0013] In some implementations, the quantum convolutional attention module includes:
[0014] A quantum channel attention submodule is configured to extract channel attention features from the preliminary feature map to obtain a channel attention feature map;
[0015] A quantum spatial attention submodule is configured to extract spatial attention features from an 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. The attention feature map is determined based on the spatial attention feature map and the intermediate feature map.
[0016] In some implementations, the quantum channel attention submodule combines max pooling and average pooling.
[0017] A first pooling unit is configured to perform pooling processing on the spatial dimension features of the preliminary feature map.
[0018] A multilayer perceptron configured to extract channel attention features from a preliminary feature map after pooling.
[0019] Thus, the spatial dimension features in the initial feature map can be aggregated through the first pooling unit, enabling the multilayer perceptron to better extract the channel attention features in the initial feature map.
[0020] In some implementations, the multilayer perceptron includes a fully connected layer, an activation function, and a quantum neural network derived from parameterized quantum circuitry.
[0021] Thus, by incorporating a quantum neural network derived from parameterized quantum circuits into a multilayer perceptron, the number of model parameters is effectively reduced, training costs are lowered, and the convergence speed of the model is accelerated.
[0022] In some embodiments, the quantum circuit includes:
[0023] A mapping subunit, configured to map input parameters input to the quantum circuit to a quantum state;
[0024] A proposed subunit is configured to process the input parameters of the quantum state to obtain a processing result;
[0025] A measurement subunit is configured to convert the processing result to a classical state to obtain the channel attention features.
[0026] In some implementations, the quantum spatial attention submodule includes:
[0027] The second pooling unit is configured to perform channel-dimensional pooling processing on the intermediate feature map.
[0028] A quantum convolution unit is configured to perform quantum convolution on the intermediate feature map after pooling through quantum circuitry to obtain the spatial attention feature map.
[0029] Thus, by introducing quantum circuitry, the ability of quantum convolutional units to express input features is improved, enabling the model to extract and utilize features more accurately.
[0030] In some implementations, the pooling process includes max pooling and average pooling.
[0031] Thus, by combining max pooling and average pooling, the quantum attention module can better extract attention features.
[0032] In some implementations, the QCBAM-UNet model is trained through the following steps:
[0033] The meteorological training images are input into the convolution module of the encoder of the QCBAM-UNet model for convolution processing to obtain preliminary training feature maps;
[0034] The preliminary training feature map is input into the quantum convolutional attention module of the encoder and processed to obtain the meteorological training feature map. The quantum convolutional attention module is configured to perform feature extraction based on quantum computing.
[0035] The meteorological training feature map is skipped to the decoder of the QCBAM-UNet model and processed to obtain the predicted meteorological results;
[0036] The loss function value is determined based on the predicted and preset weather results;
[0037] The QCBAM-UNet model is adjusted based on the loss function value.
[0038] Thus, by determining the loss function value based on the predicted and preset weather results, and continuously adjusting the QCBAM-UNet model based on the loss function value, a pre-trained QCBAM-UNet model can be obtained.
[0039] In some implementations, the loss function value is determined based on the loss weight, the mean squared error loss value, and the absolute error loss value.
[0040] Thus, combining mean squared error and mean absolute error can better assess the difference between model predictions and actual observations, thereby enabling more effective training of the QCBAM-UNet model.
[0041] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0042] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, wherein:
[0043] Figure 1 This is a flowchart illustrating the meteorological forecasting method according to the embodiments of this application;
[0044] Figure 2 This is a schematic diagram of the QCBAM-UNet model according to an embodiment of this application;
[0045] Figure 3 This is a schematic diagram of the quantum convolutional attention module according to an embodiment of this application;
[0046] Figure 4 This is a schematic diagram of the quantum channel attention submodule according to an embodiment of this application;
[0047] Figure 5 This is a schematic diagram of a quantum circuit according to an embodiment of this application;
[0048] Figure 6 This is a schematic diagram of the quantum space attention submodule according to an embodiment of this application;
[0049] Figure 7 This is a schematic diagram of a quantum convolution unit according to an embodiment of this application;
[0050] Figure 8 This is a schematic diagram of the training process of the QCBAM-UNet model according to the implementation of this application;
[0051] Figure 9 This is a schematic diagram illustrating how the training loss value changes with the number of training rounds in an embodiment of this application;
[0052] Figure 10 This is a schematic diagram illustrating how the verification loss value changes with the number of training rounds in an embodiment of this application. Detailed Implementation
[0053] The embodiments of this application are described in detail below. Examples of these embodiments are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application.
[0054] Accurate weather forecasting is a key characteristic of modern industrialized society, and weather forecasts are widely used for planning, organizing, and managing personal and economic life. To date, the primary method for weather forecasting is numerical weather prediction (NWP). NWP relies on mathematical models that consider different physical properties of the atmosphere, such as air velocity, pressure, and temperature.
[0055] Among related technologies, the mathematical models that can be used for NWP are relatively complex, and due to the limited consumption of computing resources, the accuracy of weather forecasts is difficult to improve further.
[0056] Based on the potential issues mentioned above, please refer to Figure 1 and Figure 2 This application provides a weather forecasting method based on a quantum convolutional attention module. The weather forecasting method includes:
[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 the preliminary feature map;
[0058] 012: The preliminary feature map is input into the quantum convolutional attention module 20 of the encoder 100 and processed to obtain the meteorological feature map. The quantum convolutional attention module 20 is configured to perform feature extraction based on quantum computing.
[0059] 013: The meteorological feature map is skipped to the decoder 200 of the QCBAM-UNet model 1000 and processed to obtain the prediction results.
[0060] This application provides a computer device, which includes one or more processors and a memory. The weather forecasting method of this application can be implemented by the computer device of this application. The processor can be used to input weather images 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 convolutional attention module 20 of the encoder 100 for processing to obtain a weather feature map, wherein the quantum convolutional attention module 20 is configured to perform feature extraction based on quantum computing; it can also be used to skip-connect the weather feature map to the decoder 200 of the QCBAM-UNet model 1000 for processing to obtain a prediction result.
[0061] This 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 this application can be implemented by the weather forecasting device of this application. The first processing module can be used to input a weather image into the convolution module 10 of the encoder 100 of a 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 convolutional attention module 20 of the encoder 100 for processing to obtain a weather feature map, wherein the quantum convolutional attention module 20 is configured to perform feature extraction based on quantum computing; the third processing module can be used to skip-connect the weather feature map to the decoder 200 of the QCBAM-UNet model 1000 for processing to obtain a prediction result.
[0062] Specifically, meteorological images comprise multiple images containing precipitation data over a specified historical period. Meteorological images may include grid data containing latitude and longitude coordinates, with each point representing the hourly rainfall at that latitude-longitude intersection. For example, a meteorological image could be obtained by testing the hourly rainfall over several months at a given location.
[0063] In some embodiments, hourly precipitation data from May to September is collected for a specific location as an image dataset, totaling approximately 3600 hours of continuous rainfall data, or about 3600 images. Three days of data are extracted from the image dataset as a test set, and the remaining images are divided into training and validation sets in an 8:2 ratio.
[0064] Furthermore, the meteorological images are preprocessed. To avoid zero values, the values in the training and validation sets are added to a preset value and then the logarithm is taken. The data is then normalized based on the maximum and minimum values so that the data values are all distributed within (0,1]. The preset value is a small preset value, for example, 0.001. Other preset values are also possible and are not restricted here.
[0065] A rainy / sunny day threshold can be set for the prediction results. If the prediction result is greater than the rainy / sunny day threshold, it is predicted as a rainy day; if it is less than the rainy / sunny day threshold, it is predicted as a sunny day. In one embodiment, the rainy / sunny day threshold is set to 0.5, so a prediction result greater than 0.5 is considered a rainy day.
[0066] The performance of the QCBAM-UNet model 1000 (a U-shaped network model based on quantum attention) can be measured by accuracy, which represents the proportion of correct predictions made by the model among all predictions. Accuracy is suitable for 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 or rainy days. In one embodiment, the QCBAM-UNet model 1000 achieves an accuracy of 97.5% on the test set, which is higher than the SmaAt-UNet model without the quantum convolutional attention module 20.
[0067] In related technologies, the conventional SmaAt-UNet model incorporates a Convolutional Block Attention Module (CBAM) into the U-shaped model (UNet) to enable the model to focus on target features. Furthermore, it replaces conventional convolution operations with depthwise separable convolutions to reduce the number of parameters. However, weather forecasting is computationally intensive and resource-intensive. Limited by model complexity and resource consumption, the accuracy of weather forecasts using the conventional SmaAt-UNet model is difficult to improve further.
[0068] The QCBAM-UNet model 1000 of this application replaces the traditional attention module in the conventional SmaAt-UNet model with a quantum convolutional attention module (QCBAM), which significantly accelerates the training speed while reducing the model's complexity. The quantum convolutional attention module 20 can learn important features in different temporal and spatial regions. Since the quantum convolutional attention module 20 is based on quantum computing, adding it to the model reduces its complexity and accelerates its convergence.
[0069] Thus, the QCBAM-UNet model 1000, computer device, and computer-readable storage medium of this application obtain a preliminary feature map by inputting an input image into the convolutional module 10 of the QCBAM-UNet model 1000 encoder, and then use the quantum convolutional attention module 20 to extract features from the preliminary feature map to obtain an attention feature map. The attention feature map is then input into the decoder 200 for processing to obtain the prediction result. By adding the quantum convolutional attention module 20, the QCBAM-UNet model 1000 can focus more on the target features, accelerating the convergence speed during training and improving the prediction accuracy.
[0070] Please see Figure 2 In some implementations, the QCBAM-UNet model 1000 includes an encoder 100 and a decoder 200. The encoder 100 includes a convolution module 10 and a quantum convolutional 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. The quantum convolutional 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, please refer to Figure 2 The QCBAM-UNet model 1000 of this application is designed based on the conventional SmaAt-Unet model.
[0072] The UNet model comprises a multi-layer encoder 100 and a multi-layer decoder 200. The initial feature maps obtained from the convolutions of each encoder 100 layer can have different sizes; for example, they can gradually decrease from top to bottom to form a U-shaped structure. Each encoder 100's convolutional module 10 includes a dual depthwise separable convolution. A quantum convolutional attention module 20 is placed after each dual depthwise separable convolution. Notably, Figure 2 The number of layers and feature map size of encoder 100 and decoder 200 in the figure are for illustrative purposes only. The actual number of layers and actual size can be set according to requirements.
[0073] The quantum convolutional attention module 20 is a convolutional attention module based on quantum circuit design. It can extract important features from the initial feature map to obtain an attention feature image, which can suppress redundant features while amplifying important features, effectively reducing training costs. Figure 2 The feature image filled with slashes is the attention feature image.
[0074] Furthermore, the attention feature image can be fed back to the corresponding layer's decoder 200 via skip connections. The decoder 200 performs upsampling, concatenation with the previous attention feature image output by the previous layer's encoder 100, convolution, and other processing on the attention feature image, and finally outputs the prediction result.
[0075] Thus, the QCBAM-UNet model 1000, computer device, and computer-readable storage medium of this application obtain a preliminary feature map by inputting an input image into the convolutional module 10 of the QCBAM-UNet model 1000 encoder, and then use the quantum convolutional attention module 20 to extract features from the preliminary feature map to obtain an attention feature map. The attention feature map is then input into the decoder 200 for processing to obtain the prediction result. By adding the quantum convolutional attention module 20, the QCBAM-UNet model 1000 can focus more on the target features, accelerating the convergence speed during training and improving the prediction accuracy.
[0076] Please see Figure 3 In some embodiments, 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 extract channel attention features from a preliminary feature map to obtain a channel attention feature map. The quantum spatial attention submodule 22 is configured to extract spatial attention features from an 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 cross-channel features in the preliminary feature map to obtain a channel attention feature map. Element-wise multiplication is then performed on the channel attention feature map and the preliminary feature map 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. Element-level multiplication is then performed on the spatial attention feature map and the intermediate feature map to obtain the attention feature map.
[0079] Both the quantum spatial attention submodule 22 and the quantum channel attention submodule 21 are implemented based on quantum circuits, and can learn important features across channels and spatial regions without losing a large amount 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] Please see Figure 4 In some embodiments, the quantum channel attention submodule 21 includes a first pooling unit 211 and a multilayer perceptron 212. The first pooling unit 211 is configured to perform pooling processing on the spatial dimension features of the preliminary feature map; the multilayer perceptron 212 is configured to extract the channel attention features of the pooled preliminary feature map.
[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 and enabling better inference of channel attention features. The pooling processing includes max pooling and / or average pooling. In one embodiment, the first pooling unit 211 performs max pooling and average pooling on the spatial dimension features of the preliminary feature map.
[0083] The multilayer perceptron 212 is configured to extract channel attention features from the preliminary feature map after pooling to obtain a channel attention feature map, thereby enabling the extraction and learning of important features across channels.
[0084] Thus, the spatial dimension features in the preliminary feature map can be aggregated through the first pooling unit 211, enabling the multilayer perceptron 212 to better extract the channel attention features in the preliminary feature map.
[0085] In some implementations, the multilayer perceptron 212 includes a fully connected layer, an activation function, and a quantum neural network 2121, which is derived from a parameterized quantum circuit.
[0086] Specifically, the multilayer perceptron 212 includes a multilayer structure, in which the neurons of each layer are connected to all the neurons of the layer above, so that each neuron receives input from all the neurons of the layer above and passes its output to all the neurons of the layer below, thus forming a fully connected layer, and activation functions are used on the neurons of each hidden layer and output layer.
[0087] The embodiments of this application replace some of the conventional multilayer perceptron (MLP) with quantum neural networks (QNNs), which effectively reduces the number of parameters in the model and accelerates the convergence of the model.
[0088] The quantum neural network 2121 is a quantum algorithm based on parameterized quantum circuits. It can be trained in a variational manner using classical optimizers, such as Adam. The quantum circuit consists of a feature map with input parameters and a sigma (Ansatz) with trainable weights.
[0089] Furthermore, to meet the requirement of mapping different data features to quantum states, different feature mapping quantum circuits are implemented to perform quantum state mapping transformations. When multiple qubits exist, entanglement can be introduced through CNOT gates to improve the quantum circuit's ability to express attention features. In one embodiment, when the input features are two-dimensional, the quantum circuit is as follows: Figure 5 As shown.
[0090] Thus, by adding a quantum neural network 2121 obtained from parameterized quantum circuits to the multilayer perceptron 212, the number of model parameters is effectively reduced, the training cost is lowered, and the convergence speed of the model is accelerated.
[0091] In some implementations, the quantum circuit includes a mapping subunit, a fitting subunit, and a measurement subunit. The mapping subunit is configured to map input parameters of the quantum circuit to a quantum state; the fitting subunit is configured to process the input parameters of the quantum state to obtain a processing result; and the measurement subunit is configured to convert the processing result to a classical state to obtain channel attention features.
[0092] Specifically, the mapping subunit is used to map the input parameters of the quantum circuit from classical states to quantum states, realizing the conversion from classical to quantum states. The simulation subunit processes the input parameters of the quantum state and extracts channel attention features. The simulation subunit includes trainable weights, which are continuously adjusted during the training of the QCBAM-UNet model 1000 to allow the quantum neural network 2121 to continuously adjust and learn. The measurement subunit is used to measure the results obtained by the simulation subunit to convert the results into classical states to obtain the channel attention features.
[0093] Thus, quantum circuits can be used to extract channel attention features using quantum computing, enabling the conversion between classical and quantum states.
[0094] Please see Figure 6 In some implementations, 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-dimensional pooling on the intermediate feature map; the quantum convolution unit 222 is configured to perform quantum convolution on the pooled intermediate feature map through quantum circuitry 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 pooling, the dimension of the channel features of the intermediate feature map is reduced. The quantum convolution unit 222 uses quantum circuits as convolution filters to extract local sub-parts of the pooled intermediate feature map for transformation, 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 As shown.
[0096] Thus, by introducing quantum circuitry, the ability of the quantum convolution unit 222 to express input features is improved, enabling the model to extract and utilize features more accurately.
[0097] In some implementations, pooling processing includes max pooling and average pooling.
[0098] Specifically, average pooling can effectively learn the range of target features, while max pooling can better infer channel attention. Combining max pooling and average pooling can enable the quantum channel attention submodule 21 to extract channel attention features more effectively, or enable the quantum spatial attention submodule 22 to extract spatial attention features more effectively.
[0099] Thus, by combining max pooling and average pooling, the quantum attention module can better extract attention features.
[0100] Please see Figure 8 In some implementations, the QCBAM-UNet model 1000 is trained through 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 the preliminary training feature map;
[0102] 022: The preliminary training feature map is input into the quantum convolutional attention module 20 of the encoder 100 and processed to obtain the meteorological training feature map. The quantum convolutional attention module 20 is configured to perform feature extraction based on quantum computing.
[0103] 023: The meteorological training feature map is skipped to the decoder 200 of the QCBAM-UNet model 1000 and processed to obtain the predicted meteorological results;
[0104] 024: Determine the loss function value based on the predicted and preset weather results;
[0105] 025: Adjust the QCBAM-UNet model 1000 based on the loss function value.
[0106] In some embodiments, the training method of the QCBAM-UNet model 1000 of this application can also be implemented by a processor. That is, the processor can be used to input meteorological training images 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 convolutional attention module 20 of the encoder 100 and process it to obtain a meteorological training feature map, wherein the quantum convolutional attention module 20 is configured to perform feature extraction based on quantum computing; connect the meteorological training feature map to the decoder 200 of the QCBAM-UNet model 1000 for skip connection and process it to obtain a predicted meteorological result; determine the loss function value based on the predicted meteorological result and the preset meteorological result; and adjust the QCBAM-UNet model 1000 based on the loss function value.
[0107] In some embodiments, this application provides a training device, which includes a first training module, a second training module, a third training module, a determination module, and an adjustment module. The first training module can be used to input meteorological training images 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 convolutional attention module 20 of the encoder 100 for processing to obtain a meteorological training feature map. The quantum convolutional attention module 20 is configured to perform feature extraction based on quantum computing. The third training module can be used to skip-connect the meteorological training feature map to the decoder 200 of the QCBAM-UNet model 1000 for processing to obtain a predicted meteorological result. The determination module can be used to determine a loss function value based on the predicted meteorological result and a preset meteorological result. The adjustment module can be used to adjust the QCBAM-UNet model 1000 based on the loss function value.
[0108] Specifically, the training set used to train the QCBAM-UNet model 1000 includes meteorological training images and preset meteorological results, where the preset meteorological results are meteorological results associated with the meteorological training images. The loss function can be the mean squared error loss, the absolute error loss, or a combination of the mean squared error loss and the absolute error loss. This embodiment uses the combined loss function for explanation. Based on the error between the predicted meteorological results and the preset meteorological results, the accuracy of the QCBAM-UNet model 1000's predictions can be determined. The adjustable parameters of the QCBAM-UNet model 1000 can be fine-tuned based on the error function value to further enhance the model's performance to meet specific requirements.
[0109] In one embodiment, the QCBAM-UNet model 1000 was trained using the Adam optimizer with a learning rate of 0.001 and a batch size of 32. After 200 training epochs, the QCBAM-UNet model 1000 achieved a mean squared error of 0.29 and a mean absolute error of 0.073 on the test set, with a prediction accuracy of 97.5% for sunny and rainy days. The training loss value (train_loss) and validation loss value (val_loss) were updated with each training epoch as follows: Figure 9 and Figure 10 As shown, the QCBAM-UNet model 1000 converges relatively quickly.
[0110] Thus, by determining the loss function value based on the predicted and preset meteorological results, and continuously adjusting the QCBAM-UNet model 1000 based on the loss function value, a pre-trained QCBAM-UNet model 1000 can be obtained.
[0111] In some implementations, the loss function value is determined based on the loss weight, the mean squared error loss value, and the absolute error loss value.
[0112] Specifically, the loss function value can be determined based on the loss weight, mean squared error loss value, and absolute error loss value. The function for determining the loss function value is expressed as follows:
[0113] Loss combined =Loss mse *Weig t mse +(1-Weig t mse Loss mae
[0114] Loss mse It is the mean squared error loss value, Loss mae It is the absolute error loss value, Weig t mse The loss weight is used to balance the two, and in this embodiment it is set to 0.5.
[0115] Mean Squared Error (MSE) is a commonly used metric to measure the difference between model predictions and actual observations, used to assess how well a model fits a given dataset. MSE is calculated as the average of the squared differences between the predicted and expected meteorological results.
[0116] Mean Absolute Error eModel Error (MAE) is a commonly used metric to measure the difference between model predictions and actual observations, used to assess how well a model fits a given dataset. MAE is calculated as the average of the absolute values of the differences between the predicted and assumed meteorological results.
[0117] Thus, combining mean squared error and mean absolute error can better assess the difference between model predictions and actual observations, thereby enabling more effective training of the QCBAM-UNet model 1000.
[0118] This application provides a computer device, which includes a weather forecasting system based on the QCBAM-UNet model 1000 as described in any of the above embodiments.
[0119] In the description of this specification, the terms "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with an embodiment or example that are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, without contradiction, those skilled in the art can combine and integrate different embodiments or examples described in this specification, as well as features of different embodiments or examples.
[0120] Furthermore, the term "connection" should be interpreted broadly. For example, it can include fixed connections, detachable connections, or integral connections; it can include direct connections or indirect connections through an intermediate medium; and it can also include internal communication between two elements. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.
[0121] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0122] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order according to the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0123] Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of this application.
Claims
1. A weather forecasting method based on a quantum convolutional attention module, characterized in that, The meteorological forecasting method includes: 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. The preliminary feature map is input into the quantum convolutional attention module of the encoder and processed to obtain a meteorological feature map. The quantum convolutional attention module is configured to perform feature extraction based on quantum computing. The meteorological feature map is then connected to the decoder of the QCBAM-UNet model and processed to obtain the prediction result; The quantum convolutional attention module includes: A quantum channel attention submodule is configured to extract channel attention features from the preliminary feature map to obtain a channel attention feature map; A quantum spatial attention submodule is configured to extract spatial attention features from 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; Both the quantum space attention submodule and the quantum channel attention submodule are implemented based on quantum circuits. The quantum channel attention submodule includes: A first pooling unit is configured to perform pooling processing on the spatial dimension features of the preliminary feature map. A multilayer perceptron, configured to extract channel attention features from a preliminary feature map after pooling; The multilayer perceptron includes a fully connected layer, an activation function, and a quantum neural network, wherein the quantum neural network is derived from a parameterized quantum circuit. The quantum space attention submodule includes: The second pooling unit is configured to perform channel-dimensional pooling on the intermediate feature map to obtain a spatial pooling result. A quantum convolution unit is configured to perform quantum convolution on the intermediate feature map after pooling through quantum circuitry to obtain the spatial attention feature map.
2. The meteorological forecasting method according to claim 1, characterized in that, The QCBAM-UNet model includes: The encoder includes a convolution module and a quantum convolution attention module. The convolution module is configured to perform convolution processing on the input image of the QCBAM-UNet model to obtain a preliminary feature map, and the quantum convolution attention module is configured to extract attention features from 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 meteorological forecasting method according to claim 1, characterized in that, The quantum circuit includes: A mapping subunit configured to map input parameters to the quantum circuit to a quantum state; A proposed subunit is configured to process the input parameters of the quantum state to obtain a processing result; A measurement subunit is configured to convert the processing result to a classical state to obtain the channel attention features.
4. The weather forecasting method according to claim 1, characterized in that, The pooling process includes max pooling and average pooling.
5. The meteorological forecasting method according to any one of claims 1 to 4, characterized in that, The QCBAM-UNet model is trained through the following steps: The meteorological training images are input into the convolution module of the encoder of the QCBAM-UNet model for convolution processing to obtain preliminary training feature maps; The preliminary training feature map is input into the quantum convolutional attention module of the encoder and processed to obtain the meteorological training feature map. The quantum convolutional attention module is configured to perform feature extraction based on quantum computing. The meteorological training feature map is skipped to the decoder of the QCBAM-UNet model and processed to obtain the predicted meteorological results; The loss function value is determined based on the predicted and preset weather results; The QCBAM-UNet model is adjusted based on the loss function value.
6. The meteorological forecasting method according to claim 5, characterized in that, The loss function value is determined based on the loss weight, the mean squared 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
Weather phenomenon forecast correction method based on improved UNet neural network
CN117391139A