Action recognition method introducing frame clustering and self-attention time shifting module
By introducing frame clustering and self-attention time-shift modules, combined with the video division algorithm based on the maximum entropy principle and the local detail enhancement module, the problems of frame clustering error and low temporal modeling ability are solved, and a more efficient action recognition effect is achieved. .
Patent Information
- Application Number
- CN202410694617.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2044-05-31
AI Technical Summary
In the existing technology, the frame clustering method causes the video division strategy to affect the model effect, the time shift module is difficult to model complex actions, and the multi-head self-attention mechanism is highly complex and difficult to support the application of large models.
The frame clustering and self-attention time shift modules are introduced, and the video partitioning algorithm based on the maximum entropy principle is used to optimize the frame clustering results. It is combined with the local detail enhancement module and the self-attention time shift network to reduce errors and improve temporal modeling capabilities.
It reduces the model complexity, improves the accuracy of action recognition and time modeling capabilities, and enhances the ability to recognize actions.
Smart Images

Figure CN118553014A
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of action recognition, and in particular relates to an action recognition method that introduces frame clustering and self-attention time-shift modules. Background Art
[0002] The frame clustering method is to solve the problem of information loss caused by video sampling. It is a method of clustering video frames in the early stage of the network by directly superimposing frame activations. Usually, if a deep learning model inputs all frames into the network, it is necessary to retain the activation and gradient of each frame at each layer for back propagation. Therefore, if the frames are clustered in the early stage to reduce the scale, the memory consumption can be greatly reduced. However, the operation of merging frames will inevitably cause errors in the network. The frame clustering method is also based on a priori knowledge, that is, if the positive and negative signs of activations using the ReLU function are consistent, then accumulating the gradient after the frame activation is equivalent to accumulating the activation first and then calculating the gradient. Therefore, the error caused by frame clustering also depends on the proportion of sign consistency in the clustered frame activations. Therefore, the division method of video clustering determines the quality of the frame clustering effect.
[0003] The temporal shift module is a channel fusion method based on shift. The shift operation was first proposed to replace the convolution operation. The shift operation moves each channel of its input tensor along different spatial directions. For example, in two-dimensional data, it can be moved horizontally, vertically or diagonally. Unlike spatial and depth convolution, the shift operation itself does not require parameters or floating-point operations, but is implemented through a series of memory operations. Due to the characteristics of shift operation without parameters and FLOP, the complexity and computational complexity of the model can be greatly reduced. In order to solve the problem of high complexity when extracting features for action recognition using 3D convolution, the temporal shift module (TSM) was proposed and applied to the action recognition model. The core idea of TSM is to introduce operations on the time dimension into the network. Generally, a CNN model can effectively process two-dimensional images and extract their features. In order to enable the network to acquire the ability to capture time dimension features, TSM divides the input video feature tensor along the time dimension and moves some channels along the time dimension to the features of adjacent frames in the past and future. After shifting the channels, the feature map of each frame will contain most of the original features as well as some of the features of the previous frame and some of the features of the next frame. However, time shifting is too naive to model complex actions.
[0004] The multi-head self-attention mechanism is a mechanism for modeling sequence data. It was originally introduced into neural networks to handle natural language processing tasks and is widely used in transformer models. The multi-head self-attention mechanism allows the model to interact and associate between different positions within the sequence, so that it can capture long-distance dependencies in the sequence. The basic idea of the self-attention mechanism is to model the sequence by calculating the correlation between each position in the sequence and other positions. In the self-attention mechanism, given an input sequence X and the corresponding feature representation matrix, the model obtains the representation of each position by calculating the attention weight between each pair of elements. These attention weights are used to weighted sum the representations of other positions in the sequence to obtain a context-aware representation of each position. However, the complexity of the transformer model is very high, quadratically proportional to the number of vectors applied to the transformer, and it is difficult to support large transformer models in common devices.
[0005] In summary, frame clustering has the characteristic of saving resources, but it will be affected by the video segmentation strategy and will inevitably produce errors. The time shift module has the characteristic of low complexity, but since simple shifting is difficult to model time well, the effect of the model will be affected. The multi-head self-attention mechanism supports information exchange by fully connecting several vectors, but it has the characteristic of high complexity. Summary of the invention
[0006] The purpose of the present invention is to overcome the shortcomings of the prior art and provide an action recognition method that introduces frame clustering and self-attention time-shifting modules, and proposes a video segmentation algorithm based on the maximum entropy principle, which optimizes the video clustering results in frame clustering, thereby reducing the errors caused by clustering; at the same time, the TSM module is combined with the multi-head self-attention mechanism to solve the problem of poor temporal modeling ability of lightweight action recognition models caused by naive time shifting.
[0007] The present invention solves the technical problem by the following technical solutions:
[0008] An action recognition method that introduces frame clustering and self-attention time shift modules, characterized in that: the model of the recognition method includes a frame clustering module, a local detail enhancement module and a self-attention time shift network; the frame clustering module divides and clusters video frames in the early stage of the model; the local detail enhancement module provides the model with action detail features in a tiny time neighborhood; the self-attention time shift network further extracts the spatiotemporal features of the action for the final classification task;
[0009] The frame clustering module aims to divide the video into a fixed number of segments and aggregate the features of the frames of each segment, that is, for a given video input V = {f1, f2, ... f n} Divide it into several paragraphs p={p1,p2…p T}, where n represents the number of frames in the video, T is a hyperparameter of the model, and represents the number of segments divided. and represents the start and end frames of the segment, and ∑ 1≤i≤T p i =V; then the frame clustering module will generate a merged feature F = [F1, F2, ..., F T ], the generated merged features will be input to the next module.
[0010] Moreover, the frame clustering module uses a video segmentation algorithm based on the maximum entropy principle to segment the video. The optimization objective formula of the method is:
[0011]
[0012] Where: d is the distance metric used to measure the difference between two video segments;
[0013] The overall structure of the algorithm is greedy. Its goal is to find the global optimal solution that maximizes the D value, and to continuously and greedily search for the segmentation points of the video segments to achieve the local optimal solution, so that the D value is the maximum value that can be achieved at present.
[0014] (1) First, initialize and process the video frames to obtain N segmentation points as candidate segmentation points for dividing the video segments. Select the N adjacent frames with the largest differences as candidate segmentation points, binarize the frame activations, and calculate the Hamming distances of all adjacent frames.
[0015] (2) Select the segmentation points between N frames according to the largest N Hamming distances, where N is usually one eighth of the total number of video frames n;
[0016] (3) Find the current local optimal solution, consider N segmentation points in sequence, try to divide the video segment at each segmentation point, and calculate the D value after division, find the average of each segment, and then calculate the cosine similarity between different video segments as the D value. The calculation method is shown in the formula:
[0017]
[0018] After comparing and obtaining the partition point that maximizes the current D value, the algorithm finds the current local optimal solution, uses this partition point to split the video frame and records that the partition point has been used. Then the algorithm continues to look for the next local optimal solution, greedily selecting the partition point that maximizes the D value from the remaining N-1 partition points, and repeats T-1 times until all T-1 partition points are determined.
[0019] Moreover, the frame clustering module aggregates the divided frame activations by averaging the frame activations of each segment, generating T activations for the video, expressed as the formula:
[0020] F=[F1,F2,……F T ]
[0021]
[0022] Among them: F i represents the merged features of the i-th fragment;
[0023] I j Indicates that it belongs to fragment f i The activation of video frame j;
[0024] |f i | indicates the frame number of the clip;
[0025] The above aggregated features will be input into the subsequent self-attention time shift network to further extract the overall action features of the video.
[0026] Moreover, the local detail enhancement module obtains the division and merging features of each video segment from the frame aggregation module as input, and extracts detailed features of each segment, which is expressed as a formula:
[0027] F′=[F′1,F′2,…F′ T ]
[0028] F′ i =F i +H(I[I1,I2,I3,I4,I5])
[0029] Where: H represents the extraction of motion features of the clip, I represents the set of representative frames of the clip, and each video clip in the model uses five representative frames;
[0030] The local detail enhancement module selects several sample frames, stacks their RGB differences, and uses CNN to extract the local detail features of the motion of the video clip. A uniform sampling strategy is designed. For a video clip of length m, the model uniformly selects five video frames and stacks their RGB differences along the channel direction, as shown in the formula:
[0031] D=[f mid / 2 -f1,f mid -f mid / 2 ,f 3mid / 2 -f mid ,f m -f 3mid / 2 ]
[0032] Where: f mid Indicates the middle frame of the clip;
[0033] A lightweight CNN module is designed to process the stacked RGB differences. The module adopts a low-resolution processing strategy: first downsample it using average pooling, then use CNN to extract features and then upsample it to match the extraction of the spatial features of the fragment, expressed as a formula:
[0034] H(p i )=Upsample(CNN(Downsample(D(p i ))))
[0035] Where: D represents the i-th video segment p i The represents the RGB difference of the frame stack.
[0036] Moreover, the self-attention time shift network linearly transforms part of the feature map of each frame in the TSM network and adds position encoding to obtain the time series X = x1, x2, ..., x T ; Then the model further performs a linear transformation on the obtained time series to obtain the query (Query), key (Key) and value (Value) of each element; Then the model calculates the attention score Attention, for each query q i , calculate its relationship with all keys k i The similarity score of , using the dot product attention method, refer to the formula:
[0037]
[0038] Next, the attention scores are converted into attention weights through the softmax function, and these weights are used to calculate the weighted sum of the value vectors to obtain the attention vector at the sequence position i. The calculation method refers to the formula:
[0039]
[0040] The multi-head self-attention mechanism applies the above process to multiple combinations of queries, keys, and values to obtain multiple different attention representations, and then connects and integrates the attention vectors of multiple heads to obtain the final output MultiHead; finally, it is time-shifted and spliced with the original feature map. The multi-head attention output will pass through a linear layer to adjust its shape back to the feature map.
[0041] The advantages and beneficial effects of the present invention are:
[0042] 1. The present invention greatly reduces the complexity of inputting all video frames into the model;
[0043] 2. The present invention improves the temporal modeling capability of the model, and the accuracy of the model for action recognition is improved;
[0044] 3. The present invention supplements the local detail features in the video and can better identify the action. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 It is a schematic diagram of the overall structure of the model of the present invention;
[0046] Figure 2 It is a schematic diagram of a frame clustering module of the present invention;
[0047] Figure 3 Schematic diagram of the self-attention time shift network of the present invention. DETAILED DESCRIPTION
[0048] The present invention is further described in detail below through specific examples. The following examples are only illustrative and not restrictive, and the protection scope of the present invention cannot be limited thereto.
[0049] The embodiment of the present invention discloses an action recognition method that introduces frame clustering and self-attention time shift modules. The innovation of the method is that the core of the technical solution of the present invention is a set of action recognition models that introduce frame clustering and self-attention time shift modules. The model mainly consists of three parts, namely, a frame clustering module, a local detail enhancement module and a self-attention time shift network. The overall structure of the model is shown in Figure (1). The frame clustering module divides and clusters the video frames in the early stage of the model, reducing the memory pressure of the subsequent model and minimizing the error generated. The local detail enhancement module provides the model with action detail features in a small time neighborhood, and the self-attention time shift network further extracts the spatiotemporal features of the action for the final classification task.
[0050] 1) Frame clustering module
[0051] In order to prevent information loss due to frame sampling while introducing as little additional memory usage as possible, the present invention chooses to aggregate the information of video frames in the early stage of the model to replace frame sampling, which can not only preserve the original information of the video, but also reduce the memory consumption of the model. Therefore, the frame clustering module aims to divide the video into a fixed number of segments and aggregate the features of the frames of each segment, that is, for a given video input V = {f1, f2, ... f n}, the present invention hopes to divide it into several sections p = {p1, p2...p T}, where n represents the number of frames in the video, T is a hyperparameter of the model, and represents the number of segments divided. and represents the start and end frames of the segment, and ∑ 1≤i≤T p i = V. Then the frame clustering module will generate a merged feature F = [F1, F2, ..., F T ]. The generated merged features will be input to the next module.
[0052] In order to better divide the video, the present invention proposes a video segmentation algorithm based on the maximum entropy principle. Video data is a kind of time series data. Due to the instability of time series data, the distribution of data will change all the time. Therefore, the deep learning network needs to learn the public knowledge in these different distributions to accurately determine the category of the video. The maximum entropy principle is a criterion for selecting the statistical characteristics of random variables that best conform to the objective situation. According to the maximum entropy principle, the model with the largest entropy is the best model. When no prior assumptions are made on the segmentation of time series data, it is most reasonable to make each segment as diverse as possible to maximize the entropy of the total distribution. Because this allows the model to model the data more generally and flexibly in the future. Dividing the video data according to the maximum entropy also means that the divided video segments do not contain any default priors, which is equivalent to training the model under the "worst" situation, so that the trained model has better generalization ability. The model can improve the entropy of the total distribution by maximizing the differences between the different segments divided. Based on this, the present invention designs a video segment segmentation algorithm in the frame aggregation module, which can be implemented by solving an optimization problem. The goal of the optimization problem can be expressed as a formula:
[0053]
[0054] Where d is a distance metric used to measure the difference between two video segments. Euclidean distance, cosine similarity, etc. can be used.
[0055] The algorithm is a greedy structure, and its goal is to find the global optimal solution that maximizes the value of D. The basic process of the algorithm is to continuously and greedily find the segmentation points of the video segments to achieve the local optimal solution, so that the value of D is the maximum value that can be achieved at present.
[0056] The algorithm is first initialized and the video frames are processed to obtain N segmentation points as candidate segmentation points for dividing the video segments. Therefore, how to select the segmentation points becomes one of the keys of the algorithm. Considering the segmentation point between two frames, the algorithm selects N adjacent frames with the largest difference as candidate segmentation points. The present invention believes that the Hamming distance is a good choice to measure the similarity between frames. Therefore, the model first binarizes the frame activation and then calculates the Hamming distance of all adjacent frames.
[0057] Then, the algorithm selects N split points between frames based on the largest N Hamming distances. N is usually one eighth of the total number of video frames n. Not all n split points are used here because the time complexity of the algorithm is positively correlated with the alternative split points. The model usually clusters the video into 8 frames, and the number of frames in a 10-second video is often between 200 and 300. So the size of N can meet the needs of the model.
[0058] Next, the algorithm starts to find the current local optimal solution. Consider N segmentation points in order, try to divide the video segments at each segmentation point, and calculate the D value after the division. The present invention uses cosine similarity as a metric, first calculates the average of each segment, and then calculates the cosine similarity between different video segments as the D value. The calculation method is shown in the formula:
[0059]
[0060] After comparing and finding the partition point that maximizes the current D value, the algorithm finds the current local optimal solution, uses this partition point to split the video frame and records that the partition point has been used. Then the algorithm continues to look for the next local optimal solution, greedily selecting the partition point that maximizes the D value from the remaining N-1 partition points. Repeat T-1 times in this way until all T-1 partition points are determined.
[0061] The structure of the frame clustering algorithm is shown in Figure (2). The present invention combines the video frame segmentation algorithm based on the maximum entropy principle with the frame clustering algorithm. The clustering module aggregates the divided frame activations by averaging the frame activations of each segment, thereby generating T activations for the video. It can be expressed as the formula:
[0062] F=[F1,F2,……F T ]
[0063]
[0064] Among them, F i represents the merged features of the i-th segment, I j Indicates that it belongs to fragment f i The activation of video frame j, |f i | represents the frame number of the clip. These aggregated features will be input into the subsequent TSM network to further extract the overall action features of the video.
[0065] 2) Local detail enhancement module
[0066] This part obtains the division and merging features of each video segment from the frame aggregation module as input, and extracts detailed features of each segment, which can be expressed as the formula:
[0067] F′=[F′1,F′2,…F′ T ]
[0068] F′ i =F i +H(I[I1,I2,I3,I4,I5])
[0069] Where H represents the extraction of motion features of the clip, I represents the set of representative frames of the clip, and five representative frames are used for each video clip in the model.
[0070] Since the frame clustering module divides the video based on the maximum entropy principle, for a certain video clip, the frames within the clip may often be similar. Calculating the RGB difference between two similar frames can emphasize the local areas where changes occur. Therefore, the LDEM module selects several sampling frames, stacks their RGB differences, and uses CNN to extract the local detail features of the motion of the video clip. For the selection of sampling frames, too long or too short time spans are not conducive to the network's motion modeling of the target. Too long time spans are prone to ignore the subtle changes in the action, and because the span is too long, the difference between frames is too large, which makes CNN lose focus when extracting features. Too short time spans will easily obtain extremely sparse features due to the excessive redundancy of the information in the video frames. Therefore, a uniform sampling strategy is designed. For a video clip of length m, the model uniformly selects five video frames and stacks their RGB differences along the channel direction, as shown in the formula:
[0071] D=[f mid / 2 -f1,f mid -f mid / 2 ,f 3mid / 2 -f mid ,f m -f 3mid / 2 ]
[0072] where f mid Indicates the middle frame of the clip.
[0073] Due to the similarity between video frames, the calculated RGB differences often produce higher responses locally, but show low responses in most areas. Therefore, the present invention designs a lightweight CNN module to process the stacked RGB differences without losing too much accuracy. The module adopts a low-resolution processing strategy: first downsample it using average pooling, then use CNN to extract features and then upsample to match the extraction of the spatial features of the segment, which can be expressed as a formula:
[0074] H(p i )=Upsample(CNN(Downsample(D(p i ))))
[0075] Where D represents the i-th video segment p i The represents the RGB difference of the frame stack.
[0076] In addition, regarding the spatial features of video clips, compared with using a single video frame to encode the video clips, using aggregated features as the spatial features of the video clips can enable the model to retain richer video semantic information. Therefore, the present invention directly uses the aggregated features obtained in the frame aggregation module as the spatial features of the clip, and connects them with the motion features to obtain the merged features of the clip.
[0077] 3) Self-Attention Temporal Shift Network
[0078] The self-attention time-shifting module is shown in Figure (3). The simple time-shifting module cannot model complex action changes, so the present invention designs a self-attention time-shifting module to improve TSM. Due to the fully connected characteristics of the self-attention mechanism, the high complexity it brings is often unacceptable for lightweight networks. However, since the complexity of the self-attention mechanism is positively correlated with the quadratic power of the sequence length, and the model proposed in the present invention aggregates video frames through frame clustering in the early stage, resulting in a significant reduction in the number of frames. Therefore, it is feasible to use the self-attention mechanism in the model in the article. In order to optimize the time-shifting module in the TSM network, the present invention applies the self-attention mechanism to the feature map to be time-shifted in the network. This approach can help the model capture global dependencies in the time dimension, thereby better understanding the relationship between different frames in the video, and the model can better consider the relationship between each video frame and other video frames when performing time shifting. At the same time, the self-attention mechanism can dynamically learn the relationship between each video frame, which enhances the model's temporal modeling ability and further improves the model's ability to extract video action temporal features, thereby improving the model's expression ability and model performance. In order to apply the self-attention mechanism to the time-shift module, the model first linearly transforms part of the feature map of each frame in the TSM network and adds position encoding to obtain the time series X = x1, x2, ..., x T The model then further performs a linear transformation on the obtained time series to obtain the query, key, and value of each element.
[0079] The model then calculates the attention score Attention, for each query q i , calculate its relationship with all keys k i The similarity score of , using the dot product attention method, refer to the formula:
[0080]
[0081] Next, the attention scores are converted into attention weights through the softmax function, and these weights are used to calculate the weighted sum of the value vectors to obtain the attention vector at the sequence position i. The calculation method refers to the formula:
[0082]
[0083] The multi-head self-attention mechanism applies the above process to multiple combinations of queries, keys, and values to obtain multiple different attention representations, and then connects and integrates the attention vectors of multiple heads to obtain the final output MultiHead. Finally, in order to restore the result to a feature map, re-time-shift and splice it with the original feature map, the multi-head attention output will pass through a linear layer to adjust its shape back to the feature map.
[0084] Although the embodiments and drawings of the present invention are disclosed for illustrative purposes, those skilled in the art will appreciate that various substitutions, changes and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the scope of the present invention is not limited to the contents disclosed in the embodiments and drawings.
Claims
1. An action recognition method introducing frame clustering and self-attention time-shifting module, characterized by: The model of the recognition method includes a frame clustering module, a local detail enhancement module and a self-attention time shift network; the frame clustering module divides and clusters the video frames in the early stage of the model; the local detail enhancement module provides the model with action detail features in a small time neighborhood; the self-attention time shift network further extracts the spatiotemporal features of the action for the final classification task; The frame clustering module aims to divide the video into a fixed number of segments and aggregate the features of the frames of each segment, that is, for a given video input V = {f1, f2, ... f n } Divide it into several paragraphs p={p1,p2…p T }, where n represents the number of frames in the video, T is a hyperparameter of the model, and represents the number of segments divided. and represents the start and end frames of the segment, and ∑ 1≤i≤T p i =V; then the frame clustering module will generate a merged feature F = [F1, F2, ..., F T ], the generated merged features will be input to the next module.
2. The method for motion recognition using frame clustering and self-attention time-shifting module according to claim 1, characterized in that: The frame clustering module uses a video segmentation algorithm based on the maximum entropy principle to segment the video. The optimization objective formula of the method is: Where: d is the distance metric used to measure the difference between two video segments; The overall structure of the algorithm is greedy. Its goal is to find the global optimal solution that maximizes the D value, and to continuously and greedily search for the segmentation points of the video segments to achieve the local optimal solution, so that the D value is the maximum value that can be achieved at present. (1) First, initialize and process the video frames to obtain N segmentation points as candidate segmentation points for dividing the video segments. Select the N adjacent frames with the largest differences as candidate segmentation points, binarize the frame activations, and calculate the Hamming distances of all adjacent frames. (2) Select the segmentation points between N frames according to the largest N Hamming distances, where N is usually one eighth of the total number of video frames n; (3) Find the current local optimal solution, consider N segmentation points in sequence, try to divide the video segment at each segmentation point, and calculate the D value after division, find the average of each segment, and then calculate the cosine similarity between different video segments as the D value. The calculation method is shown in the formula: After comparing and obtaining the partition point that maximizes the current D value, the algorithm finds the current local optimal solution, uses this partition point to split the video frame and records that the partition point has been used. Then the algorithm continues to look for the next local optimal solution, greedily selecting the partition point that maximizes the D value from the remaining N-1 partition points, and repeats T-1 times until all T-1 partition points are determined.
3. The method for motion recognition introducing frame clustering and self-attention time-shifting module according to claim 1, characterized in that: The frame clustering module aggregates the divided frame activations by averaging the frame activations of each segment, generating T activations for the video, expressed as the formula: F=[F1,F2,……F T ] Among them: F i represents the merged features of the i-th fragment; I j Indicates that it belongs to fragment f i The activation of video frame j; |f i | indicates the frame number of the clip; The above aggregated features will be input into the subsequent self-attention time shift network to further extract the overall action features of the video.
4. The method for motion recognition using frame clustering and self-attention time-shifting module according to claim 1, characterized in that: The local detail enhancement module obtains the division and merging features of each video segment from the frame aggregation module as input, and extracts detailed features of each segment, which is expressed as the formula: F’=[F’1,F’2,……F’ T ] F’ i =F i +H(I[I1,I2,I3,I4,I5]) Where: H represents the extraction of motion features of the clip, I represents the set of representative frames of the clip, and each video clip in the model uses five representative frames; The local detail enhancement module selects several sample frames, stacks their RGB differences, and uses CNN to extract the local detail features of the motion of the video clip. A uniform sampling strategy is designed. For a video clip of length m, the model uniformly selects five video frames and stacks their RGB differences along the channel direction, as shown in the formula: D=[f mid / 2 -f1,f mid -f mid / 2 ,f 3mid / 2 -f mid ,f m -f 3mid / 2 ] Where: f mid Indicates the middle frame of the clip; A lightweight CNN module is designed to process the stacked RGB differences. The module adopts a low-resolution processing strategy: first downsample it using average pooling, then use CNN to extract features and then upsample it to match the extraction of the spatial features of the fragment, expressed as a formula: H(p i )=Upsample(CNN(Downsample(D(p i )))) Where: D represents the i-th video segment p i The represents the RGB difference of the frame stack.
5. The method for motion recognition introducing frame clustering and self-attention time-shifting module according to claim 1, characterized in that: The self-attention time shift network linearly transforms part of the feature map of each frame in the TSM network and adds position encoding to obtain the time series X = x1, x2, ..., x T ; Then the model further performs a linear transformation on the obtained time series to obtain the query (Query), key (Key) and value (Value) of each element; Then the model calculates the attention score Attention, for each query q i , calculate its relationship with all keys k i The similarity score of , using the dot product attention method, refer to the formula: Next, the attention scores are converted into attention weights through the softmax function, and these weights are used to calculate the weighted sum of the value vectors to obtain the attention vector at the sequence position i. The calculation method refers to the formula: The multi-head self-attention mechanism applies the above process to multiple combinations of queries, keys, and values to obtain multiple different attention representations, and then connects and integrates the attention vectors of multiple heads to obtain the final output MultiHead; finally, it is time-shifted and spliced with the original feature map. The multi-head attention output will pass through a linear layer to adjust its shape back to the feature map.
Citation Information
Patent Citations
Video pedestrian re-identification algorithm and device based on multi-space-time attention model
CN110110601A
Video processing method and device, electronic equipment and storage medium
CN112464814A
Near-repetition infrared video cleaning system and method based on spatial-temporal characteristics
CN117992630A
Cited By
Violation video information identification method based on convolutional neural network model
CN122116485A
