Modeling method based on double attention mechanisms

By adopting a dual attention mechanism method in digital twin modeling, spatial and feature attention are integrated, and modeling problems of traditional models under complex space-time dynamics and multi-dimensional features are solved, and digital twin modeling with high precision and interpretability is achieved.

CN119720785AActive Publication Date: 2025-03-28夏萃慧
View PDF 7 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

The prior art is difficult to build high-precision digital twins, especially in the case of complex space-time dynamic and multidimensional features, and the lack of interpretability of traditional AI models, limiting their applicability in digital twin modeling and physical system understanding.

Method used

The modeling method based on the dual attention mechanism is adopted to extract spatiotemporal features through deep convolutional long and short-term memory networks, and integrate the spatial and feature attention of the time distribution in the deep learning framework, calculate the spatial and feature attention weights, and enhance the interpretability and prediction ability of the model.

Benefits of technology

It realizes effective capture of complex spatial and spatial dynamics and feature importance, improves the high-precision modeling and interpretability of digital twins, and enhances the flexibility and generalization capabilities of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119720785A_ABST
    Figure CN119720785A_ABST
Patent Text Reader

Abstract

The invention discloses a modeling method based on a double attention mechanism. The modeling method comprises the following steps: taking a four-dimensional tensor as input data; extracting spatio-temporal features of the input data through a deep convolutional long short-term memory network, applying a ConvLSTM2D layer to each input feature channel, and splicing the feature channels on feature dimensions; time distribution space attention and feature attention are integrated into a deep learning framework, and the space feature of each time step is expanded into a one-dimensional vector through a time distribution Flaten layer; performing feature aggregation on the one-dimensional vector in a time dimension by applying a global average pooling layer; a target value is predicted by an output layer. According to the method, a dual attention mechanism is utilized, an algorithm is utilized for modeling for important spatial positions and features changing along with time, pre-analysis of data is not needed, and prediction accuracy, interpretability and generalization ability under multiple space-time scenes are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] In recent years, digital twins, as high-precision mappings of the physical world in digital space, have become key technologies in fields such as smart manufacturing, smart cities, and earth system science. Digital twins acquire and analyze data from physical systems in real time to monitor, predict, and optimize system states in real time. However, building high-precision digital twins requires accurate modeling and simulation of physical systems, especially when complex spatiotemporal dynamics and multidimensional features are involved.

[0003] Traditional Earth system models are usually equation-driven and rely on predefined equations to represent physical processes. These models face challenges in capturing complex nonlinear interactions and high-dimensional data in Earth system processes, and have difficulty meeting the real-time and accuracy requirements of digital twins. In addition, they usually lack flexibility and generalization capabilities in different regions and scenarios.

[0004] Artificial Intelligence (AI) methods, especially 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 usually use only a single attention mechanism and are limited to specific applications, which 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 complex nonlinear interactions in physical systems, lack flexibility and generalization capabilities, and are difficult to meet the requirements of digital twins for high precision and real-time performance. Although powerful, traditional AI models usually act as 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 in physical systems, limiting the ability of digital twins in modeling complex systems. Therefore, a modeling method 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 present application embodiment adopts 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 the 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 wrapped with time distribution on the time dimension of the input data, and the feature attention mechanism calculates feature attention weights by using a two-dimensional convolutional layer wrapped with time distribution on the time dimension of the input data;

[0012] d) The spatial features of each time step are expanded 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] Make sure 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 a 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 deep 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 feature changes in physical systems, providing support for high-precision modeling of digital twins.

[0035] (2) The present invention enhances the interpretability in AI-driven physical system models by utilizing a dual attention mechanism, reveals important spatial locations and features that change over time, and improves 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 algorithm 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 a key area of ​​influence obtained by analyzing a model based on an attention mechanism according to a modeling method based on a dual attention mechanism provided in an embodiment of this specification;

[0041] Figure 4 A schematic diagram of a key area of ​​influence obtained by analyzing an attention mechanism according to a modeling method based on a 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 a key area of ​​influence provided by a modeling method based on a dual attention mechanism in an embodiment of this specification;

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

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

[0045] The present invention is further described in detail below by specific embodiments in conjunction with the accompanying drawings. Wherein similar elements in different embodiments adopt associated similar element numbers. In the following embodiments, many detailed descriptions are for making the present application better understood. However, those skilled in the art can easily recognize that some features can be omitted in different situations, or can be replaced by other elements, materials, methods. In some cases, some operations related to the present application are not shown or described in the specification, and this is to avoid the core part of the present application being overwhelmed by too much description, and for those skilled in the art, it is not necessary to describe these related operations in detail, and they can fully understand the related operations according to 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 can be combined in any appropriate manner to form various implementations. At the same time, the steps or actions in the method description can also be interchanged or adjusted in a manner that is obvious to those skilled in the art. Therefore, the various sequences in the specification and the drawings are only for the purpose of clearly describing a certain embodiment and are not meant to be a required sequence, unless otherwise specified that a certain sequence must be followed.

[0047] The serial numbers of the components in this document, such as "first", "second", etc., are only used to distinguish the objects described and do not have any order or technical meaning. The "connection" and "coupling" mentioned in this application, unless otherwise specified, include direct and indirect connections (couplings).

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

[0049] like Figure 1 As shown, the present invention provides a modeling method based on a dual attention mechanism, which is applicable to a variety of spatiotemporal scenarios in physical world digital twins. The 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, and provides a high-precision and interpretable model for the construction of digital twins, including the following steps:

[0050] The technical solution is as follows:

[0051] Model Architecture:

[0052] Input Layer:

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

[0054] T: number of time steps;

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

[0056] C: Number of features.

[0057] Depthwise ConvLSTM2D:

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

[0059] Implementation: Apply a ConvLSTM2D layer to each feature channel of the input and then concatenate across 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) TimeDistributedSpatialAttention:

[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, and 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 both spatial position and time step.

[0089] Implement a 1×1 two-dimensional convolutional layer that uses time distribution (TimeDistributed) to wrap 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] Make sure 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] Flatten layer of time distribution:

[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, the model architecture is applied in hydrological simulation to process various gridded / gridded land surface data, including radiation, evaporation, runoff, temperature, snow depth and other variables. The data is first processed through the DepthwiseConvLSTM2D layer, which can capture the spatial and temporal dependencies in the input data. The performance is enhanced by integrating the dual attention mechanism.

[0139] The TimeDistributedSpatialAttention layer identifies which spatial locations in the grid have 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 (either 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. 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 areas of hydrological impact 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, 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 of the model structure and data independence, 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 also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.

[0143] The processor, network interface and memory can be interconnected through 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 only one type of bus.

[0144] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a 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 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 execute 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 A modeling method based on a 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. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or instructions in the form of software. The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may 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 gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in a decoding processor. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0148] The electronic device may also perform Figure 1 A modeling method based on dual attention mechanism is implemented 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 may be provided as methods, systems, or computer program products. Therefore, the present application may 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 may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include 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 generate 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 capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A 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 operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

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

[0155] The 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. The memory is an example of a computer-readable medium.

[0156] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. 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 disk read-only memory (CD-ROM), digital versatile disk (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 temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0157] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[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 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 may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0159] The above is only 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 modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A modeling method based on a dual attention mechanism, characterized in that: a) Take a four-dimensional tensor as input data; b) extracting the 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; 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 wrapped with time distribution on the time dimension of the input data, and the feature attention mechanism calculates feature attention weights by using a two-dimensional convolutional layer wrapped with time distribution on the time dimension of the input data; d) The spatial features of each time step are expanded 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.

2. A modeling method based on a dual attention mechanism according to claim 1, characterized in that: 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: a t =σ(Conv2D(H t )) 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.

3. The modeling method based on the dual attention mechanism according to claim 1, characterized in that: 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, where the formula for calculating the feature attention weight is: β t =softmax(Conv2D 1×1 (H t )) Among them, e is a natural constant, z i 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 the attention weights of all feature channels are distributed proportionally at a certain time step (t) and spatial position (i, j).

4. The modeling method based on the dual attention mechanism according to claim 1, characterized in that: The training process of the model uses mean square error as the loss function and is optimized using an adaptive moment estimation optimizer.

5. The modeling method based on the dual attention mechanism according to claim 1, characterized in that: The training strategies include early stopping and dynamic adjustment of learning rate.

6. A modeling method based on a 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.

7. A modeling method based on a 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.

8. A modeling method based on a dual attention mechanism according to claim 1, characterized in that: During model inference, the spatial and feature attention weights α are extracted t and β t , 9. A modeling method based on a 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.

10. 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 9.

Citation Information

Patent Citations

  • Short-term load prediction model and method based on double attention mechanism and LSTM

    CN113902202A

  • Typhoon prediction method, system and equipment based on space-time attention and medium

    CN116822716A

  • Traffic flow prediction method

    CN117275230A

  • Forest canopy height inversion model of double attention mechanism deep network

    CN118447402A

  • Pipeline system fault diagnosis method and system based on hierarchical attention mechanism

    CN119004322A