A weather prediction method based on an attention LSTM network

CN117953285BActive Publication Date: 2026-10-30NANJING TECH UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410095256.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-23
Publication Date
2026-10-30
Estimated Expiration
2044-01-23

AI Technical Summary

Technical Problem

然而,基于RNN的预测方法往往不能有效利用较远时间步的历史信息,导致预测结果不准确

Benefits of technology

[0038](1)所提出的预测单元TA-LSTM通过引入时序注意力模块(TAM),拓宽了预测网络的时间感受野,能够更准确地预测天气数据未来的走向;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117953285B_ABST
    Figure CN117953285B_ABST
Patent Text Reader

Abstract

The application discloses a weather prediction method based on an attention LSTM network and belongs to the field of machine learning. The method comprises the following steps: acquiring a weather dataset, preprocessing the dataset, dividing the dataset into a training set and a test set, and obtaining sequence data for training and testing a prediction network; on the basis of a PredRNN++ network prediction unit Causal LSTM, the application proposes a time series LSTM prediction unit (Temporal Attention LSTM, TA-LSTM), a time series attention module (Temporal Attention Module, TAM) is introduced, the time receptive field of the prediction network is widened, the time information modeling capability of the network is enhanced, meanwhile, a local attention mechanism (Local Attention, LA) is introduced, the spatial information modeling capability of the network is enhanced; a weather prediction network is constructed by stacking multiple layers of TA-LSTM units; the network is trained by using the training set, and the network parameters are optimized; the test set is input into the trained prediction network, a predicted weather sequence is obtained, and the prediction result is evaluated by using evaluation indexes. Compared with existing prediction methods, the TA-LSTM prediction network can obtain more accurate prediction results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer vision and predictive learning, and specifically relates to a weather prediction method based on attention LSTM network. Background Technology

[0002] Accurate and timely weather forecasts can reduce the impact of severe weather on socio-economic development, people's lives, and property. Predicting extreme weather is crucial for preventing natural disasters and minimizing loss of life and property. With the development of remote sensing technology, more and more meteorological data can be collected, providing substantial data support for weather forecasting research, and weather forecasting is receiving increasing attention in the field of computer vision. However, due to the variability and complexity of meteorological conditions, weather forecasting remains a challenging task.

[0003] Traditional weather forecasting methods, due to their high prediction costs, cannot provide small-scale real-time forecasts and cannot fully meet the requirements of real-time forecasting. Deep learning can effectively learn data patterns from large amounts of data, providing a new approach to weather forecasting. Deep learning-based weather forecasting methods can be broadly classified into three types: Convolutional Neural Network (CNN) based methods, Recurrent Neural Network (RNN) based methods, and Generative Adversarial Network (GAN) based methods. Since the Long Short-Term Memory (LSTM) units used in traditional RNN networks lack spatial awareness of image data, ConvLSTM, by replacing the fully connected layers in LSTM with convolutional layers, can capture spatial transformations in spatiotemporal sequence data. PredRNN improves the model's ability to model spatiotemporal sequence data by introducing spatiotemporal memory streams on top of ConvLSTM. PredRNN++ proposes the Causal LSTM prediction unit and adds a Gradient High-Speed ​​Unit (GHU) to PredRNN to mitigate the gradient vanishing problem. However, RNN-based prediction methods often fail to effectively utilize historical information from distant time steps, leading to inaccurate prediction results. To address the above issues, this invention proposes two improvements based on PredRNN++: (1) Constructing a Temporal Attention Module (TAM) based on an attention mechanism to expand the temporal receptive field of the prediction network and fully utilize historical information; (2) Introducing a Local Attention (LA) mechanism to enhance the model's ability to learn complex spatial relationships. Based on these improvements, this invention proposes a Temporal Attention LSTM (TA-LSTM) unit and constructs a weather prediction network. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings of the prior art and provide a weather forecasting method based on attention LSTM networks.

[0005] The technical solution adopted in this invention is a weather forecasting method based on an attention LSTM network, which is implemented according to the following steps:

[0006] Step 1: Obtain the weather sequence dataset, preprocess the data, and divide it into training and testing sets to obtain sequence data for training and testing the prediction network;

[0007] Step 2: Based on the attention mechanism, aggregate historical sequence information according to its importance and construct a temporal attention module (TAM). Introduce a local attention mechanism (LA) to enhance the model's ability to learn complex spatial relationships. Combine the temporal attention module (TAM) and the local attention mechanism (LA) with Causal LSTM to form a temporal attention long short-term memory unit (TA-LSTM).

[0008] Step 3: Connect the inputs and outputs of multiple TA-LSTM units and GHU units to construct a network for weather prediction;

[0009] Step 4: Train the prediction network built in Step 3 based on the training set obtained in Step 1, and optimize the network parameters;

[0010] Step 5: Input the test set weather sequence obtained in Step 1 into the prediction network trained in Step 4 to obtain the predicted weather sequence, and use the evaluation index to evaluate the prediction results.

[0011] The invention is further characterized by:

[0012] In step 1, the specific steps are as follows:

[0013] (1) Divide the acquired weather dataset into a training set and a test set;

[0014] (2) Normalize the data in the weather image dataset and convert it into grayscale image data.

[0015] In step 2, the specific steps are as follows: For a stacked RNN prediction network with L layers (L≥1), at time step t (t≥1), the input information of the k-th layer... Input information The input frame X should be when k=1. t Where c represents the number of channels, and h and w represent the height and width, respectively. At time step t (t≥1), t sets of 1×1 convolutional kernels W are used. q W k W vWill Mapped to Use T a Used to represent the temporal attention information of the aggregation; T a The calculation formula is as follows:

[0016] Where d represents the dimension;

[0017] The timing attention information input to the Timing Attention Module (TAM) is as follows:

[0018] When k=1, the input The input image frame X t A gating mechanism is used to construct a Temporal Attention Module (TAM), enabling it to remember or forget temporal attention information. The specific state transition formula of the TAM is as follows:

[0019] Where W is the convolution kernel D t With V t This indicates updating and resetting the door. Represents temporal attention flow. This represents the timing attention information extracted from the input of the previous time step. The internal structure of TAM is as follows: Figure 1 As shown;

[0020] By incorporating TAM into Causal LSTM and introducing a local attention mechanism (LA), a Temporal Attention-LSTM (TA-LSTM) is constructed. The specific state transition formula of TA-LSTM is as follows:

[0021] Where LA() represents the local attention mechanism and TAM() represents the temporal attention module, which integrates temporal attention information. With temporal attention flow Each is integrated into o t and Construct a TA-LSTM.

[0022] Step 3, the specific steps are as follows:

[0023] The prediction network is constructed by stacking 4n-layer TA-LSTM units and n-layer GHU units. The specific method is as follows: initialize the 4n-layer TA-LSTM and n-layer GHU, and initialize the hidden state of all units to 0.

[0024] The 4n-layer TA-LSTM units and GHU units are connected in series according to a certain pattern. The TA-LSTM unit is used as the first layer, and its output is used as the input of the second-layer GHU unit. The output of the GHU is used as the input of the third-layer TA-LSTM. Then, two more layers of TA-LSTM are stacked.

[0025] Step 4 involves the following steps:

[0026] The sequence data in the training set are used as the input to the first layer of the TA-LSTM prediction network in the order of time steps. The prediction network calculates the prediction for the next time step layer by layer. In the stage of predicting future frames, a periodic sampling training strategy is adopted. After all the sequence data is input, the mean square error of all the predicted images and the corresponding real images is used as the loss function, and the backpropagation algorithm is used to update the network parameters.

[0027] Step 5 involves the following steps:

[0028] The test set sequence is input into the trained prediction network to obtain the generated prediction results. The root mean square error (RMSE) and mean absolute error (MAE) are used as evaluation indicators to evaluate the prediction results. For the radar echo dataset, the precipitation forecast accuracy indicators, namely the critical success index (CSI) and Heidke skill score (HSS), are used as evaluation indicators.

[0029] The root mean square error (RMSE) is calculated as follows:

[0030] Where M is the total number of pixels in image x, N is the total number of pixels in image y, and the smaller the RMSE value, the more similar the images are;

[0031] The mean absolute error (MAE) is calculated as follows:

[0032] For a radar echo dataset, the relationship between pixel values ​​(p) and radar reflectivity values ​​(dBZ) is as follows:

[0033] The relationship between radar reflectivity (dBZ) and precipitation intensity (R: mm / h) is as follows: dBZ = 10 log a + 10b log R

[0034] Where a = 58.53, b = 1.56;

[0035] To calculate HSS and CSI, a precipitation intensity threshold is set. The pixel values ​​in the predicted radar echo map are converted into precipitation intensity values. Precipitation intensities in the map that are greater than the set precipitation intensity threshold are set to 1, and those that are not are set to 0. The pixel values ​​in both the ground truth map and the predicted map are converted into precipitation intensities. The corresponding pixels in the two maps are compared one by one to obtain the following cases: True Positive (TP) (ground truth = 1, predicted value = 1), False Negative (FN) (ground truth = 1, predicted value = 0), False Positive (FP) (ground truth = 0, predicted value = 1), True Negative (TN) (ground truth = 0, predicted value = 0).

[0036] The calculation methods for CSI and HSS are as follows:

[0037] This invention improves upon PredRNN++, proposing a Temporal Attention Long Short-Term Memory Neural Network (TA-LSTM) that can effectively utilize historical information and learn the spatial correlation of spatiotemporal sequence data. A spatiotemporal sequence prediction network is constructed based on TA-LSTM, and its beneficial effects are as follows:

[0038] (1) The proposed prediction unit TA-LSTM, by introducing a temporal attention module (TAM), broadens the temporal receptive field of the prediction network and can more accurately predict the future trend of weather data.

[0039] (2) By introducing a local attention mechanism (LA), the appearance changes of weather data can be modeled more accurately.

[0040] (3) Compared with existing advanced prediction methods, the TA-LSTM prediction network can obtain more accurate prediction results. Attached image description:

[0041] Figure 1This is a diagram of the internal structure of TA-LSTM;

[0042] Figure 2 This is a diagram of the internal structure of TAM;

[0043] Figure 3 This is a diagram of the prediction network structure consisting of 4 layers of TA-LSTM and 1 layer of GHU.

[0044] Figure 4 This is a comparison chart of the prediction results of different prediction methods on the WeatherBench dataset;

[0045] Figure 5 This is a comparison chart of prediction results from different prediction methods on the CIKM radar echo dataset. Detailed implementation method:

[0046] The implementation method of the present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.

[0047] Example 1:

[0048] This example demonstrates a prediction experiment on the WeatherBench dataset. The WeatherBench dataset consists of various types of weather data; in this example, global temperature data is used as the dataset. In this dataset, the original weather data is resized to a lower resolution of 32×64.

[0049] The specific implementation steps of this weather forecasting method based on attention LSTM networks are as follows:

[0050] In step 1 of the example, the WeatherBench dataset is divided into training and testing sets. Data from 1979 to 2015 is used as the training set, data from 2016 is used as the validation set, and data from 2017 and 2018 are used as the testing set. Each sequence contains 24 consecutive images. The pixel values ​​of the images in the dataset are normalized to between 0 and 1, converting them into grayscale image data.

[0051] Example Step 2, Building the Prediction Model:

[0052] Construct a Temporal Attention Module (TAM), the internal structure of which is as follows: Figure 1 As shown. The Causal LSTM is fused with a Temporal Attention Module (TAM) and a Local Attention Mechanism (LA) to form a TA-LSTM, the internal structure of which is as follows: Figure 2 As shown, a prediction model is constructed by stacking four layers of TA-LSTM and one layer of GHU, as follows. Figure 3As shown, the initial values ​​of H, C, and A for each layer, as well as the initial value of the spatiotemporal memory M, are all set to 0. The number of hidden layer channels is set to 128, the learning rate is 0.0001, the kernel size is set to 5×5, the loss function is L2 loss, and the number of training iterations is set to 50.

[0053] The test results of different methods on the WeatherBench dataset are shown in Table 1: Table 1 Experimental results on the WeatherBench dataset MAU 0.895 1.343 ConvLSTM 0.736 1.159 PredRNN 0.725 1.154 PredRNNv2 0.723 1.142 PredRNN++ 0.718 1.132 SimVP 0.717 1.120 TA-LSTM 0.701 1.114

[0054] As shown in Table 1, TA-LSTM outperforms other comparative methods in all metrics. The input image, the ground image, the predicted images generated by different methods, and the absolute errors between the ground and predicted images are shown in Table 1. Figure 4 As shown in the figure, the image generated by TA-LSTM is closer to the real image and has less error.

[0055] Example 2:

[0056] This embodiment conducts prediction experiments on the CIKM radar echo dataset, which covers the Shenzhen area of ​​China. Each sequence consists of 15 consecutive radar echo images with a time interval of 6 minutes between each frame. The size of each radar image is set to 64×64, and the pixel value of the radar echo image ranges from 0 to 255.

[0057] The operation steps are similar to those in Example 1. In step 1, a training set containing 10,000 sequences and a test set containing 4,000 sequences are divided.

[0058] In step 2, the number of hidden layer channels is set to 128, the learning rate is 0.0001, the kernel size is set to 5×5, the loss function is L2 loss, and the number of training iterations is set to 50.

[0059] The test results of different methods on the CIKM radar echo dataset are shown in Tables 2 and 3: Table 2. CSI metrics for various methods tested on the CIKM dataset. Table 3. HSS metrics of various methods tested on the CIKM dataset. SimVP 0.589 0.418 0.309 0.158 0.004 ConvLSTM 0.613 0.365 0.299 0.253 0.129 PredRNN 0.623 0.432 0.318 0.254 0.136 PhyDNet 0.636 0.439 0.337 0.274 0.115 PredRNNv2 0.639 0.439 0.325 0.262 0.122 MAU 0.647 0.431 0.340 0.283 0.149 PredRNN++ 0.646 0.451 0.377 0.329 0.201 TA-LSTM 0.651 0.456 0.383 0.349 0.225

[0060] As shown in Tables 2 and 3, the average performance of TA-LSTM is higher than that of other methods. Input image, real image, and prediction maps generated by different methods are shown below. Figure 4As shown in the figure, the shape of the rain cloud and the radar reflectivity in the TA-LSTM generated image are closer to the real image.

[0061] The test results of the above embodiments demonstrate the effectiveness and superiority of the present invention in weather forecasting.

Claims

1. A weather forecasting method based on attention LSTM networks, characterized in that, Includes the following steps: Step 1: Obtain the weather sequence dataset, preprocess the data, and divide it into training and testing sets to obtain sequence data for training and testing the prediction network; Step 2: Construct a temporal attention module (TAM), introduce a local attention mechanism (LA), and combine the temporal attention module (TAM) and the local attention mechanism (LA) with the Causal LSTM to form a temporal attention long short-term memory unit (TA-LSTM). Step 3: Stack 4n TA-LSTM units with n GHU units to construct a network for weather prediction; Step 4: Train the prediction network built in Step 3 based on the training set obtained in Step 1, and optimize the network parameters; Step 5: Input the test set weather sequence obtained in Step 1 into the prediction network trained in Step 4 to obtain the predicted weather sequence, and use the evaluation index to evaluate the prediction results. The key feature is that, in step 2, the construction of the temporal attention module (TAM) specifically includes: For a stacked L-layer RNN prediction network, at time step t, where , Input information of the kth layer Input frame when k=1 Where c represents the number of channels, and h and w represent the height and width, respectively; by using t groups convolution kernel , , Will Mapped to , , Aggregated temporal attention information The calculation formula is as follows: Where d represents the dimension; The timing attention information input to the timing attention module TAM is as follows: A temporal attention module (TAM) is constructed using a gating mechanism. The state transition formula for the TAM is as follows: in, and This indicates updating and resetting the door. Represents temporal attention flow. This represents the timing attention information extracted from the input of the previous time step; By incorporating TAM into Causal LSTM and introducing the local attention mechanism LA, a temporal attention long short-term memory unit TA-LSTM is constructed. The state transition formula of TA-LSTM is as follows: LA() represents the local attention mechanism, and TAM() represents the temporal attention module.

2. The weather forecasting method based on an attention-based LSTM network according to claim 1, characterized in that, In step 1, specifically: (1) Divide the acquired weather dataset into a training set and a test set; (2) Normalize the data in the weather image dataset and convert it into grayscale image data.

3. The weather forecasting method based on an attention-based LSTM network according to claim 1, characterized in that, Step 3 specifically involves: The prediction network is constructed by stacking 4n TA-LSTM units with n GHU units. The specific method is as follows: Initialization One TA-LSTM and n GHUs, initialize the hidden state of all cells to 0; 4n TA-LSTM units are connected in series with n GHU units according to a certain pattern. The output of the first TA-LSTM unit is used as the input of the GHU unit, and the output of the GHU unit is used as the input of the second TA-LSTM unit. Then, two more TA-LSTM units are stacked.

4. The weather forecasting method based on an attention-based LSTM network according to claim 1, characterized in that, Step 4 specifically involves: The sequence data in the training set are used as the input to the first layer of the TA-LSTM prediction network in the order of time steps. The prediction network calculates the prediction for the next time step layer by layer. In the stage of predicting future frames, a periodic sampling training strategy is adopted. After all the sequence data is input, the mean square error of all the predicted images and the corresponding real images is used as the loss function, and the backpropagation algorithm is used to update the network parameters.

5. A weather forecasting method based on an attention-based LSTM network according to claim 1, characterized in that, Step 5 specifically involves: The test set sequence is input into the trained prediction network to obtain the generated prediction results. The root mean square error (RMSE) and mean absolute error (MAE) are used as evaluation indicators to evaluate the prediction results. For the radar echo dataset, the precipitation forecast accuracy indicators, namely the critical success index (CSI) and the Heidke skill score (HSS), are used as evaluation indicators. The root mean square error (RMSE) is calculated as follows: in, and These represent the number of pixels in the vertical and horizontal directions of the image, respectively. The smaller the RMSE value, the more similar the images are. The mean absolute error (MAE) is calculated as follows: For a radar echo dataset, the relationship between the pixel value p and the radar reflectivity value dBZ is as follows: The relationship between radar reflectivity (dBZ) and precipitation intensity (R: mm / h) is as follows: Where a = 58.53, b = 1.56; Calculate HSS and CSI, set a precipitation intensity threshold, convert the pixel values ​​in the predicted radar echo image into precipitation intensity values, and set precipitation intensities greater than the set threshold to 1, otherwise to 0. Convert the pixel values ​​in both the ground truth image and the predicted image into precipitation intensities, and compare the corresponding pixels in the two images one by one to obtain the following cases: True positive TP: ground truth = 1, predicted value = 1; False negative FN: ground truth = 1, predicted value = 0; False positive FP: ground truth = 0, predicted value = 1; True negative TN: ground truth = 0, predicted value = 0. The calculation methods for CSI and HSS are as follows: 。

Citation Information

Patent Citations

  • Short-term wind speed prediction method based on two-stage decomposition, LSTM and AT

    CN111950759A

  • Transform-IRB-based short and temporary rainfall prediction method and device and storage medium

    CN114137541A