Molecular dynamics simulation acceleration method, electronic device and storage medium
By using the Transformer model instead of the RNN model and combining it with the autoencoder for dimensionality reduction and self-attention mechanism, the problem of long computation time in biomolecular dynamics simulation is solved, and more efficient molecular dynamics simulation is achieved.
Patent Information
- Application Number
- CN202310976931.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-03
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2043-08-03
AI Technical Summary
Biomolecular dynamics simulations in the biological field take too long to compute. Existing RNN models have poor parallel efficiency during training, suffer from gradient diffusion and gradient explosion problems, and are unable to capture long-term series dependencies, resulting in slow inference speed.
The Transformer model is used instead of the RNN model, dimensionality reduction is performed through the autoencoder, and the self-attention mechanism is used to capture the dependency between any two moments, thus realizing the parallel calculation of the molecular temporal hidden vector.
It improves the computational efficiency and inference speed of molecular dynamics simulation, shortens the simulation time, and improves the training and inference efficiency of the model.
Smart Images

Figure CN117116368B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of bioinformatics, and in particular to a molecular dynamics simulation acceleration method, electronic equipment, and storage medium. Background Art
[0002] Molecular dynamics simulation is a computer simulation technique based on Newtonian mechanics that studies the interactions and motions between atoms or molecules in matter. It is widely used in fields such as materials science and life sciences, helping scientists better understand intermolecular interactions, predict the properties and behavior of substances, and provide guidance for the design of new materials and drugs. However, in the biological field, the large number of atoms in biomolecules and the complex interactions between atoms make the simulation process computationally intensive. Furthermore, because the microscopic biological phenomena required to be simulated in the biological field, such as protein folding, often occur on timescales of microseconds and milliseconds, biomolecular dynamics simulations often require significant computational time, and may even be impossible to complete within a reasonable timeframe using available computing resources.
[0003] To accelerate the computational speed of biomolecular dynamics simulations, scholars have combined deep learning technology to develop two major methods: enhanced sampling and molecular trajectory generation. Vlachas et al. proposed a molecular trajectory generation method that uses an autoencoder (AE) to learn the representation of molecular structure and a recurrent neural network (RNN) to directly model the dynamic changes of molecules, ignoring the force and velocity calculations in traditional dynamics simulations. The method ultimately achieves a computational speed three orders of magnitude higher than traditional dynamics simulations. However, the work of Vlachas et al. all used the RNN model to model the dynamic changes of molecular conformations. Since the RNN training and inference processes are iterative, the RNN model makes predictions at the current moment based on the calculation results of the previous moment during training, resulting in poor parallel efficiency. In addition, the RNN model also has problems such as gradient diffusion and gradient explosion, and is unable to capture long-term series dependencies. This limits the efficiency of model training and inference, reducing the inference speed of this type of method in practical applications. Summary of the Invention
[0004] This application aims to solve at least one of the technical problems existing in the prior art. To this end, this application proposes a molecular dynamics simulation acceleration method, electronic device, and storage medium that can use the Transformer model instead of the RNN model to model the dynamic process of molecular temporal hidden vectors, thereby improving the model's inference speed.
[0005] In a first aspect, the present application provides a molecular dynamics simulation acceleration method, comprising:
[0006] Obtain target motion trajectory information of target molecules based on force field;
[0007] Generate target internal coordinates corresponding to the atomic positions in each frame based on the target motion trajectory information; wherein the target internal coordinates are used to characterize the dependency relationship between each atom;
[0008] Inputting the target internal coordinates into the preset autoencoder for dimensionality reduction processing to obtain the target hidden vector;
[0009] The target hidden vector set is input into a preset timing model to obtain the molecular dynamic change process; wherein the timing model is a Transformer model.
[0010] According to the molecular dynamics simulation acceleration method of the first embodiment of the present application, there are at least the following beneficial effects: obtaining target motion trajectory information of the target molecule based on the force field, and generating target internal coordinates corresponding to the atomic positions in each frame based on the target motion trajectory information. The target internal coordinates are used to characterize the dependencies between each atom. The target internal coordinates are then input into a preset autoencoder for dimensionality reduction to obtain a target hidden vector. The target hidden vector set is then input into a preset time series model to obtain the dynamic change process of the molecule; wherein the time series model is a Transformer model. In this application, the Transformer model is used instead of the RNN model as the time series model to model the dynamic process of the molecular time series hidden vector. Because the RNN model predicts the current moment based on the calculation results of the previous moment during training, the parallel efficiency is low. In addition, the RNN model also suffers from problems such as gradient diffusion and gradient explosion, and cannot capture long-term dependencies. The Transformer model, on the other hand, uses a self-attention mechanism to capture the dependencies between any two moments, without the need for sequential processing like traditional RNNs. This mechanism makes the calculations at each position independent of each other, so the calculations at all positions can be performed in parallel, greatly improving computational efficiency. Therefore, adopting the Transformer structure can greatly speed up training efficiency.
[0011] According to some embodiments of the first aspect of the present application, the timing model is trained by the following steps: obtaining the training motion trajectory information of the training molecule based on the force field; generating a training internal coordinate set corresponding to the atomic position in each frame based on the training motion trajectory information; dividing the training internal coordinate set into several first training samples, and inputting them into the preset autoencoder, and encoding the first training samples through the autoencoder to obtain a training hidden vector set corresponding to each first training sample; dividing the training hidden vector set into a test vector set and an expected vector set, and inputting the test vector set into the timing model in the initial state to obtain a predicted vector set; optimizing the parameters of the timing model based on the expected vector set and the predicted vector set.
[0012] According to some embodiments of the first aspect of the present application, generating a training internal coordinate set corresponding to the atomic position in each frame based on the training motion trajectory information includes: obtaining the Cartesian coordinates corresponding to all atoms in each frame of molecules based on the training motion trajectory information; determining the bond length between two atoms, the bond angle between three atoms, and the dihedral angle between four of the atoms based on the Cartesian coordinates corresponding to each atom; and generating a training internal coordinate set corresponding to all atoms in each frame of molecules based on the bond length, the bond angle, and the dihedral angle.
[0013] According to some embodiments of the first aspect of the present application, the training hidden vector set is divided into a test vector set and an expected vector set, and the test vector set is input into the timing model in the initial state to obtain a prediction vector set, including: segmenting the training hidden vector set according to a preset division rule, using the hidden vectors of the front part of the training hidden vector set as the test vector set, and the hidden vectors of the back part as the expected vector set; adding a placeholder vector to the test vector set according to the expected vector set to form an input vector set; and inputting the input vector set into the timing model in the initial state to obtain a prediction vector set.
[0014] According to some embodiments of the first aspect of the present application, optimizing the parameters of the timing model based on the expected vector set and the predicted vector set includes: calculating a first loss value between the expected vector set and the predicted vector set; and optimizing the parameters of the timing model based on the first loss value.
[0015] According to some embodiments of the first aspect of the present application, after the step of optimizing the parameters of the timing model according to the first loss value, it also includes: re-dividing the training hidden vector set into a test vector set and an expected vector set, and executing subsequent steps to iteratively train the optimized timing model until the first loss value or the number of iterations meets the preset convergence conditions, thereby obtaining a trained timing model.
[0016] According to some embodiments of the first aspect of the present application, before the step of dividing the training internal coordinate set into several first training samples, inputting them into the preset autoencoder, and encoding the first training samples through the autoencoder to obtain a training hidden vector set corresponding to each first training sample, the autoencoder is also included in the following steps: taking the training internal coordinate set corresponding to a frame of atomic positions as a second training sample, and inputting it into the autoencoder in the initial state for forward calculation to obtain a reconstructed position; calculating a second loss value between the second training sample and the reconstructed position; and optimizing the parameters of the autoencoder according to the second loss value.
[0017] According to some embodiments of the first aspect of the present application, after the step of optimizing the parameters of the autoencoder according to the second loss value, it also includes: re-inputting a number of the second training samples into the optimized autoencoder to iteratively train the optimized autoencoder until the second loss value or the number of iterations meets the preset convergence condition, thereby obtaining a trained autoencoder.
[0018] According to some embodiments of the first aspect of the present application, after the step of optimizing the parameters of the timing model according to the expected vector set and the predicted vector set, it also includes: inputting the first training sample into the trained autoencoder again for forward calculation and encoding processing to obtain a reconstructed position set of several frame atomic positions and a training hidden vector set corresponding to each of the first training samples; dividing the training hidden vector set into a test vector set and an expected vector set, and inputting the test vector set into the trained timing model to obtain a predicted vector set; calculating a third loss value between the first training sample and the reconstructed position set; calculating a fourth loss value between the expected vector set and the predicted vector set; calculating a comprehensive loss value based on the third loss value and the fourth loss value; and optimizing the autoencoder and the timing model again based on the comprehensive loss value.
[0019] According to some embodiments of the first aspect of the present application, after the step of re-optimizing the autoencoder and the timing model according to the third loss value and the fourth loss value, it also includes: re-inputting several of the first training samples into the optimized autoencoder, and re-dividing the training hidden vector set into a test vector set and an expected vector set, and executing subsequent steps to iteratively train the optimized autoencoder and the optimized timing model again until the comprehensive loss value or the number of iterations meets the preset convergence conditions, thereby obtaining the trained autoencoder and timing model.
[0020] In a second aspect, the present application provides an electronic device comprising: at least one memory; at least one processor; at least one program; the program is stored in the memory, and the processor executes at least one program to implement the molecular dynamics simulation acceleration method described in any embodiment of the first aspect.
[0021] In a third aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer-executable signal, and the computer-executable signal is used to execute the molecular dynamics simulation acceleration method as described in any embodiment of the first aspect.
[0022] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become obvious from the description below, or will be learned through practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Additional aspects and advantages of the present application will become apparent and readily understood from the following description of the embodiments with reference to the accompanying drawings, in which:
[0024] Figure 1 is a flow chart of a molecular dynamics simulation acceleration method provided by one embodiment of the present application;
[0025] Figure 2 is a flow chart of a molecular dynamics simulation acceleration method provided by another embodiment of the present application;
[0026] Figure 3 is a flow chart of a molecular dynamics simulation acceleration method provided by another embodiment of the present application;
[0027] Figure 4 is a flow chart of a molecular dynamics simulation acceleration method provided by another embodiment of the present application;
[0028] Figure 5 is a flow chart of a molecular dynamics simulation acceleration method provided by another embodiment of the present application;
[0029] Figure 6 is a flow chart of a molecular dynamics simulation acceleration method provided by another embodiment of the present application;
[0030] Figure 7 is a flow chart of a molecular dynamics simulation acceleration method provided by another embodiment of the present application;
[0031] Figure 8 is a flow chart of a molecular dynamics simulation acceleration method provided by another embodiment of the present application;
[0032] Figure 9 is a flow chart of a molecular dynamics simulation acceleration method provided by another embodiment of the present application;
[0033] Figure 10 is a flow chart of a molecular dynamics simulation acceleration method provided by another embodiment of the present application;
[0034] Figure 11 is a schematic diagram of atomic distribution positions provided by one embodiment of the present application;
[0035] Figure 12 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0036] The following describes in detail embodiments of the present application. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application and are not to be construed as limiting the present application.
[0037] In the description of this application, it should be understood that descriptions involving orientations, such as up, down, front, back, left, right, etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings. They are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, they cannot be understood as limitations on this application.
[0038] In the description of this application, if there is a description of first or second, it is only for the purpose of distinguishing technical features, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features or implicitly indicating the order of the indicated technical features.
[0039] In the description of this application, unless otherwise clearly defined, terms such as setting, installing, and connecting should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in this application based on the specific content of the technical solution.
[0040] First, let’s analyze some of the terms used in this application:
[0041] Transformer model: The Transformer model is a neural network that learns context and therefore meaning by tracking relationships in sequence data (such as the words in this sentence). The Transformer model applies a set of evolving mathematical techniques called attention or self-attention to detect subtle ways in which even distant data elements in a series influence and depend on each other. The emergence of the Transformer model solves the problems of recurrent neural networks in the field of natural language processing that cannot be trained in parallel and have high computational complexity. Compared with recurrent neural networks, the training time and training cost of Transformer are greatly reduced.
[0042] Informer model: The Informer model is a variant of the Transformer model. Its main work is to use Transformer to achieve long sequence prediction. When inferring, Informer uses a time sequence as the input of the decoder, which is equivalent to the start symbol in the natural language processing scenario. <start>The result of a single forward computation is used as the final prediction result, with a time complexity of O(1). Compared with the dynamic decoding of Transformer in natural language processing scenarios, the time complexity is O(L), where L is the target sequence length. This variant is mainly proposed to solve the problem of slow reasoning efficiency of Transformer when predicting long sequences.
[0043] An autoencoder (AE) is a type of artificial neural network (ANN) used in semi-supervised and unsupervised learning. Its function is to learn representations of input information by using that information as a learning target. An autoencoder consists of two parts: an encoder and a decoder. Based on their learning paradigm, autoencoders can be categorized as contractive autoencoders, regularized autoencoders, and variational autoencoders (VAEs). The former two are discriminative models, while the latter is a generative model. Based on their architecture, autoencoders can be either feedforward or recursive neural networks. Autoencoders have the general functionality of representation learning algorithms and are used for dimensionality reduction and anomaly detection. Autoencoders constructed with convolutional layers can be applied to computer vision problems, including image denoising and neural style transfer.
[0044] Currently, molecular dynamics simulation is a computer simulation technology based on Newtonian mechanics that studies the interactions and motions between atoms or molecules in matter. It is widely used in fields such as materials science and life sciences, helping scientists better understand intermolecular interactions, predict the properties and behavior of substances, and provide guidance for the design of new materials and drugs. However, in the biological field, due to the large number of atoms in biomolecules and the complex interactions between atoms, the simulation process involves a large amount of computation. In addition, because the microscopic biological phenomena that need to be simulated in the biological field, such as protein folding, often occur on time scales of microseconds and milliseconds, biomolecular dynamics simulations often require a long time to calculate, and may even be impossible to complete within a reasonable time using existing computing resources.
[0045] To accelerate the computational speed of biomolecular dynamics simulations, scholars have combined deep learning technology to develop two major methods: enhanced sampling and molecular trajectory generation. Vlachas et al. proposed a method for molecular trajectory generation, using an autoencoder (AE) to learn the representation of molecular structure and a recurrent neural network (RNN) to directly model the dynamic changes of molecules, ignoring the force and velocity calculations in traditional dynamics simulations. Ultimately, this method achieved a computational speed three orders of magnitude higher than traditional dynamics simulations. However, the work of Vlachas et al. all used the RNN model to model the dynamic changes of molecular conformations. Since the RNN training and inference processes are iterative, the RNN model makes predictions at the current moment based on the calculation results of the previous moment during training, resulting in differences in parallel efficiency. In addition, the RNN model also has problems such as gradient diffusion and gradient explosion, and is unable to capture long-term series dependencies. This limits the efficiency of model training and inference, reducing the inference speed of this type of method in practical applications.
[0046] Based on the above technical problems, the present application provides a molecular dynamics simulation acceleration method, electronic device and storage medium to solve the above technical problems. The technical solutions provided by the present application are described one by one below.
[0047] First, refer to Figure 1 , the present application provides a molecular dynamics simulation acceleration method, including but not limited to steps S110 to S140:
[0048] Step S110: obtaining target motion trajectory information of the target molecule based on the force field;
[0049] Step S120: generating target internal coordinates corresponding to the atomic positions in each frame according to the target motion trajectory information; wherein the target internal coordinates are used to characterize the dependency relationship between each atom;
[0050] Step S130: Input the target internal coordinates into a preset autoencoder for dimensionality reduction processing to obtain a target hidden vector;
[0051] Step S140: inputting the target hidden vector set into a preset time series model to obtain the molecular dynamic change process; wherein the time series model is a Transformer model.
[0052] In this application, the Transformer model is used instead of the RNN model as the timing model to model the dynamic process of the molecular timing hidden vector. Since the RNN model predicts the current moment based on the calculation results of the previous moment during the training process, the parallel efficiency is different; in addition, the RNN model also has problems such as gradient diffusion and gradient explosion, and cannot capture long-term series dependencies. The Transformer model uses a self-attention mechanism to capture the dependency between any two moments, without the need to process them one by one in sequence like traditional RNN. This mechanism makes the calculations at each position independent of each other, so the calculations at all positions can be executed in parallel, which greatly improves the computational efficiency. Therefore, the use of the Transformer structure can greatly speed up training efficiency.
[0053] It is understandable that the time series model Transformer model provided in this application is trained through the following steps:
[0054] Step S210: obtaining training motion trajectory information of the target molecule based on the force field;
[0055] In step S110 of some embodiments, the system uses a short segment of a molecular dynamics simulation trajectory based on an empirical force field as training data. Due to the large number of atoms in biomolecules and the complexity of the system, molecular simulation trajectories based on first principles cannot usually be obtained within a reasonable time frame. Molecular dynamics simulation of biomolecules generally requires the following process: determining the starting configuration, selecting the force field and simulation software, establishing the system, energy minimization, system equilibration, data acquisition, and MD result analysis. Assuming that the target molecule contains N atoms, during the data acquisition process, the trajectory is sampled at time intervals dt, and the Cartesian coordinates of the N atoms in each frame are recorded, and the training motion trajectory information Traj= <F1,F2,…,F i ,…,F M >, the trajectory file contains a total of M frames, and the total simulation time is M*dt.
[0056] Step S220: generating a training internal coordinate set corresponding to the atomic position in each frame according to the training motion trajectory information; wherein the training internal coordinate set is used to characterize the dependency relationship between each atom;
[0057] Step S230: Divide the training internal coordinate set into a plurality of first training samples, input the first training samples into a preset autoencoder, and encode the first training samples by the autoencoder to obtain a training hidden vector set corresponding to each first training sample;
[0058] In step S130 of some embodiments, the first training sample may be a set of several frames of training internal coordinate sets, and the feature representations of the training internal coordinate sets in the previous step are arranged in chronological order to obtain a trajectory feature sequence. <X1,X2,…,X i ,…,X M >. Each first training sample contains H frames, which are divided into First training samples. Fix the autoencoder parameters, input the first training sample into the autoencoder, and obtain the hidden vector representation of the sample. The training hidden vector set of each first training sample is represented as S j = <L j*H+1 ,L j*H+2 ,…,L j*H+H >.
[0059] Step 240: Divide the training hidden vector set into a test vector set and an expected vector set, and input the test vector set into the time series model in the initial state to obtain a predicted vector set;
[0060] In step S240 of some embodiments, the time series model in the present application is an Informer model, which is a variant of the Transformer for time series prediction task scenarios. The Informer model has more effective long time series prediction performance than the Transformer.
[0061] Step S250: Optimize the parameters of the time series model according to the expected vector set and the predicted vector set.
[0062] In steps S210 to S250 shown in the embodiment of the present application, during the training process, the atomic positions in each frame are marked using internal coordinates to capture the dependency between any two moments, without the need to process them one by one in sequence like traditional RNNs. This mechanism makes the calculation of each position independent of each other, so the calculation of all positions can be executed in parallel, thereby greatly improving the inference speed of practical applications, and thus improving the model training efficiency in the corresponding model training.
[0063] Reference Figure 3 In some embodiments, step S220 may include but is not limited to steps S310 to S330:
[0064] Step S310: Obtain the Cartesian coordinates corresponding to all atoms in each frame of the molecule according to the training motion trajectory information;
[0065] Step S320: determining the bond length between two atoms, the bond angle between three atoms, and the dihedral angle between four atoms according to the Cartesian coordinates corresponding to each atom;
[0066] Step S330: Generate a training internal coordinate set corresponding to all atoms in each frame of the molecule based on the bond length, bond angle and dihedral angle.
[0067] In steps S310 to S330 of this embodiment, the training motion trajectory information is preprocessed to convert the Cartesian coordinates of the molecule into internal coordinates, which serve as training data for the autoencoder. Specifically, the Cartesian coordinates of the molecule are converted into internal coordinates. Specifically, the recorded atom pool Atom = [] is initialized, and the first atom at the end of the molecule's C skeleton is selected as the starting atom A1 and added to the Atom list. Select any atom connected to it as the second atom A2, record its distance from the first atom, add it to the Atom list, and record it as the bond length B1; traverse all atoms not in the Atom list, search for the first atom connected to the atom in the Atom list and forming a chemical bond and bond angle with the atom in the list as the third atom A3, record the bond length B2 and bond angle Angle1; traverse all atoms not in the Atom list, search for the first atom connected to the atom in the Atom list and forming a chemical bond, bond angle, and dihedral angle with the atom in the list as the fourth atom A4, record the bond length B3, bond angle Angle2, and dihedral angle D1; and so on. For each atom in the future, it is necessary to determine the bond length, bond angle, and dihedral angle associated with it, such as Figure 11 As shown. After the preprocessing is completed, the atomic position F of each frame i It can be represented by N-1 bond lengths, N-2 bond angles, and N-3 dihedral angles, and its characteristic is represented by X i = <B1,B2,…,B N-1 ,Angle1,Angle2,…,Angle n-2 ,D1,D2,…,D N-3 >i, as shown in Table 1:
[0068]
[0069]
[0070] Table 1
[0071] By converting the molecular Cartesian coordinates into internal coordinates to represent the dependencies between each atom, the Transformer model employs a self-attention mechanism to capture the dependencies between any two moments, eliminating the need for sequential processing like traditional RNNs. This mechanism ensures that calculations at each position are independent of each other, allowing calculations at all positions to be performed in parallel, significantly improving computational efficiency. Therefore, the Transformer architecture can significantly accelerate training efficiency.
[0072] Reference Figure 4 In some embodiments, step S240 may include but is not limited to steps S410 to S430:
[0073] Step S410: Split the training hidden vector set according to a preset division rule, using the hidden vectors in the front part of the training hidden vector set as the test vector set and the hidden vectors in the back part as the expected vector set;
[0074] Step S420: adding placeholder vectors to the test vector set according to the expected vector set to form an input vector set;
[0075] Step S430: Input the input vector set into the time series model in the initial state to obtain a prediction vector set.
[0076] In steps S410 to S430 shown in this embodiment, the first t hidden vectors of each sample are used as the test vector set of the time series model input, and the last Ht hidden vectors are used as the expected vector set of the sample label. A placeholder vector is added to the test vector set to form an input vector set, that is, the input vector set is <L j*H+1:j*H+t ,P t+1:H >, where P t+1:H It is represented as a vector representation of (Ht) placeholders. The expected vector set is L j*H+(t+1):j*H+H , the prediction vector set output by the model is recorded as D j*H+(t+1):j*H+H .
[0077] The following describes the Informer model from input <L j*H+1:j*H+t ,P t+1:H >To model output D j*H+(t+1):j*H+H The complete calculation process. <L j*H+1:j*H+t ,P t+1:H >Self-attention is calculated through the Masked Multi-head ProbSparse self-attention layer of Informer. Compared with the original Informer model structure, since the encoder part of Informer is not used, there is no need to calculate the Multi-head attention layer between encoder-decoder. The Masked Multi-head ProbSparse layer and the Feed forward layer are both followed by the Add&Norm layer. Add represents the residual connection, which is used to prevent network degradation. Norm represents the layer Normalization layer, which is a common operation in neural network training. For the sake of simplicity, it is not described in detail. The output of the Masked Multi-head ProbSparse self-attention is directly connected to two layers of fully connected layers with ReLU functions. The output of the fully connected layer is used as the input of the next decoder block. Usually, multiple decoder blocks need to be stacked to capture complex sequence dependencies. The output of the last decoder block is Finally, connect a fully connected layer, and the calculation formula is as follows D j*H+1:j*H+H =H×W O ,in The result is only the prediction result D after t j*H+(t+1):j*H+H The calculation process of Masked Multi-head ProbSparse self-attention requires extensive theoretical foundations and is outside the scope of protection of this patent. A detailed calculation process is provided in point 6. During inference, compared to the dynamic decoding process of the traditional Transformer, the Informer's inference process can output prediction results for multiple moments at a time, significantly reducing inference time.
[0078] Reference Figure 5 In some embodiments, step S250 may include but is not limited to steps S510 to S520:
[0079] Step S510: Calculating a first loss value between the expected vector set and the predicted vector set;
[0080] Step S520: Optimize the parameters of the time series model according to the first loss value.
[0081] According to the above steps, the model outputs the result D j*H+(t+1):j*H+H and target L j*H+(t+1):j*H+H , calculate the first loss value of MSE loss. The calculation formula is as follows:
[0082]
[0083] Reference Figure 6 In some embodiments, after step S520, the molecular dynamics simulation acceleration method may further include, but is not limited to, step S610:
[0084] Step S610: Re-divide the training hidden vector set into a test vector set and an expected vector set, and execute subsequent steps to iteratively train the optimized timing model until the first loss value or the number of iterations meets the preset convergence condition to obtain the trained timing model.
[0085] In step S610 shown in this embodiment, the number of training steps step can be set to 0. After step S410 to step S420, the number of training steps step is increased by one, and it is determined whether the current number of training steps step is greater than the set maximum number of training steps max_step, or whether the current first loss value converges. If the current number of training steps step is less than the set maximum number of training steps max_step or the current first loss value does not converge, step S140 is re-executed.
[0086] Reference Figure 7 In some embodiments, before step S230, the molecular dynamics simulation acceleration method may further include but is not limited to the steps of training the autoencoder, specifically steps S710 to S730:
[0087] Step S710: taking the training internal coordinate set corresponding to the atomic position of one frame as the second training sample and inputting it into the autoencoder in the initial state for forward calculation to obtain the reconstructed position;
[0088] Step S720: Calculating a second loss value between the second training sample and the reconstructed position;
[0089] Step S730: Optimize the parameters of the autoencoder according to the second loss value.
[0090] In step S710, the training motion trajectory information Traj= <F1,F2,…,F i ,…,F M >M samples are divided according to each frame. A second training sample X is used as the input of the autoencoder, and the autoencoder performs forward calculation to obtain the reconstructed samples of the batch The present invention uses a multi-layer perceptron as the autoencoder network structure. The autoencoder structure consists of two parts, the encoder and the decoder. The encoder consists of an L-layer feedforward neural network, and its output dimensions are <o1,o2,…,o L >, where o1>=o2>=…>=o L ; The decoder also consists of an L-layer feedforward neural network, and its output dimensions are <o L-1 ,o L-2 ,…,o1,3N-6>, where 3N-6>=o1>=o2>=…>=o L-1 , there is no restriction on the selection of the autoencoder network structure in this application.
[0091] In steps S720 to S730, the reconstruction error is calculated based on the second training sample and the reconstructed position in the above steps. The Mean Squared Error (MSE) can be used for calculation. The calculation formula is as follows:
[0092]
[0093] According to the loss value of the previous step, the update gradient of the autoencoder is obtained and the autoencoder parameters are updated.
[0094] Reference Figure 8 In some embodiments, after step S730, the following steps may also be included but not limited to step S810:
[0095] Step S810: re-inputting a plurality of second training samples into the optimized autoencoder to iteratively train the optimized autoencoder until the second loss value or the number of iterations meets the preset convergence condition, thereby obtaining a trained autoencoder.
[0096] In step S710 shown in this embodiment, when training the autoencoder, it can also adopt a method similar to step S510, setting the number of training steps step to 0, and after steps S610 to S630, the number of training steps step is increased by one, and it is determined whether the current number of training steps step is greater than the set maximum number of training steps max_step, or whether the current second loss value converges. If the current number of training steps step is less than the set maximum number of training steps max_step or the current second loss value does not converge, steps S610 to S630 are re-executed.
[0097] It should be noted that the training of the timing model in steps S210 to S250 needs to be performed on the basis of the trained autoencoder. That is, in the training method of molecular dynamics simulation acceleration, the autoencoder needs to be trained first, and then the Transformer timing model is trained after the autoencoder is trained.
[0098] Reference Figure 9 In some embodiments, in order to improve the accuracy of molecular dynamics simulation, optionally, after step S250, the method further includes but is not limited to jointly retraining the autoencoder and the time series model, specifically steps S910 to S950:
[0099] Step S910: inputting the first training sample into the trained autoencoder again for forward calculation and encoding processing to obtain a set of reconstructed positions of atom positions of several frames and a set of training hidden vectors corresponding to each first training sample;
[0100] Step S920: Divide the training hidden vector set into a test vector set and an expected vector set, and input the test vector set into the trained time series model to obtain a predicted vector set;
[0101] Step S930: calculating a third loss value between the first training sample and the reconstructed position set, and calculating a fourth loss value between the expected vector set and the predicted vector set;
[0102] Step S940: Calculate a comprehensive loss value based on the third loss value and the fourth loss value;
[0103] Step S950: According to the comprehensive loss value, the autoencoder and the time series model are optimized again.
[0104] The difference between step S910 and step S710 is that the first training sample in step S910 includes a set of internal coordinate sets for training of several frames, while the second training sample in step S710 is a set of internal coordinate sets for training of a single frame. In a complete training process, steps S910 to S950 need to be performed based on at least one separate training of the autoencoder and the time series model.
[0105] Specifically, in step S910 to step S950, the feature representations of the internal coordinate set trained in the previous step are arranged in chronological order to obtain the trajectory feature sequence <X1,X2,…,X i ,…,X M >. Each first training sample contains H frames, which are divided into The first training sample is input into the autoencoder to obtain the H-frame trajectory reconstruction position of each first training sample. And the training hidden vector set of each first training sample is denoted as S j = <L j*H+1 ,L j*H+2 ,…,L j*H+H >. The first t hidden vectors of each sample are used as the input of the Informer model, and the last Ht hidden vectors are used as the sample label. That is, the model input is <L j*H+1:j*H+i ,P t+1:H >, where Target is L j*H+(t+1):j*H+H , the output of the Informer model is recorded as D j*H+(t+1):j*H+H According to the above steps, the model Infomer outputs the result D j*H+(t+1):j*H+H and target L j*H+(t+1):j*H+H Calculate the fourth loss value of MSE. Output of the autoencoder With sample <X j*H+1 ,X j*H+2 ,…,X j*H+H >Calculate the reconstruction error loss and calculate the third loss value: Based on the third and fourth loss values, the overall loss is calculated as: Overall Loss = αReconstruct Loss + MSE Loss. The value of α is typically an empirical value and needs to be adjusted based on the model's performance on the validation set. This joint retraining of the autoencoder and time series model further improves their accuracy, enabling molecular dynamics simulations to be completed with greater efficiency and accuracy.
[0106] Reference Figure 10 In some embodiments, after step S950, the molecular dynamics simulation acceleration method may further include but is not limited to the following steps S1010:
[0107] Step S1010: Re-input a number of first training samples into the optimized autoencoder, and re-divide the training hidden vector set into a test vector set and an expected vector set, and execute subsequent steps to iteratively train the optimized autoencoder and the optimized time series model again until the comprehensive loss value or the number of iterations meets the preset convergence conditions, thereby obtaining the trained autoencoder and time series model.
[0108] In step S1010, in this embodiment, the autoencoder and the timing model are optimized and trained simultaneously, and the comprehensive loss value and the number of iterations are used to determine whether the preset convergence conditions are met. By training the autoencoder and the timing model simultaneously, the training efficiency of the molecular dynamics simulation acceleration model is improved.
[0109] Second, see Figure 12 , Figure 12 The hardware structure of an electronic device according to another embodiment is shown. The electronic device includes:
[0110] The processor 1201 can be implemented as a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0111] The memory 1202 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1202 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1202, and the processor 1201 calls and executes the intention jump method of the embodiments of this application;
[0112] Input / output interface 1203, used to implement information input and output;
[0113] Communication interface 1204, used to implement communication interaction between this device and other devices, which can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WiFi, Bluetooth, etc.);
[0114] Bus 1205 , which transmits information between various components of the device (e.g., processor 1201 , memory 1202 , input / output interface 1203 , and communication interface 1204 );
[0115] The processor 1201 , the memory 1202 , the input / output interface 1203 and the communication interface 1204 are connected to each other in communication within the device via the bus 1205 .
[0116] On the third aspect, an embodiment of the present application also provides a storage medium, which is a computer-readable storage medium used for computer-readable storage. The storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the above-mentioned intention jump method.
[0117] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0118] The intention jump method and device, electronic device and storage medium provided in the embodiments of the present application are that the user selects the first state node in the preset state machine and generates a configuration operation instruction. The state machine determines the configuration mode selected by the user and the configuration content corresponding to the configuration mode according to the configuration operation instruction, and determines the intention jump condition of the first state node according to the configuration content. The intention jump condition is used to indicate the conditions that must be met to jump from the first state node to the second state node. When the preset state machine reaches the first state node, the user's query content is obtained, and the query content is matched with the intention jump condition corresponding to the first state node to obtain a matching result. When the matching result indicates a successful match, the machine jumps from the first state node to the second state node. The solution of the present application enables the task-type robot to select different intention jump configuration modes in different application scenarios. At the same time, the present application discloses two configuration modes. In the complex first configuration mode, the intention jump conditions of the first state node are jointly determined by the dictionary tree, regular expression set and intention recognition model. In the simple second configuration mode, the intention jump conditions of the second state node are jointly determined by the keyword set, thereby realizing the intention jump of the state machine from the first state node to the second state node. The appropriate configuration mode is selected for the first state node in different application scenarios, thereby improving the application scope.
[0119] The embodiments described in the embodiments of this application are intended to more clearly illustrate the technical solutions of the embodiments of this application and do not constitute a limitation on the technical solutions provided by the embodiments of this application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0120] It will be understood by those skilled in the art that Figure 1-9 The technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than those shown in the figures, or a combination of certain steps, or different steps.
[0121] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, i.e., they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment.
[0122] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the devices disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.
[0123] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0124] It should be understood that in this application, "at least one (item)" means one or more, and "more" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or plural.
[0125] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0126] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0127] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0128] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store programs.
[0129] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention should be within the scope of the present invention.< / start>
Claims
1. A molecular dynamics simulation acceleration method, characterized in that: include: Obtain target motion trajectory information of target molecules based on force field; Generate target internal coordinates corresponding to the atomic positions in each frame based on the target motion trajectory information; wherein the target internal coordinates are used to characterize the dependency relationship between each atom; Input the target internal coordinates into a preset autoencoder for dimensionality reduction to obtain a target hidden vector; Inputting the target hidden vector set into a preset time series model to obtain the molecular dynamic change process; wherein the time series model is a Transformer model; The time series model is trained by the following steps: Obtaining training motion trajectory information of training molecules based on force fields; Generating a training internal coordinate set corresponding to the atomic position in each frame according to the training motion trajectory information; Dividing the training internal coordinate set into a plurality of first training samples, inputting the first training samples into the preset autoencoder, and encoding the first training samples by the autoencoder to obtain a training hidden vector set corresponding to each first training sample; Dividing the training hidden vector set into a test vector set and an expected vector set, and inputting the test vector set into the time series model in an initial state to obtain a prediction vector set; Optimizing parameters of the time series model according to the expected vector set and the predicted vector set; Before the step of dividing the training internal coordinate set into a plurality of first training samples, inputting the first training samples into the preset autoencoder, and encoding the first training samples by the autoencoder to obtain a training hidden vector set corresponding to each first training sample, the step of training the autoencoder is further included: The training internal coordinate set corresponding to the atomic position of one frame is used as a second training sample and input into the autoencoder in the initial state for forward calculation to obtain a reconstructed position; Calculating a second loss value between the second training sample and the reconstructed position; Optimizing the parameters of the autoencoder according to the second loss value; After the step of optimizing the parameters of the time series model according to the expected vector set and the predicted vector set, the method further includes: Inputting the first training sample into the trained autoencoder again for forward calculation and encoding processing to obtain a set of reconstructed positions of atomic positions of several frames and a set of training hidden vectors corresponding to each of the first training samples; Dividing the training hidden vector set into a test vector set and an expected vector set, and inputting the test vector set into the trained time series model to obtain a prediction vector set; Calculating a third loss value between the first training sample and the reconstructed position set, and calculating a fourth loss value between the expected vector set and the predicted vector set; Calculating a comprehensive loss value based on the third loss value and the fourth loss value; According to the comprehensive loss value, the autoencoder and the timing model are re-optimized respectively.
2. The molecular dynamics simulation acceleration method according to claim 1, characterized in that: Generating a training internal coordinate set corresponding to the atomic position of each frame according to the training motion trajectory information includes: Obtaining Cartesian coordinates corresponding to all atoms in each frame of the molecule according to the training motion trajectory information; Determine the bond length between two atoms, the bond angle between three atoms, and the dihedral angle between four of the atoms based on the Cartesian coordinates corresponding to each atom; A training internal coordinate set corresponding to all atoms in each frame of the molecule is generated according to the bond length, the bond angle and the dihedral angle.
3. The molecular dynamics simulation acceleration method according to claim 1, characterized in that: The step of dividing the training hidden vector set into a test vector set and an expected vector set, and inputting the test vector set into the time series model in an initial state to obtain a prediction vector set includes: The training hidden vector set is divided according to a preset division rule, and the hidden vectors of the front part of the training hidden vector set are used as the test vector set, and the hidden vectors of the rear part are used as the expected vector set; According to the expected vector set, adding a placeholder vector to the test vector set to form an input vector set; The input vector set is input into the time series model in the initial state to obtain a prediction vector set.
4. The molecular dynamics simulation acceleration method according to claim 1, characterized in that: Optimizing the parameters of the time series model according to the expected vector set and the predicted vector set includes: Calculating a first loss value between the expected vector set and the predicted vector set; Optimizing parameters of the timing model according to the first loss value.
5. The molecular dynamics simulation acceleration method according to claim 4, characterized in that: After the step of optimizing the parameters of the time series model according to the first loss value, the method further includes: Re-divide the training hidden vector set into a test vector set and an expected vector set, and execute subsequent steps to iteratively train the optimized timing model until the first loss value or the number of iterations meets the preset convergence condition, thereby obtaining the trained timing model.
6. The molecular dynamics simulation acceleration method according to claim 1, characterized in that: After the step of optimizing the parameters of the autoencoder according to the second loss value, the method further includes: Re-inputting a plurality of the second training samples into the optimized autoencoder to iteratively train the optimized autoencoder until the second loss value or the number of iterations meets a preset convergence condition, thereby obtaining a trained autoencoder.
7. The molecular dynamics simulation acceleration method according to claim 1, characterized in that: After the step of re-optimizing the autoencoder and the time series model according to the third loss value and the fourth loss value, the method further includes: Re-inputting several of the first training samples into the optimized autoencoder, and re-dividing the training hidden vector set into a test vector set and an expected vector set, and executing subsequent steps to iteratively train the optimized autoencoder and the optimized timing model again until the comprehensive loss value or the number of iterations meets the preset convergence conditions, thereby obtaining a trained autoencoder and timing model.
8. An electronic device, characterized in that: include: at least one memory; at least one processor; at least one program; The programs are stored in the memory, and the processor executes at least one of the programs to implement the molecular dynamics simulation acceleration method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer-executable signal, and the computer-executable signal is used to execute the molecular dynamics simulation acceleration method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Three-dimensional space molecule generation method and device based on multi-task pre-training inverse reinforcement learning
CN115831261A
Molecular dynamics simulation method and system based on hybrid functional and first principle
CN115859597A