A modeling method based on dual attention mechanism

By integrating time-distributed spatial attention and feature attention in a deep learning framework, the shortcomings of traditional models in capturing complex spatiotemporal dynamics and feature importance are addressed, high-precision and interpretable digital twin modeling is achieved, and the model's prediction accuracy and flexibility in multiple spatiotemporal scenarios are improved.

CN119720785BActive Publication Date: 2025-09-09夏萃慧
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411854795.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-17
Publication Date
2025-09-09
Estimated Expiration
2044-12-17

AI Technical Summary

Technical Problem

Traditional Earth system models have difficulty capturing complex nonlinear interactions and high-dimensional data, lack flexibility and generalization capabilities, and AI models lack interpretability, which limits the high precision and real-time requirements of digital twins.

Method used

A modeling method based on the dual attention mechanism is adopted. The spatiotemporal features are extracted through a deep convolutional long short-term memory network, and the spatial attention and feature attention of the time distribution are combined. The mean square error loss function and the adaptive moment estimation optimizer are used for training. The model makes predictions in multiple spatiotemporal scenarios.

Benefits of technology

It improves the model's prediction accuracy and generalization capabilities in multiple spatiotemporal scenarios, enhances the interpretability of AI-driven physical system models, and supports high-precision modeling and real-time monitoring of digital twins.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119720785B_ABST
    Figure CN119720785B_ABST
Patent Text Reader

Abstract

This application discloses a modeling method based on a dual attention mechanism. It takes a four-dimensional tensor as input data; extracts the spatiotemporal features of the input data through a deep convolutional long short-term memory network, applies a ConvLSTM2D layer to each feature channel of the input, and splices them in the feature dimension; integrates the time-distributed spatial attention and feature attention into a deep learning framework, and expands the spatial features of each time step into a one-dimensional vector through a time-distributed Flatten layer; applies a global average pooling layer to the one-dimensional vector to aggregate the features in the time dimension; and predicts the target value through the output layer. By utilizing the dual attention mechanism, the present invention uses an algorithm to model important spatial positions and features that change over time, without the advantage of pre-analyzing data, thereby improving the prediction accuracy, interpretability, and generalization ability in multiple spatiotemporal scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data modeling and processing technology, and in particular to a modeling method based on a dual attention mechanism. Background Art

[0002] In recent years, digital twins, which represent high-precision representations of the physical world in digital space, have become a key technology in fields such as smart manufacturing, smart cities, and Earth system science. Digital twins acquire and analyze data from physical systems in real time, enabling real-time monitoring, prediction, and optimization of system states. However, building high-precision digital twins requires precise modeling and simulation of physical systems, especially when complex spatiotemporal dynamics and multidimensional features are involved.

[0003] Traditional Earth system models are typically equation-driven, relying on predefined equations to represent physical processes. These models face challenges in capturing the complex nonlinear interactions and high-dimensional data of Earth system processes, and struggle to meet the real-time and accuracy requirements of digital twins. Furthermore, they often lack flexibility and generalizability across diverse regions and scenarios.

[0004] Artificial Intelligence (AI) methods, particularly deep learning models, have been applied to Earth system modeling and the construction of digital twins to address these challenges. However, many AI models act as black boxes and lack interpretability, limiting their usefulness in understanding underlying processes and guiding decision-making.

[0005] Attention mechanisms have shown potential in AI to improve model performance and interpretability by focusing on the most relevant parts of the input data. However, existing models typically use only a single attention mechanism and are limited to specific applications. They cannot fully capture complex spatiotemporal dynamics and feature importance, which becomes a limiting factor in the high-precision modeling of digital twins. Equation-driven models have difficulty capturing the complex nonlinear interactions in physical systems, lack flexibility and generalization capabilities, and cannot meet the high-precision and real-time requirements of digital twins. Although powerful, traditional AI models are usually black boxes and lack interpretability, which limits their applicability in digital twin modeling and physical system understanding. Existing attention mechanisms are usually single and may not be able to fully capture the spatiotemporal dynamics and feature importance of physical systems, limiting the ability of digital twins to model complex systems. Therefore, a modeling approach based on a dual attention mechanism is needed. Summary of the Invention

[0006] An embodiment of the present application provides a modeling method based on a dual attention mechanism to at least partially solve the above technical problems.

[0007] The embodiments of this application adopt the following technical solutions:

[0008] In a first aspect, an embodiment of the present application provides a modeling method based on a dual attention mechanism, the method comprising:

[0009] a) Take a four-dimensional tensor as input data;

[0010] b) extracting spatiotemporal features of the input data through a deep convolutional long short-term memory network, applying a ConvLSTM2D layer to each feature channel of the input, and concatenating them in the feature dimension;

[0011] c) integrating time-distributed spatial attention and feature attention into a deep learning framework, wherein the time-distributed spatial attention calculates spatial attention weights by using a two-dimensional convolutional layer with time distribution wrapping on the input data in the time dimension, and the feature attention mechanism calculates feature attention weights by using a two-dimensional convolutional layer with time distribution wrapping on the input data in the time dimension;

[0012] d) Expand the spatial features of each time step into a one-dimensional vector through the time-distributed Flatten layer;

[0013] e) applying a global average pooling layer to the one-dimensional vector to aggregate features in the time dimension;

[0014] f) Predict the target value through the output layer.

[0015] Furthermore, the spatial attention weight is calculated by performing a convolution operation on the input data of each time step and applying a sigmoid activation function. The formula for calculating the spatial attention weight is:

[0016] α t =σ(Conv2D(H t ))

[0017]

[0018] Among them, Conv2D is a two-dimensional convolution operation, the filling method is "same", σ() is the sigmoid activation function, is the input of time step t.

[0019] Furthermore, the feature attention weight is calculated by performing a 1×1 convolution operation on the input data of each time step and applying a softmax activation function, wherein the formula for calculating the feature attention weight is:

[0020] β t =softmax(Conv2D 1×1 (H t))

[0021]

[0022] Ensure that at each spatial position, the sum of the attention weights of all features is 1:

[0023]

[0024] Among them, the softmax activation function is applied on the channel dimension.

[0025] Furthermore, the training process of the model uses mean square error as the loss function and is optimized using an adaptive moment estimation optimizer.

[0026] Furthermore, the training strategy includes early stopping and dynamic adjustment of learning rate.

[0027] Furthermore, the four-dimensional tensor includes the number of time steps, the height, width and number of features of the spatial dimension.

[0028] Furthermore, after the depthwise convolutional LSTM layer, a batch normalization layer and a dropout layer are applied to stabilize the training process and prevent overfitting.

[0029] Furthermore, during model inference, the spatial and feature attention weights α are extracted t and β t ,

[0030]

[0031] Furthermore, the model implementation environment uses Python language, and the deep learning framework adopts TensorFlow or PyTorch.

[0032] In a second aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores one or more programs. When the one or more programs are executed by an electronic device including multiple applications, the electronic device executes the method steps described in the first aspect.

[0033] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects:

[0034] (1) The present invention provides a flexible, data-independent spatiotemporal algorithm modeling method that can effectively capture the complex spatiotemporal patterns and characteristic changes in physical systems, providing support for high-precision modeling of digital twins.

[0035] (2) This invention enhances the interpretability in AI-driven physical system models by utilizing a dual attention mechanism, revealing important spatial locations and features that change over time, and improving the transparency and controllability of digital twins.

[0036] (3) The present invention improves the prediction accuracy and generalization ability in multiple spatiotemporal scenarios, takes advantage of the fact that algorithmic modeling does not require pre-analysis of data, and supports the application of digital twins in different physical systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0038] Figure 1 A schematic diagram of a model architecture of a modeling method based on a dual attention mechanism provided in an embodiment of this specification;

[0039] Figure 2 A dual attention mechanism flow chart of a modeling method based on a dual attention mechanism provided in an embodiment of this specification;

[0040] Figure 3 A schematic diagram of the key impact areas obtained by analyzing the attention mechanism based on a modeling method based on a dual attention mechanism provided in an embodiment of this specification;

[0041] Figure 4 A schematic diagram of the key impact areas obtained by analyzing the attention mechanism according to a modeling method based on the dual attention mechanism provided in an embodiment of this specification;

[0042] Figure 5 A schematic diagram of the spatiotemporal impact of monsoon movement on hydrology in key impact areas according to a modeling method based on a dual attention mechanism provided in an embodiment of this specification;

[0043] Figure 6 A schematic diagram of the spatiotemporal impact of the non-monsoon period on hydrology in key areas of influence provided by a modeling method based on a dual attention mechanism according to an embodiment of this specification;

[0044] Figure 7 This is a schematic diagram of the structure of an electronic device in an embodiment of this specification. DETAILED DESCRIPTION

[0045] The present invention will be further described in detail below with reference to the accompanying drawings by way of specific embodiments. Similar elements in different embodiments are numbered with associated similar elements. In the following embodiments, many detailed descriptions are provided to enable the present application to be better understood. However, those skilled in the art will readily appreciate that some of the features may be omitted under different circumstances, or may be replaced by other elements, materials, or methods. In some cases, some operations related to the present application are not shown or described in the specification. This is to avoid overwhelm the core of the present application with excessive descriptions, and for those skilled in the art, it is not necessary to describe these related operations in detail. They will fully understand the related operations based on the description in the specification and the general technical knowledge in the art.

[0046] In addition, the features, operations, or characteristics described in the specification may be combined in any appropriate manner to form various embodiments. Furthermore, the steps or actions in the method description may be reordered or adjusted in a manner readily apparent to those skilled in the art. Therefore, the various sequences in the specification and drawings are provided solely for the purpose of clearly describing a particular embodiment and are not intended to be mandatory, unless otherwise specified.

[0047] The serial numbers assigned to components herein, such as "first," "second," etc., are used solely to distinguish the objects being described and do not convey any sequential or technical meaning. References to "connection" and "coupling" herein, unless otherwise specified, include both direct and indirect connections (couplings).

[0048] The following describes in detail the technical solutions provided by various embodiments of the present application in conjunction with the accompanying drawings.

[0049] like Figure 1 As shown in the figure, the present invention provides a modeling method based on a dual attention mechanism, which is applicable to various spatiotemporal scenarios in physical world digital twins. This method integrates time-distributed spatial attention and feature attention in a deep learning framework (such as a convolutional long short-term memory network, ConvLSTM) to capture complex spatiotemporal interactions and feature importance, providing a high-precision and interpretable model for the construction of digital twins. It includes the following steps:

[0050] The technical solution is as follows:

[0051] Model Architecture:

[0052] Input layer:

[0053] Input data is a four-dimensional tensor in:

[0054] T: number of time steps;

[0055] H and W: height and width of spatial dimensions;

[0056] C: number of features.

[0057] Depthwise ConvLSTM2D:

[0058] Purpose: Extract the spatiotemporal features of input data.

[0059] Implementation: Apply a ConvLSTM2D layer to each feature channel of the input, and then concatenate along the feature dimension.

[0060] Mathematical description:

[0061] For input Split it into C channels in the feature dimension.

[0062] Each channel k=1,2,...,C,

[0063] Apply ConvLSTM2D to each channel:

[0064] H (k) =ConvLSTM2D(X (k) )

[0065] The final output is obtained by concatenating on the channel (feature) dimension:

[0066] H=Concat(H (1) ,H (2) ,...,H (C) )

[0067] Batch Normalization and Dropout layers

[0068] Purpose: Stabilize the training process and prevent overfitting.

[0069] Design and implementation of dual attention mechanism:

[0070] a) Time Distributed Spatial Attention Mechanism:

[0071] Purpose: At each time step, the spatial positions are weighted to highlight the most relevant spatial positions.

[0072] accomplish:

[0073] A 3×3 two-dimensional convolutional layer (Conv2D) with a time-distributed wrapper is used for the input data in the time dimension, and the activation function is sigmoid.

[0074] Calculating spatial attention weights

[0075] in:

[0076] is the input of time step t;

[0077] α t =σ(Conv2D(H t ))

[0078] σ() is the sigmoid activation function:

[0079]

[0080] Conv2D is a two-dimensional convolution operation with the padding mode "same".

[0081] Apply spatial attention weights:

[0082] H t =H t ⊙α t

[0083] Among them, ⊙ represents element-wise multiplication, attention α t Broadcasting is performed on the channel (feature) dimension. Definition of element-wise multiplication:

[0084] For tensors A and B, (A⊙B) i,j,k =A i,j,k ×B i,j,k

[0085] The weighted output sequence H = {H1, H2, ..., H T};

[0086] The corresponding spatial attention weight sequence {α1,α2,…,α T}.

[0087] b) FeatureWiseAttention:

[0088] Purpose: Evaluate the importance of each feature at spatial location and time step.

[0089] Implement a 1×1 two-dimensional convolutional layer that uses a time-distributed wrapper on the input data in the time dimension. The number of output channels is C (the number of features), and the activation function is softmax.

[0090] Calculate feature attention weights:

[0091] β t =softmax(Conv2D 1×1 (H t ))

[0092] Among them, the softmax activation function is applied on the channel (feature) dimension:

[0093]

[0094] Ensure that at each spatial position, the sum of the attention weights of all features is 1:

[0095]

[0096] Apply attention weights:

[0097]

[0098] Output:

[0099] The final weighted output sequence:

[0100] The corresponding feature attention weight sequence {β1,β2,…,β T}.

[0101] Processing of subsequent layers:

[0102] Time-distributed Flatten layer:

[0103] Purpose: Expand the spatial features of each time step into a one-dimensional vector.

[0104] accomplish:

[0105] Time-distributed fully connected layer (Dense layer):

[0106] Purpose: To further process the unfolded features.

[0107] accomplish:

[0108] D t =Dense(F t ), where the number of units in the Dense layer is a hyperparameter and can be adjusted, and the activation function is ReLU.

[0109] Dropout layer:

[0110] Purpose: To prevent overfitting.

[0111] Global average pooling layer (GlobalAveragePooling1D):

[0112] Purpose: Aggregate features in the time dimension.

[0113] accomplish:

[0114]

[0115] Output layer:

[0116] Purpose: To predict target values, simulate and predict the state of physical systems, and provide support for digital twins.

[0117] accomplish:

[0118]

[0119] Model training and implementation:

[0120] Loss function:

[0121] Use Mean Squared Error (MSE) as the main loss function:

[0122]

[0123] Where N is the number of samples, y is the true value, is the predicted value.

[0124] Optimizer:

[0125] The adaptive moment estimation (Adam) optimizer is used, and the learning rate η is a hyperparameter that can be dynamically adjusted based on the performance of the validation set.

[0126] Training strategy:

[0127] Early Stopping: Stop training when the validation set loss stops decreasing.

[0128] Learning rate adjustment: Dynamically reduce the learning rate when validation loss does not improve.

[0129] Complete model calculation process:

[0130] For each time step t:

[0131] Input H after deep convolutional LSTM layer processing t

[0132] Calculate the spatial attention weight α t

[0133] Applying spatial attention

[0134] Calculate feature attention weight β t

[0135] Applying Feature Attention

[0136] Flatten feature

[0137] Fully connected layer output

[0138] In this implementation example, this model architecture is applied to hydrological simulations to process various gridded land surface data, including variables such as radiation, evaporation, runoff, temperature, and snow depth. This data is first processed through a DepthwiseConvLSTM2D layer, which captures spatial and temporal dependencies in the input data. Performance is enhanced by incorporating a dual attention mechanism.

[0139] The TimeDistributedSpatialAttention layer is able to identify which spatial locations in the grid have an important influence at each time step. It outputs weighted spatial data and corresponding attention weights, allowing the model to focus on the most relevant areas. Similarly, the FeatureWiseAttention layer helps identify the temporal importance of each environmental feature (such as temperature, precipitation, or snow depth), and the output of the model includes three parts: hydrological prediction results, spatial attention weights, and feature attention weights. These attention weights provide valuable information about which parts of the input data (whether spatial or feature) the model focuses on when making predictions. The dual attention mechanism not only improves the model's prediction accuracy, but also enhances the model's interpretability, helping to better understand how environmental factors and location affect hydrological processes such as runoff, snowmelt, and evaporation. As Figure 3-6 As shown, the attention mechanism of the model can be spatially visualized according to any time period as follows, Figure 3 The model shows the key hydrological impact areas of a certain region in the early monsoon period, obtained based on the attention mechanism analysis. The darker the color, the greater the impact of the geographical space on the hydrology. Figure 4 The model shows the key hydrological impact areas of a region during the monsoon period obtained based on the attention mechanism analysis. Figure 5-6 The model shows the key hydrological impact areas in a certain region in the late monsoon period obtained based on the attention mechanism analysis, indicating that the model effectively captures the spatiotemporal impact of monsoon movement on hydrology.

[0140] The application of digital twins in urban digital twins is that models can be used to predict traffic flow, energy consumption, etc., to support urban planning and management; in digital twins of industrial equipment, models can be used to predict equipment failures, optimize production processes, improve efficiency and reduce costs; in digital twins of ecosystems, models can be used to predict pollution spread, the impact of climate change, etc., to support environmental protection and decision-making.

[0141] Due to the flexibility and data independence of the model structure, this method can be applied to digital twin modeling of various physical systems, including but not limited to hydrology, atmosphere, ocean, ecosystems, and industrial processes. Through the dual attention mechanism, the model can capture complex spatiotemporal dynamics and feature importance, providing a high-precision model for digital twins and supporting real-time monitoring, prediction, and optimization.

[0142] Figure 7 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 7 At the hardware level, the electronic device includes a processor and, optionally, an internal bus, a network interface, and memory. The memory may include internal memory, such as high-speed random-access memory (RAM), or non-volatile memory, such as at least one disk drive. Of course, the electronic device may also include other hardware required for its services.

[0143] The processor, network interface, and memory can be interconnected via an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or one type of bus.

[0144] The memory is used to store programs. Specifically, the program may include program code, which includes computer operating instructions. The memory may include internal memory and non-volatile memory, and provides instructions and data to the processor.

[0145] The processor reads the corresponding computer program from the non-volatile memory into the internal memory and then runs it, forming a modeling device based on the dual attention mechanism at the logical level. The processor executes the program stored in the memory and is specifically used to perform any of the aforementioned modeling methods based on the dual attention mechanism.

[0146] In this implementation example, a modeling method based on the dual attention mechanism is deployed on a GPU server, using Python 3.8, and performing data processing and modeling on a Linux system equipped with a 32-core CPU, 188GB of memory, and an A10 GPU.

[0147] The above application Figure 1 The modeling method based on the dual attention mechanism disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits in the processor or by software instructions. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. The various methods, steps, and logic block diagrams disclosed in the embodiments of this application can be implemented or executed. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this application can be directly implemented and executed by a hardware decoding processor, or by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium well-known in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. The storage medium is located in the memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps of the above method.

[0148] The electronic device may also perform Figure 1 A modeling method based on dual attention mechanism and implementation Figure 1 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.

[0149] An embodiment of the present application also proposes a computer-readable storage medium, which stores one or more programs, and the one or more programs include instructions. When the instructions are executed by an electronic device including multiple applications, any one of the aforementioned modeling methods based on the dual attention mechanism is executed.

[0150] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0151] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0152] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0153] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 The steps for the function specified in one or more boxes.

[0154] In a typical configuration, a computing device includes one or more processors (CPUs), input / output interfaces, network interfaces, and memory.

[0155] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.

[0156] Computer-readable media includes permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0157] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.

[0158] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0159] The foregoing is merely an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application should all be included within the scope of the claims of the present application.

Claims

1. A modeling method based on a dual attention mechanism, characterized in that: Application of the model framework to hydrological simulations to process various gridded / gridded land surface data, including radiation, evaporation, runoff, temperature, and snow depth variables; a) Take a four-dimensional tensor as input data; Processing land surface data through the Depthwise ConvLSTM2D layer can capture the spatial and temporal dependencies in the input data and enhance performance by integrating the dual attention mechanism; b) extracting spatiotemporal features of the input data through a deep convolutional long short-term memory network, applying a ConvLSTM2D layer to each feature channel of the input, and concatenating them in the feature dimension; The TimeDistributedSpatialAttention layer identifies which spatial locations in the grid are most influential at each time step. It outputs weighted spatial data and corresponding attention weights, allowing the model to focus on the most relevant areas. The FeatureWiseAttention layer helps identify the temporal importance of each environmental feature, including temperature, precipitation, or snow depth. c) integrating time-distributed spatial attention and feature attention into a deep learning framework, wherein the time-distributed spatial attention calculates spatial attention weights by using a two-dimensional convolutional layer with time distribution wrapping on the input data in the time dimension, and the feature attention mechanism calculates feature attention weights by using a two-dimensional convolutional layer with time distribution wrapping on the input data in the time dimension; d) Expand the spatial features of each time step into a one-dimensional vector through the time-distributed Flatten layer; e) applying a global average pooling layer to the one-dimensional vector to aggregate features in the time dimension; f) predict the target value through the output layer; The spatial attention weight is calculated by performing a convolution operation on the input data of each time step and applying a sigmoid activation function. The formula for calculating the spatial attention weight is: Among them, Conv2D is a two-dimensional convolution operation, the filling method is "same", σ() is the sigmoid activation function, is the input of time step t; The feature attention weight is calculated by performing a 1×1 convolution operation on the input data of each time step and applying a softmax activation function. The formula for calculating the feature attention weight is: Among them, e is a natural constant, Represents the input value of softmax, and the summation operation is performed on all channels C at each spatial position (i, j), ensuring that at each spatial position (i, j), the sum of the attention weights of all features is 1: That is, the softmax function is normalized along the channel dimension k, which means that at a certain time step t and spatial position (i, j), the attention weights of all feature channels are distributed proportionally; The global average pooling layer aggregates features in the time dimension to achieve the following formula: The model training process uses mean squared error as the loss function and is optimized using an adaptive moment estimation optimizer; The loss function is as follows: Where N is the number of samples, y is the true value, is the predicted value; The output of the model includes three parts: hydrological prediction results, spatial attention weights, and feature attention weights.

2. A modeling method based on a dual attention mechanism according to claim 1, characterized in that: Training strategies include early stopping and dynamically adjusting learning rates.

3. The modeling method based on the dual attention mechanism according to claim 1, characterized in that: The four-dimensional tensor includes the number of time steps, the height, width and number of features in the spatial dimension.

4. The modeling method based on the dual attention mechanism according to claim 1, characterized in that: After the depthwise convolutional LSTM layer, batch normalization and dropout layers are applied to stabilize the training process and prevent overfitting.

5. The modeling method based on the dual attention mechanism according to claim 1, characterized in that: Extracting spatial and feature attention weights during model inference and , ; .

6. The modeling method based on the dual attention mechanism according to claim 1, characterized in that: The model implementation environment uses Python language, and the deep learning framework uses TensorFlow or PyTorch.

7. An electronic device, characterized in that: include: processor; and a memory arranged to store computer-executable instructions, which, when executed, cause the processor to perform the method of any one of claims 1 to 6.