TimeSform model-based confrontation result prediction method and system

By adopting the TimeSformer model in game confrontation, using global mobile data to capture timing and spatial dependencies, the problem of low prediction accuracy of traditional models is solved, and more accurate prediction of confrontation results is achieved.

CN119849591APending Publication Date: 2025-04-18INST OF WAR STUDIES ACAD OF MILITARY SCI OF THE CHINESE PEOPLES LIBERATION ARMY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411947569.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

Traditional recurrent neural network models such as RNN or LSTM have low prediction accuracy in the game confrontation prediction, making it difficult to accurately predict the outcome of the confrontation.

Method used

The adversarial result prediction method based on the TimeSformer model is adopted, and the adversarial result is predicted by obtaining global moving data in the adversarial scenario, preprocessing is performed to obtain the global feature sequence, and processing it with the pre-trained TimeSformer model to predict the adversarial result. The TimeSformer model includes a multi-layer TranSformer component and a classification head component to capture the timing and spatial dependencies of feature sequences through the time attention module, the spatial attention module and the feedforward neural network module.

Benefits of technology

It improves the accuracy of the victory and loss prediction of both sides of the confrontation, and can more effectively capture multi-scale timing and spatial dependencies, thereby providing more accurate prediction of confrontation results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119849591A_ABST
    Figure CN119849591A_ABST
Patent Text Reader

Abstract

The invention relates to a TimeSform model-based adversarial result prediction method and system, and relates to the field of data processing. The method comprises the following steps: acquiring global movement data of a target object with a confrontation relationship in a confrontation scene; preprocessing each piece of global mobile data, and respectively obtaining a global feature sequence of each target object; and processing each obtained global feature sequence by using a pre-trained TimeSform model, and predicting a confrontation result of the confrontation scene, the TimeSform model being obtained by training by using a global mobile data sample of a training sample with a confrontation relationship collected in a historical confrontation scene and the confrontation result. Therefore, the prediction accuracy of the confrontation result is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of data processing, and in particular relates to a method and system for predicting confrontation results based on a TimeSformer model. Background Art

[0002] In recent years, great breakthroughs have been made in the research on intelligent agent game confrontation. Artificial intelligence AI represented by AlphaGo and AlphaStar has defeated top professional players in human-machine competitions, providing a new research paradigm for the study of cognitive intelligence.

[0003] Game confrontation usually sets the two parties as Party A and Party B, and evaluates the advantages and disadvantages of both parties and the possibility of winning or losing by simulating the actions and decision-making processes of both parties. In the process of game confrontation, victory and defeat prediction plays an important role. By analyzing the historical confrontation data of Party A and Party B, the outcome of the game can be predicted in advance, thus providing support for tactical deduction.

[0004] Neural network models are an important technical support for predicting the outcome of a game between two parties. However, traditional recurrent neural network models such as RNN or LSTM have problems such as low prediction accuracy. Summary of the invention

[0005] In view of this, it is necessary to provide a confrontation result prediction method and system based on the TimeSformer model to address the above technical problems, so as to more accurately predict the outcome of the confrontation between the two parties.

[0006] A method for predicting adversarial results based on a TimeSformer model, the method comprising:

[0007] Obtain global movement data of target objects with adversarial relationships in adversarial scenarios;

[0008] Preprocess each global motion data to obtain the global feature sequence of each target object;

[0009] The pre-trained TimeSformer model is used to process the obtained global feature sequences to predict the confrontation results of the confrontation scenario. The TimeSformer model is trained using global mobile data samples and confrontation results of training samples with confrontation relationships collected in historical confrontation scenarios.

[0010] In one embodiment, the TimeSformer model includes a trained multi-layer TranSformer component and a classification head component; the intermediate feature sequence output by the Transformer component of the current layer is used as the input of the TranSformer component of the next layer;

[0011] Using the pre-trained TimeSformer model, the obtained global feature sequences are processed to predict the confrontation results of the confrontation scenario, including:

[0012] Input the global feature sequence of each target object into the TranSformer component of the first layer;

[0013] Get the final feature sequence output by the TranSformer component of the last layer;

[0014] The final feature sequence is input into the classification head component to obtain the adversarial result.

[0015] In one embodiment, the TranSformer component of each layer includes a temporal attention module, a spatial attention module, and a feedforward neural network module;

[0016] The processing of each layer of the TranSformer component is:

[0017] The temporal attention module is used to process the intermediate feature sequence output by the previous layer Transformer component, capture the temporal pattern of the intermediate feature sequence, and obtain a first feature sequence with a temporal dependency;

[0018] Using the spatial attention module to process the first feature sequence, capturing the spatial dependency of the first feature sequence, and obtaining a second feature sequence with spatial dependency;

[0019] The second feature sequence is processed by using the feedforward neural network module to obtain an intermediate feature sequence output by the TranSformer component of this layer.

[0020] In one embodiment, a temporal attention module is used to process an intermediate feature sequence output by a previous layer Transformer component, capture a temporal pattern of the intermediate feature sequence, and obtain a first feature sequence with a temporal dependency, including:

[0021] Using the intermediate feature sequence output by the previous layer Transformer component, the query, key, and value matrices in the time dimension are calculated according to the following formula:

[0022]

[0023] Among them, the Q t is the query matrix in the time dimension, the K t is the key matrix in the time dimension, the V t is the value matrix in the time dimension, are the weight matrices corresponding to the query matrix, key matrix, and value matrix in the time dimension, respectively. is the bias vector corresponding to each weight matrix; the z l is the intermediate feature sequence output by the Transformer component of layer l;

[0024] Based on the query, key and value matrix on the time dimension, the first feature sequence is obtained according to the following formula:

[0025]

[0026] Among them, TA(z l ) is the first characteristic sequence; is the dimension of each attention head; h is the number of attention heads; D is the spatial dimension.

[0027] In one embodiment, the spatial attention module is used to process the first feature sequence to capture the spatial dependency of the first feature sequence to obtain a second feature sequence with spatial dependency, including:

[0028] Using the first feature sequence, the query, key and value matrices in the spatial dimension are calculated according to the following formula:

[0029]

[0030] Among them, the Q s is the query matrix in the spatial dimension; the K s is the bond matrix in the spatial dimension; the V s is a matrix of values ​​in the spatial dimensions; are the weight matrices corresponding to the query matrix, key matrix, and value matrix in the spatial dimension; is the bias vector corresponding to each weight matrix;

[0031] Based on the query, key and value matrix in the spatial dimension, the second feature sequence is obtained according to the following formula:

[0032]

[0033] Among them, SA(TA(z l )) is the second characteristic sequence.

[0034] In one embodiment, the second feature sequence is processed by the feedforward neural network module to obtain an intermediate feature sequence output by the TranSformer component of the layer, including:

[0035] The second feature sequence is iterated according to the following formula to obtain a third feature sequence:

[0036]

[0037] Among them, Q f is the third characteristic sequence, is the weight matrix under the feedforward neural network module, is the bias vector corresponding to the weight matrix;

[0038] The third feature sequence is processed according to the following formula to obtain the intermediate feature sequence output by the TranSformer component of this layer:

[0039] FL(SA(TA(z l ))) = f l (Q f )

[0040] Among them, FL(SA(TA(z l ))) is the intermediate feature sequence activation function output by the TranSformer component of this layer; f l (·) is the activation function.

[0041] In one of the embodiments, the feedforward neural network module includes a two-layer fully connected neural network;

[0042] Inputting the final feature sequence into the classification head component to obtain the confrontation result includes:

[0043] The final feature sequence is subjected to nonlinear transformation processing according to the following formula to obtain the confrontation result:

[0044]

[0045] in, is the final feature sequence; W1 and W2 are the weight matrices of the two-layer fully connected neural network; b1 and b2 are the bias vectors corresponding to the weight matrices of the two-layer fully connected neural network respectively; represents the GELU activation function; σ(·) is the sigmoid activation function; y is the predicted probability of the target object.

[0046] In one embodiment, the training process of the TimeSformer model is:

[0047] Using the training samples in the training set to train the TimeSformer model;

[0048] During the training process, the loss function is used to measure the difference between the predicted adversarial result and the actual adversarial result; based on the difference, the parameters in the TimeSformer model are adjusted through the back propagation algorithm, and the step of training the TimeSformer model using the training samples in the training set is continued. When the training is completed, the trained TimeSformer model is obtained.

[0049] In one embodiment, using a loss function to measure the difference between the predicted adversarial result and the actual adversarial result includes:

[0050] The difference between the predicted adversarial result and the actual adversarial result is measured using the following cross entropy loss function:

[0051]

[0052] Where B is the size of the training batch; y i is the actual adversarial result of the i-th training sample; p i is the predicted adversarial result; Loss is the difference.

[0053] In a second aspect, a confrontation result prediction system based on a TimeSformer model is provided, the system comprising:

[0054] An acquisition module, used to acquire global movement data of target objects having adversarial relationships in adversarial scenarios;

[0055] A preprocessing module is used to preprocess each global motion data to obtain a global feature sequence of each target object;

[0056] The prediction module is used to use the pre-trained TimeSformer model to process the obtained global feature sequences and predict the confrontation results of the confrontation scenario. The TimeSformer model is trained using the global mobile data samples and confrontation results of the training samples with confrontation relationships collected in historical confrontation scenarios.

[0057] In the above-mentioned confrontation result prediction method and system based on the TimeSformer model, the global movement data of the target objects with confrontation relationship in the confrontation scene are obtained; each global movement data is preprocessed to obtain the global feature sequence of each target object respectively; and each global feature sequence obtained is processed using the pre-trained TimeSformer model to predict the confrontation result of the confrontation scene. Since the above-mentioned TimeSformer model is trained using the global movement data samples and confrontation results of the training samples with confrontation relationship collected in the historical confrontation scene, when the model is used to predict the confrontation result of the target object in the confrontation scene, the confrontation result can be accurately predicted. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 It is a flowchart of a method for predicting confrontation results based on a TimeSformer model in one embodiment;

[0059] Figure 2 is a schematic diagram of a MicroRTS platform map frame in one embodiment;

[0060] Figure 3 A schematic diagram of the structure of a single-layer Transformer component in one embodiment;

[0061] Figure 4 It is a structural schematic diagram of a confrontation result prediction system based on the TimeSformer model in one embodiment;

[0062] Figure 5 FIG. 4 is a diagram showing the internal structure of a computing device in one embodiment. DETAILED DESCRIPTION

[0063] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0064] In one embodiment, Figure 1 As shown, a method for predicting confrontation results based on the TimeSformer model is provided. The method is applied to an electronic device as an example for explanation. The electronic device may be, but is not limited to, a server or other device. The method may be applied to any of the above scenarios where confrontation exists, and may be, but is not limited to, game confrontation, etc. When the above electronic device implements the above method, the following steps may be included:

[0065] S11. Obtain global movement data of target objects having adversarial relationships in adversarial scenarios.

[0066] In this step, the target object may be an object in a confrontational relationship during the confrontation process. The embodiment does not limit the specific number of target objects included in the confrontation process. For example, if a confrontation scene includes party A and party B, the target object may be party A and party B.

[0067] Based on this, in order to predict the results of the confrontation, the global movement data of the target object with a confrontation relationship in the confrontation scene can be first obtained, so as to predict the results based on the obtained global movement data. Taking the target objects as party A and party B as an example, the global movement data of party A and party B in the confrontation scene can be obtained to predict the results of the confrontation based on the global movement data of both parties. It is worth noting that when obtaining the global movement data of the target object, the global movement data can be the movement data within the set confrontation round. The specific value of the set confrontation round is not limited in this embodiment.

[0068] In order to better understand this embodiment, the confrontation scenario simulated by the MicroRTS open source platform is taken as an example for explanation. The map frame size of the platform is 16*16. Both parties AB conduct confrontation within the map range. Figure 2 As shown. During the confrontation, the movement data of the entities of both parties A and B at each time step will be recorded according to the grid position of the map. In order to prevent the confrontation from falling into an infinite loop, a maximum limit of 1000 steps is set. After exceeding the limit, the party with more remaining entities wins. In this case, H = W = 16, C = 5, T ≤ 1000. Based on this, the global movement data of party A and party B are obtained in this simulated confrontation scenario.

[0069] Optionally, the global movement data may include, but are not limited to, entity type, current health value, owner, neutral resources, and resources of the party to which the target object belongs, as shown in Table 1. The neutral resources may include, but are not limited to, neutral resources such as food, metal minerals used by factories to manufacture light units and heavy units, and wood; the owner resources may include, but are not limited to, resources such as food, minerals, and wood that the party to which the target object belongs has collected and transported to the base.

[0070] Table 1

[0071]

[0072] S12, pre-processing each global motion data to obtain a global feature sequence of each target object.

[0073] In this step, in order to predict the adversarial results, after obtaining the global motion data of each target object, it is necessary to first process the global motion data to obtain data that can meet the input requirements of the TimeSformer model, that is, to obtain the global feature sequence of each target object mentioned above.

[0074] S13. Using the pre-trained TimeSformer model, the obtained global feature sequences are processed to predict the confrontation result of the confrontation scenario.

[0075] The TimeSformer model is trained by using global mobile data samples and adversarial results of training samples with adversarial relationships collected in historical adversarial scenarios.

[0076] In this step, after obtaining the global feature sequences of the above-mentioned target objects, they can be input into the trained TimeSformer model, which processes the global feature sequences and outputs the confrontation results of this time. Since the above-mentioned TimeSformer model is trained using the global mobile data samples and confrontation results of the training samples with confrontation relationships collected in the above-mentioned historical confrontation scenarios, the TimeSformer model can learn the correlation between the global mobile data samples and the confrontation results, so that when predicting the confrontation results, it can accurately predict the confrontation results based on the global mobile sequence corresponding to the global mobile data.

[0077] In the method for predicting confrontation results based on the TimeSformer model provided in this embodiment, the global motion data of the target objects with confrontation relationships in the confrontation scene are obtained; each global motion data is preprocessed to obtain the global feature sequence of each target object; and each global feature sequence obtained is processed using the pre-trained TimeSformer model to predict the confrontation result of the confrontation scene. Since the above-mentioned TimeSformer model is trained using the global motion data samples and confrontation results of the training samples with confrontation relationships collected in historical confrontation scenes, when the model is used to predict the confrontation results of the target objects in the above-mentioned confrontation scenes, the confrontation results can be accurately predicted.

[0078] Optionally, in this embodiment, the above-mentioned TimeSformer model includes trained multi-layer TranSformer components and classification head components; the intermediate feature sequence output by the Transformer component of the current layer is used as the input of the TranSformer component of the next layer; on this basis, step 13 can be performed according to the following process: input the global feature sequence of each target object into the TranSformer component of the first layer; obtain the final feature sequence output by the TranSformer component of the last layer; input the final feature sequence into the classification head component to obtain the adversarial result.

[0079] Furthermore, each layer of the Transformer component includes a temporal attention module, a spatial attention module, and a feedforward neural network module. Figure 3 As shown. The TranSformer component of each layer is used for feature extraction, and features directly related to the predicted adversarial results are obtained by extracting features layer by layer. On this basis, the processing process of the TranSformer component of each layer is as follows: the intermediate feature sequence output by the Transformer component of the previous layer is processed by the time attention module to capture the temporal pattern of the intermediate feature sequence, and obtain a first feature sequence with a time dependency; the first feature sequence is processed by the spatial attention module to capture the spatial dependency of the first feature sequence, and obtain a second feature sequence with a spatial dependency; the second feature sequence is processed by the feedforward neural network module to obtain the intermediate feature sequence output by the TranSformer component of this layer.

[0080] Specifically, the temporal attention module in the Transformer component of each layer is mainly used to capture the temporal pattern of the evolution of the adversarial process, that is, to capture the dynamic dependency between frames in the intermediate feature sequence corresponding to the layer. By applying the attention mechanism provided by the temporal attention module on the timeline, the Transformer model can understand the changes between different frames.

[0081] In view of this, the following process can be performed to process the intermediate feature sequence output by the previous layer Transformer component using the time attention module to capture the temporal pattern of the intermediate feature sequence and obtain the step of the first feature sequence with time dependency: using the intermediate feature sequence output by the previous layer Transformer component, the query, key and value matrices in the time dimension are calculated according to the following formula:

[0082]

[0083] Among them, the Q tis the query matrix in the time dimension, the K t is the key matrix in the time dimension, the V t is the value matrix in the time dimension, are the weight matrices corresponding to the query matrix, key matrix, and value matrix in the time dimension, respectively. is the bias vector corresponding to each weight matrix; the z l is the intermediate feature sequence output by the Transformer component of layer l;

[0084] Based on the query, key and value matrix in the time dimension, the first feature sequence can be calculated by a scaled dot product attention mechanism, that is, the first feature sequence is obtained according to the following formula:

[0085]

[0086] Among them, TA(z l ) is the first characteristic sequence; is the dimension of each attention head; h is the number of attention heads; D is the spatial dimension.

[0087] Specifically, the first feature sequence mentioned above can be understood as the temporal attention weight. During the calculation process, the input intermediate feature sequence is first reorganized into the form of [(B×N)×T×D], so that each spatial position can learn long-term dependencies across T time steps. This design enables the model to effectively capture multi-scale temporal patterns from tactical changes to strategic evolution.

[0088] In addition, the above-mentioned spatial attention module models the spatial dependency within each time step based on the temporal relationship modeling. This module calculates the query, key and value matrices in the spatial dimension based on the output of the temporal attention module. In view of this, the step of processing the first feature sequence using the spatial attention module to capture the spatial dependency of the first feature sequence and obtain the second feature sequence with spatial dependency can be performed according to the following process: Using the first feature sequence, the query, key and value matrices in the spatial dimension are calculated according to the following formula:

[0089]

[0090]

[0091]

[0092] Among them, the Q s is the query matrix in the spatial dimension; the K s is the bond matrix in the spatial dimension; the V sis a matrix of values ​​in the spatial dimensions; are the weight matrices corresponding to the query matrix, key matrix, and value matrix in the spatial dimension; is the bias vector corresponding to each weight matrix;

[0093] Based on the query, key and value matrices in the spatial dimension, the spatial attention weight is calculated by the scaled dot product attention mechanism, that is, the second feature sequence is obtained according to the following formula:

[0094]

[0095] Among them, SA(TA(z l )) is the second characteristic sequence.

[0096] Specifically, during the calculation process, the first feature sequence is first reorganized into the form of [(B×T)×N×D], so that the N spatial positions in each time step can be directly used for attention calculation. This multi-head design enables the model to capture spatial dependencies in different subspaces in parallel.

[0097] Furthermore, in this embodiment, the step of processing the second feature sequence using the feedforward neural network module to obtain the intermediate feature sequence output by the TranSformer component of the layer can be performed according to the following process: the second feature sequence is iteratively processed according to the following formula to obtain a third feature sequence:

[0098]

[0099] Among them, Q f is the third characteristic sequence, is the weight matrix under the feedforward neural network module, is the bias vector corresponding to the weight matrix;

[0100] The third feature sequence is processed according to the following formula to obtain the intermediate feature sequence output by the TranSformer component of this layer:

[0101] FL(SA(TA(z l ))) = f l (Q f )

[0102] Among them, FL(SA(TA(z l ))) is the intermediate feature sequence activation function output by the TranSformer component of this layer; f l (·) is the activation function.

[0103] To achieve deep feature extraction, the calculation process of each layer of TranSformer components can be expressed as:

[0104] z l+1 =LN(FL(SA(TA(z l )+z l )))

[0105] Specifically, the output z of the lth layer l+1 ∈R B×(T×N+1)×D It inherits all the feature information from the l-1 layer and superimposes new feature representations on this basis. In this way, the TimeSformer model can pay attention to both spatial dimension information and temporal dimension information at the same time, thereby improving the accuracy of winning and losing predictions. That is, by combining the output of the last layer of TranSformer components with the classification head component, the adversarial results can be accurately obtained.

[0106] Optionally, the feedforward neural network module comprises a two-layer fully connected neural network;

[0107] Inputting the final feature sequence into the classification head component to obtain the confrontation result includes:

[0108] The final feature sequence is subjected to nonlinear transformation processing according to the following formula to obtain the confrontation result:

[0109]

[0110] in, is the final feature sequence; W1 and W2 are the weight matrices of the two-layer fully connected neural network; b1 and b2 are the bias vectors corresponding to the weight matrices of the two-layer fully connected neural network respectively; represents the GELU activation function; σ(·) is the sigmoid activation function; y is the predicted probability of the target object.

[0111] Specifically, after completing the extraction of all L-layer features, the TimeSformer model passes the aggregated final feature sequence that directly affects the prediction of the confrontation result to the classification head component, which performs the final classification and realizes the final win-loss prediction by performing nonlinear transformation on the special tag vector. The above design uses the TimeSformer model to compress complex multi-dimensional feature information into a single prediction probability.

[0112] In addition, in order to avoid overfitting and improve the generalization ability of the TimeSformer model, the TimeSformer model applies a random inactivation dropout layer between the spatial attention module and the feedforward neural network module. The dropout layer is used to randomly discard neurons to prevent overfitting of the model.

[0113] Optionally, the training process of the above-mentioned TimeSformer model is as follows: the TimeSformer model is trained using the training samples in the training set; during the training process, the difference between the predicted adversarial result and the actual adversarial result is measured using the loss function; based on the difference, the parameters in the TimeSformer model are adjusted through the back propagation algorithm, and the step of training the TimeSformer model using the training samples in the training set is continued. When the training is completed, a trained TimeSformer model is obtained.

[0114] It should be noted that when the training samples are input into the above-mentioned TimeSformer model, the processing process of the training samples by the TimeSformer model is the same as the process of the above-mentioned TimeSformer model predicting the adversarial results of the input global feature sequence. The sample sequence of the training samples must also be input into the first-layer TimeSformer component in the TimeSformer model. The processing process of the input sequence by the TimeSformer component of each layer is similar to the corresponding processing process in the above-mentioned prediction process, and will not be described in detail here.

[0115] Specifically, the training of the TimeSformer model is an iterative process, in which the training set is input into the TimeSformer model, and the parameters of the TimeSformer model are continuously adjusted through the back-propagation algorithm. During the training process, the value of the loss function can be monitored to evaluate the performance of the TimeSformer model until the performance of the TimeSformer model is no longer significantly improved. Based on this, the step of using the loss function to measure the difference between the predicted adversarial result and the actual adversarial result can be performed according to the following process: The difference between the predicted adversarial result and the actual adversarial result is measured according to the following cross entropy loss function:

[0116]

[0117] Where B is the size of the training batch; y i is the actual adversarial result of the i-th training sample; p i is the predicted adversarial result; Loss is the difference.

[0118] Optionally, the method for obtaining the training set is described by taking a game confrontation platform (such as MicroRTS) to conduct several rounds of confrontation between two parties A and B as an example, and each round of confrontation is carried out step by step until the winner is determined. The global movement data of all forces of both parties A and B during the confrontation process, as well as the victory and defeat data of the confrontation between the two parties A and B, are collected and used as the data set for predicting the victory and defeat of the confrontation between the two parties A and B (X i ,y i ), i = 1, 2, ..., K, K is the total number of rounds in the competition. i ∈R T×C×H×W , H and W represent the height and width of the map space dimension in the game confrontation platform, respectively, C represents the number of multi-channel feature planes, and T represents the number of discrete time steps.

[0119] The dataset consisting of K rounds of collected data is divided into training set, validation set and test set according to a certain ratio. The training set is used to train the parameters and weights of the TimeSformer model, and contains a large number of training samples. The model learns features and patterns through the training set; the validation set is used to adjust the hyperparameters of the model, such as learning rate, regularization parameters, etc., to improve the generalization performance of the model; the test set is used to evaluate the performance of the model and check the generalization ability of the model for unseen data. The samples in the test set are required not to be used in the entire training and validation process. The commonly used division method is to use most of the data set for training, a small part for validation, and another small part for the final test.

[0120] In order to better perform model prediction processing, the training samples in the training set can be preprocessed first. The general process is as follows: the global mobile data samples of several training samples in the training set and the sample sequence consisting of the adversarial results are combined together as the input of the TimeSformer model, which belongs to the five-dimensional real tensor space X∈R B×T×C×H×W . Where B represents the batch size. Each time the model is trained, B samples are taken from the training set for training. Therefore, these B samples are combined together to form a sample sequence as the input of the model. This multi-channel feature design constructs a complete representation space for the game confrontation situation.

[0121] In order to improve computational efficiency and capture local spatial patterns, the input sample sequence is processed frame by frame and divided into N non-overlapping blocks using a sliding window method. Each block is mapped to a D-dimensional embedding space through a learnable linear transformation matrix E, and position encoding is introduced to preserve spatial and temporal information. The process is expressed as:

[0122]

[0123] In this expression, is the initial feature representation corresponding to position p and time step t, Exp,t is the learnable matrix E∈R D×(C×K) For the input block x p,t ∈R C×K The feature embedding obtained by linear transformation is is a learnable position embedding vector that encodes the spatiotemporal position information in the input sequence. Where p∈{1,2,…,N} represents the spatial position index and t∈{1,2,…,T} represents the time step index. In particular, a special marker vector is inserted at the beginning of the sequence. This tag will aggregate the sequence information for prediction in the final layer of the network. Through this preprocessing method, the original input is converted into a feature sequence with a shape of [B, (T×N+1), D].

[0124] It should be noted that the above-mentioned TimeSformer model, as a variant of Transformer, introduces a temporal self-attention mechanism, which is particularly suitable for processing time series data and can effectively capture temporal dependencies, especially when processing complex dynamic data. By modeling the time dimension, TimeSformer can more accurately analyze historical battle data, thereby providing higher accuracy and reliability in predicting wins and losses. The application of this model can not only improve the efficiency of tactical analysis, but also provide strong data support for real-time decision-making.

[0125] In summary, by providing the above-mentioned TimeSformer model training method, a comprehensive analysis of the forces, equipment, tactics and other factors of the two opposing parties involved in the confrontation can be conducted. By combining historical data and war experience, a more realistic and complex confrontation simulation environment can be constructed through computer programming and simulation technology, so as to more accurately predict the outcome of the confrontation scenario. This prediction technology can provide an important reference for decision-making in confrontation scenarios and help commanders formulate more reasonable confrontation plans and strategic deployments.

[0126] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0127] Based on the same technical concept, Figure 4 As shown in the structural schematic diagram, the present application also provides a confrontation result prediction based on the TimeSformer model, the system comprising:

[0128] An acquisition module 41 is used to acquire global movement data of target objects having an adversarial relationship in an adversarial scenario;

[0129] A preprocessing module 42 is used to preprocess each global motion data to obtain a global feature sequence of each target object;

[0130] The prediction module 43 is used to use the pre-trained TimeSformer model to process the obtained global feature sequences and predict the confrontation results of the confrontation scenario. The TimeSformer model is trained using the global mobile data samples and confrontation results of the training samples with confrontation relationships collected in historical confrontation scenarios.

[0131] Optionally, the above-mentioned TimeSformer model includes trained multi-layer TranSformer components and classification head components; the intermediate feature sequence output by the Transformer component of the current layer is used as the input of the TranSformer component of the next layer; on this basis, the above-mentioned prediction module 43 is specifically used to input the global feature sequence of each target object into the TranSformer component of the first layer; obtain the final feature sequence output by the TranSformer component of the last layer; input the final feature sequence into the classification head component to obtain the adversarial result.

[0132] Furthermore, the TranSformer component of each layer includes a temporal attention module, a spatial attention module and a feedforward neural network module; on this basis, the prediction module 43 is specifically used to execute the processing steps of the TranSformer component of each layer according to the following process:

[0133] The temporal attention module is used to process the intermediate feature sequence output by the previous layer Transformer component, capture the temporal pattern of the intermediate feature sequence, and obtain a first feature sequence with a temporal dependency;

[0134] Using the spatial attention module to process the first feature sequence, capturing the spatial dependency of the first feature sequence, and obtaining a second feature sequence with spatial dependency;

[0135] The second feature sequence is processed by using the feedforward neural network module to obtain an intermediate feature sequence output by the TranSformer component of this layer.

[0136] Optionally, the prediction module 43 is specifically used for:

[0137] Using the intermediate feature sequence output by the previous layer Transformer component, the query, key, and value matrices in the time dimension are calculated according to the following formula:

[0138]

[0139] Among them, the Q t is the query matrix in the time dimension, the K t is the key matrix in the time dimension, the V t is the value matrix in the time dimension, are the weight matrices corresponding to the query matrix, key matrix, and value matrix in the time dimension, respectively. is the bias vector corresponding to each weight matrix; the z l is the intermediate feature sequence output by the Transformer component of layer l;

[0140] Based on the query, key and value matrix on the time dimension, the first feature sequence is obtained according to the following formula:

[0141]

[0142] Among them, TA(z l ) is the first characteristic sequence; is the dimension of each attention head; h is the number of attention heads; D is the spatial dimension.

[0143] Optionally, the prediction module 43 is specifically used for:

[0144] Using the first feature sequence, the query, key and value matrices in the spatial dimension are calculated according to the following formula:

[0145]

[0146]

[0147]

[0148] Among them, the Q s is the query matrix in the spatial dimension; the K s is the bond matrix in the spatial dimension; the V s is a matrix of values ​​in the spatial dimensions; are the weight matrices corresponding to the query matrix, key matrix, and value matrix in the spatial dimension; is the bias vector corresponding to each weight matrix;

[0149] Based on the query, key and value matrix in the spatial dimension, the second feature sequence is obtained according to the following formula:

[0150]

[0151] Among them, SA(TA(z l )) is the second characteristic sequence.

[0152] Optionally, the prediction module 43 is specifically used for:

[0153] The second feature sequence is iterated according to the following formula to obtain a third feature sequence:

[0154]

[0155] Among them, Q f is the third characteristic sequence, is the weight matrix under the feedforward neural network module, is the bias vector corresponding to the weight matrix;

[0156] The third feature sequence is processed according to the following formula to obtain the intermediate feature sequence output by the TranSformer component of this layer:

[0157] FL(SA(TA(z l ))) = f l (Q f )

[0158] Among them, FL(SA(TA(z l ))) is the intermediate feature sequence activation function output by the TranSformer component of this layer; f l (·) is the activation function.

[0159] Optionally, the feedforward neural network module includes a two-layer fully connected neural network; on this basis, the prediction module 43 is specifically used to: perform nonlinear transformation processing on the final feature sequence according to the following formula to obtain the adversarial result:

[0160]

[0161] in, is the final feature sequence; W1 and W2 are the weight matrices of the two-layer fully connected neural network; b1 and b2 are the bias vectors corresponding to the weight matrices of the two-layer fully connected neural network respectively; represents the GELU activation function; σ(·) is the sigmoid activation function; y is the predicted probability of the target object.

[0162] Optionally, the device provided in this embodiment may further include:

[0163] A training module (not shown in the figure) is used to train the TimeSformer model using the training samples in the training set; during the training process, the difference between the predicted adversarial result and the actual adversarial result is measured using the loss function; based on the difference, the parameters in the TimeSformer model are adjusted through the back propagation algorithm, and the step of training the TimeSformer model using the training samples in the training set is continued. When the training is completed, a trained TimeSformer model is obtained.

[0164] Furthermore, the above training module is specifically used to measure the difference between the predicted adversarial result and the actual adversarial result according to the following cross entropy loss function:

[0165]

[0166] Where B is the size of the training batch; y i is the actual adversarial result of the i-th training sample; p i is the predicted adversarial result; Loss is the difference.

[0167] In one embodiment, a computing device is provided. The computing device may be a server, and its internal structure diagram may be as follows: Figure 5 As shown. The computing device includes a processor, a memory, a network interface and a database connected through a system bus. Among them, the processor of the computing device is used to provide computing and control capabilities. The memory of the computing device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computing device is used to store data. The network interface of the computing device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a confrontation result prediction based on the TimeSformer model is implemented.

[0168] In one embodiment, a computing device is provided. The computing device may be a terminal or a server. The internal structure diagram thereof may be as follows: Figure 5As shown. The computing device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computing device is used to provide computing and control capabilities. The memory of the computing device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computing device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method and device for scene situation assembly with adaptive demand is implemented. The display screen of the computing device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computing device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the housing of the computing device, or an external keyboard, touchpad or mouse, etc.

[0169] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present application, and does not constitute a limitation on the computing device to which the scheme of the present application is applied. The specific computing device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0170] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in any of the above embodiments are implemented.

[0171] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0172] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0173] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A method for predicting adversarial results based on the TimeSformer model, characterized in that: The method comprises: Obtain global movement data of target objects with adversarial relationships in adversarial scenarios; Preprocess each global motion data to obtain the global feature sequence of each target object; The pre-trained TimeSformer model is used to process the obtained global feature sequences to predict the confrontation results of the confrontation scenario. The TimeSformer model is trained using global mobile data samples and confrontation results of training samples with confrontation relationships collected in historical confrontation scenarios.

2. The method according to claim 1, characterized in that The TimeSformer model includes a trained multi-layer TranSformer component and a classification head component; the intermediate feature sequence output by the Transformer component of the current layer is used as the input of the TranSformer component of the next layer; Using the pre-trained TimeSformer model, the obtained global feature sequences are processed to predict the confrontation results of the confrontation scenario, including: Input the global feature sequence of each target object into the TranSformer component of the first layer; Get the final feature sequence output by the TranSformer component of the last layer; The final feature sequence is input into the classification head component to obtain the adversarial result.

3. The method according to claim 2, characterized in that The TranSformer components of each layer include a temporal attention module, a spatial attention module, and a feedforward neural network module; The processing of each layer of the TranSformer component is: The temporal attention module is used to process the intermediate feature sequence output by the previous layer Transformer component, capture the temporal pattern of the intermediate feature sequence, and obtain a first feature sequence with a temporal dependency; Using the spatial attention module to process the first feature sequence, capturing the spatial dependency of the first feature sequence, and obtaining a second feature sequence with spatial dependency; The second feature sequence is processed by the feedforward neural network module to obtain an intermediate feature sequence output by the TranSformer component of this layer.

4. The method according to claim 3, characterized in that The temporal attention module is used to process the intermediate feature sequence output by the previous layer Transformer component, capture the temporal pattern of the intermediate feature sequence, and obtain a first feature sequence with a temporal dependency, including: Using the intermediate feature sequence output by the previous layer Transformer component, the query, key, and value matrices in the time dimension are calculated according to the following formula: Among them, the Q t is the query matrix in the time dimension, the K t is the key matrix in the time dimension, the V t is the value matrix in the time dimension, are the weight matrices corresponding to the query matrix, key matrix, and value matrix in the time dimension, respectively. is the bias vector corresponding to each weight matrix; the z l is the intermediate feature sequence output by the Transformer component of layer l; Based on the query, key and value matrix on the time dimension, the first feature sequence is obtained according to the following formula: Among them, TA(z l ) is the first characteristic sequence; is the dimension of each attention head; h is the number of attention heads; D is the spatial dimension.

5. The method according to claim 4, characterized in that The first feature sequence is processed by the spatial attention module to capture the spatial dependency of the first feature sequence to obtain a second feature sequence with spatial dependency, including: Using the first feature sequence, the query, key and value matrices in the spatial dimension are calculated according to the following formula: Among them, the Q s is the query matrix in the spatial dimension; the K s is the bond matrix in the spatial dimension; the V s is a matrix of values ​​in the spatial dimensions; are the weight matrices corresponding to the query matrix, key matrix, and value matrix in the spatial dimension; is the bias vector corresponding to each weight matrix; Based on the query, key and value matrix in the spatial dimension, the second feature sequence is obtained according to the following formula: Among them, SA(TA(z l )) is the second characteristic sequence.

6. The method according to claim 5, characterized in that The second feature sequence is processed by the feedforward neural network module to obtain an intermediate feature sequence output by the TranSformer component of the layer, including: The second feature sequence is iterated according to the following formula to obtain a third feature sequence: Among them, Q f is the third characteristic sequence, is the weight matrix under the feedforward neural network module, is the bias vector corresponding to the weight matrix; The third feature sequence is processed according to the following formula to obtain the intermediate feature sequence output by the TranSformer component of this layer: FL(SA(TA(z l )))=f l (Q f ) Among them, FL(SA(TA(z l ))) is the intermediate feature sequence activation function output by the TranSformer component of this layer; f l (·) is the activation function.

7. The method according to claim 2, characterized in that The feedforward neural network module includes a two-layer fully connected neural network; Inputting the final feature sequence into the classification head component to obtain the confrontation result includes: The final feature sequence is subjected to nonlinear transformation processing according to the following formula to obtain the confrontation result: in, is the final feature sequence; W1 and W2 are the weight matrices of the two-layer fully connected neural network; b1 and b2 are the bias vectors corresponding to the weight matrices of the two-layer fully connected neural network respectively; represents the GELU activation function; σ(·) is the sigmoid activation function; y is the predicted probability of the target object.

8. The method according to claim 1, characterized in that The training process of the TimeSformer model is: Using the training samples in the training set to train the TimeSformer model; During the training process, the loss function is used to measure the difference between the predicted adversarial result and the actual adversarial result; based on the difference, the parameters in the TimeSformer model are adjusted through the back propagation algorithm, and the step of training the TimeSformer model using the training samples in the training set is continued. When the training is completed, the trained TimeSformer model is obtained.

9. The method according to claim 8, characterized in that The loss function is used to measure the difference between the predicted adversarial results and the actual adversarial results, including: The difference between the predicted adversarial result and the actual adversarial result is measured using the following cross entropy loss function: Where B is the size of the training batch; y i is the actual adversarial result of the i-th training sample; p i is the predicted adversarial result; Loss is the difference.

10. A confrontation result prediction system based on the TimeSformer model, characterized in that: include: An acquisition module, used to acquire global movement data of target objects having adversarial relationships in adversarial scenarios; A preprocessing module is used to preprocess each global motion data to obtain a global feature sequence of each target object; The prediction module is used to use the pre-trained TimeSformer model to process the obtained global feature sequences and predict the confrontation results of the confrontation scenario. The TimeSformer model is trained using the global mobile data samples and confrontation results of the training samples with confrontation relationships collected in historical confrontation scenarios.