Molecular structure generation method based on multi-scale attention mechanism
Through a generative adversarial network based on a multi-scale attention mechanism, the problem that molecular structure generation methods in the prior art cannot ensure chemical properties and stability is solved, and a more accurate and chemical-compliant molecular structure generation is achieved.
Patent Information
- Application Number
- CN202510589270.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-08
- Publication Date
- 2025-08-12
AI Technical Summary
The molecular structure generation methods in the prior art cannot effectively ensure the rationality of the generated molecules in terms of chemical properties, stability and synthesisability, resulting in the generated molecular structure not meeting the actual requirements in terms of chemical properties.
Generative adversarial networks based on multi-scale attention mechanisms are adopted, including multiple attention modules for molecular feature extraction, feature generation depth separation of convolutional convolution modules and component constraint modules. The local information and global structure of molecules are captured through multiple attention mechanisms, combined with chemical bond connection relationships, and through component constraint modules, ensure that the molecular structure conforms to given elemental composition and chemical rules.
It improves the accuracy and quality of molecular structure generation, ensures that the generated molecular structure complies with chemical laws and actual requirements, and improves the chemical properties and stability of the generated molecules.
Smart Images

Figure CN120473026A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the intersection of artificial intelligence and computational chemistry, and in particular to a molecular structure generation method based on a multi-scale attention mechanism. Background Art
[0002] Continuous advances in science and technology have fueled the development of the materials field, while the rise of generative artificial intelligence (AI) has accelerated the progress of molecular research. Generative AI uses machine learning models to creatively generate new, realistic data, such as images, text, audio, or video, based on the patterns and features of existing data. This has led to innovative breakthroughs in various fields.
[0003] Existing molecular structure generation methods fall into two main categories. One is the variational autoencoder (VAE), a deep generative model that employs an encoder-decoder architecture and generates new samples with a distribution similar to the training data by learning the latent representation of the data. In molecular structure generation tasks, VAEs can learn the implicit laws underlying molecular structure in the latent space and generate molecules that conform to chemical rules. By sampling in the latent space, VAEs not only generate new molecular structures but also ensure that these generated molecules have statistically similar properties to those in the training data. However, when generating molecules, VAEs optimize the distribution of the latent space by maximizing the variational lower bound (ELBO). The ELBO consists of two parts: reconstruction loss and information divergence (Kullback-Leibler, KL). Although the KL divergence constrains the structure of the latent space, it cannot ensure the rationality of the generated molecules in terms of chemical properties, stability, and synthesizability. As a result, the molecules generated by VAEs are structurally reasonable but their chemical properties do not meet practical requirements.
[0004] Therefore, there is an urgent need for a method to improve the accuracy of molecular structure generation. Summary of the Invention
[0005] Therefore, it is necessary to provide a molecular structure generation method based on a multi-scale attention mechanism to address the above technical issues. This method can improve the accuracy of molecular structure generation.
[0006] The present invention adopts the following technical solutions:
[0007] The present invention provides a molecular structure generation method based on a multi-scale attention mechanism, comprising:
[0008] Construct a generative adversarial network (GAN); the GAN consists of a generator and a composition constraint module. The generator includes a molecular feature extraction multi-attention module, a feature generation deep separable convolution module, and a feature generation module. The feature generation deep separable convolution module is used to comprehensively capture the characteristics of the molecule. The molecular feature extraction multi-attention module is used to capture the local information, global structure, and chemical bond connection relationship of the molecule. The composition constraint module is used to ensure that the molecular structure conforms to the given elemental composition and chemical rules.
[0009] Acquire molecular feature information and input it into the generator. Use the molecular feature extraction multi-attention module to extract features from the molecular feature information to obtain molecular feature representation. Use the feature generation deep separable convolution module to process the molecular feature representation to obtain optimized molecular features. After inputting the optimized molecular features into the feature generation module, generate the molecular structure.
[0010] The molecular structure is input into the component constraint module, and the molecular structure is corrected to obtain the target molecular structure.
[0011] Preferably, the molecular feature extraction multi-attention module includes a channel attention module, a spatial attention module, and a self-attention module; the molecular feature information is extracted by the molecular feature extraction multi-attention module to obtain a molecular feature representation, specifically including:
[0012] The molecular feature information is input into the channel attention module, and different attention scores are assigned to each channel of the molecular feature information to obtain the channel attention feature; each channel in the channel attention feature represents a different molecular feature;
[0013] Multiply the molecular feature information and the channel attention feature element-wise to obtain the first weighted feature;
[0014] Input the first weighted feature into the spatial attention module for processing to obtain a spatial attention feature;
[0015] Multiply the molecular feature information and the spatial attention feature element-wise to obtain the second weighted feature;
[0016] The second weighted feature is input into the self-attention module for processing to obtain the molecular feature representation.
[0017] Preferably, the feature generation depthwise separable convolution module includes three layers of depthwise separable convolution, squeeze and excitation modules connected in series. The molecular feature representation is processed by the feature generation depthwise separable convolution module to obtain optimized molecular features, specifically including:
[0018] For each layer in the feature generation depthwise separable convolution module, each channel of the molecular feature representation is depthwise convolved by depthwise separable convolution;
[0019] After depthwise convolution, each channel is adaptively adjusted through the squeeze and excitation module;
[0020] After the three layers of depth-wise separable convolution, squeeze and excitation modules are processed in series, the output features of the squeeze and excitation module of the last layer are determined as the optimized molecular features.
[0021] Preferably, obtaining molecular characteristic information specifically includes:
[0022] Obtain the true characteristics of molecules;
[0023] The molecular true features and Gaussian noise are processed by maximum pooling and average pooling respectively to obtain maximum pooling features and average pooling features;
[0024] Perform convolution operation on the maximum pooling feature and the average pooling feature to obtain the convolution result;
[0025] The convolution results, maximum pooling features, and average pooling features are added element-wise to obtain molecular feature information.
[0026] Preferably, the method further comprises:
[0027] After obtaining the molecular structure, the molecular structure is input into the discriminator, where the similarity between the molecular structure and the true molecular structure is evaluated to obtain a probability value; the probability value represents whether the molecular structure is true or false;
[0028] And feed the probability value back to the generator to make the generator.
[0029] Preferably, the molecular structure is input into the component constraint module, and the molecular structure is corrected to obtain the target molecular structure, which specifically includes:
[0030] The feature map corresponding to the molecular structure is input into the component constraint module, and the feature map is downsampled by the component constraint module;
[0031] After the downsampling operation, the feature map is repeatedly subjected to depth-wise separable convolution and batch normalization to obtain a multidimensional feature map;
[0032] Convert the multi-dimensional feature map into a one-dimensional vector, and input the one-dimensional vector into the fully connected layer for processing to obtain the fully connected layer processing result;
[0033] The results of the fully connected layer processing are converted into probability distributions; the probability distributions are used to evaluate the likelihood that the molecular structure belongs to the target component category;
[0034] Compare the molecular structure to the target component category and identify deviations in the chemical composition of the molecular structure;
[0035] The molecular structure is optimized according to the deviation to obtain the final target molecular structure.
[0036] The present invention provides a molecular structure generation device based on a multi-scale attention mechanism, comprising:
[0037] A construction module for constructing a generative adversarial network (GAN); the GAN includes a generator and a composition constraint module. The generator includes a molecular feature extraction multi-attention module, a feature generation deep separable convolution module, and a feature generation module. The feature generation deep separable convolution module is used to comprehensively capture the characteristics of the molecule. The molecular feature extraction multi-attention module is used to capture the local information, global structure, and chemical bond connection relationship of the molecule. The composition constraint module is used to ensure that the molecular structure conforms to the given elemental composition and chemical rules.
[0038] The generation module is used to obtain molecular feature information and input the molecular feature information into the generator. The molecular feature information is extracted by the molecular feature extraction multi-attention module to obtain molecular feature representation. The molecular feature representation is processed by the feature generation deep separable convolution module to obtain optimized molecular features. After the optimized molecular features are input into the feature generation module, the molecular structure is generated.
[0039] The correction module is used to input the molecular structure into the component constraint module, correct the molecular structure, and obtain the target molecular structure.
[0040] The present invention provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the above-mentioned molecular structure generation method based on the multi-scale attention mechanism.
[0041] The present invention provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the method for generating molecular structures based on a multi-scale attention mechanism is implemented.
[0042] At least one of the above technical solutions adopted by the present invention can achieve the following beneficial effects:
[0043] In the present invention, a generative adversarial network is constructed; molecular feature information is obtained and input into the generator, and the molecular feature information is extracted through the molecular feature extraction multi-attention module to obtain molecular feature representation. The molecular feature extraction multi-attention module combines hybrid channel attention, channel attention and self-attention mechanisms. The hybrid channel attention optimizes the selection of different channel features, the channel attention adjusts the weight of each channel feature, and the self-attention captures the long-range dependency between atoms. Through the combination of the three mechanisms, the model can comprehensively and accurately extract the local and global features of the molecule, thereby improving the quality and accuracy of molecular structure generation. The deep separable convolution module processes the molecular feature representation to obtain optimized molecular features. After the optimized molecular features are input into the feature generation module, the molecular structure is generated. The feature generation deep separable convolution module adaptively adjusts the convolution kernel size and combines deep convolution and point-by-point convolution to fully capture the characteristics of each atom. The channel attention module can adaptively adjust the channel weights, thereby effectively compensating for the shortcomings of deep separable convolution in capturing global features. The molecular structure is input into the composition constraint module, and the molecular structure is corrected to obtain the target molecular structure. The generated molecular structure is identified to ensure that it conforms to the given elemental composition and strengthen the constraints on the generator. This method can improve the accuracy of molecular structure generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0045] Figure 1 The overall structure diagram of a molecular structure generation method based on a multi-scale attention mechanism provided by the present invention;
[0046] Figure 2 A schematic diagram of the process of molecular structure generation based on a multi-scale attention mechanism provided by the present invention;
[0047] Figure 3 Schematic diagram of the molecular feature extraction multi-attention module provided by the present invention;
[0048] Figure 4 Schematic diagram of the feature generation depth-separable convolution module provided by the present invention;
[0049] Figure 5 A schematic diagram of a component constraint module provided by the present invention;
[0050] Figure 6 A schematic diagram of a molecular structure generation device based on a multi-scale attention mechanism provided by the present invention;
[0051] Figure 7 A schematic diagram of a computer device provided by the present invention for implementing a molecular structure generation method based on a multi-scale attention mechanism. DETAILED DESCRIPTION
[0052] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with specific embodiments of the present invention and corresponding drawings. Obviously, the embodiments described are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0053] Devices such as desktop computers, laptop computers, and servers that can execute the solution of the present invention are described below with the server as the execution subject for the sake of convenience.
[0054] VAE maps input data (such as the representation of a molecule) to a probability distribution in a latent space (usually a Gaussian distribution) and optimizes the model by maximizing the variational lower bound (ELBO). The encoder part is responsible for extracting features from the input data and outputting the mean and variance of the latent variables, defining a distribution in a latent space. The decoder samples latent variables from the latent space and then reconstructs the data through a decoding process to generate new samples. For molecules represented by a graph structure, the generator outputs a graph structure in which nodes represent atoms and edges represent chemical bonds; for molecules represented by SMILES, the generator outputs a SMILES string.
[0055] The discriminator's task is to determine whether an input molecule comes from a real dataset or is a fake molecule generated by the generator. The discriminator distinguishes between real and fake samples by outputting a probability value. For graph-based molecules, the discriminator receives the molecule's graph structure and evaluates whether it conforms to chemical laws. For SMILES-based molecules, the discriminator determines whether the generated SMILES string conforms to a valid chemical molecular structure. The generator continuously optimizes its adversarial process with the discriminator, striving to generate sufficiently realistic molecules that the discriminator cannot distinguish between the generated molecules and real ones. During training, the discriminator continuously improves its ability to distinguish between real and fake molecules. Through this game-like training, the generator gradually learns to generate molecular structures that meet the target requirements, while the discriminator also continuously improves its judgment accuracy. The discriminator is typically a binary classification model that outputs a value between 0 and 1, indicating whether the input sample is "real." Through adversarial training with the generator, the discriminator gradually improves the accuracy and robustness of its judgment.
[0056] When a variational autoencoder (VAE) generates molecules, it cannot effectively ensure the rationality of the generated molecules in terms of chemical properties, stability, and synthesizability. As a result, a VAE may generate molecules that are structurally sound but chemically incompatible with practical requirements. When GANs are applied to molecular structure generation, the goal is to generate samples that are as realistic as possible, but lack explicit chemical constraints, so the generated molecules may contain unreasonable structures.
[0057] In response to the above technical deficiencies, the present invention provides a molecular structure generation method based on a multi-scale attention mechanism, which mainly consists of three modules: a molecular feature extraction multi-attention module, a feature generation deep separable convolution module, and a component constraint module. Figure 1 The figure shows the overall structure of the method provided by the present invention. The present invention first inputs Gaussian noise and true molecular feature information into the generator; secondly, after entering the generator, the molecular overall features and local features are extracted through the molecular feature extraction multi-attention module; thirdly, the extracted features are input into the feature generation deep separable convolution module to generate the molecular structure; finally, the output results of the generator are respectively input into the discriminator and the component constraint module to judge the gap between the generated data and the given data and whether it conforms to the given composition, and provide feedback to the generator.
[0058] The technical solutions provided by various embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0059] Figure 2 The figure is a flow chart of a molecular structure generation method based on a multi-scale attention mechanism in the present invention, which specifically includes the following steps:
[0060] S201: Construct a generative adversarial network; the generative adversarial network includes a generator and a component constraint module; the generator includes a molecular feature extraction multi-attention module, a feature generation deep separable product convolution module and a feature generation module; the feature generation deep separable product convolution module is used to comprehensively capture the features of the molecule; the molecular feature extraction multi-attention module is used to capture the local information, global structure and chemical bond connection relationship of the molecule; the component constraint module is used to ensure that the molecular structure conforms to the given elemental composition and chemical rules.
[0061] S202: Acquire molecular feature information and input the molecular feature information into the generator, extract features from the molecular feature information through the molecular feature extraction multi-attention module to obtain molecular feature representation, process the molecular feature representation through the feature generation deep separable convolution module to obtain optimized molecular features; after inputting the optimized molecular features into the feature generation module, generate the molecular structure.
[0062] In an exemplary embodiment, obtaining molecular feature information specifically includes: obtaining true molecular features; processing the true molecular features and Gaussian noise through maximum pooling and average pooling, respectively, to obtain maximum pooling features and average pooling features; performing a convolution operation on the maximum pooling features and the average pooling features to obtain a convolution result; and performing element-wise addition of the convolution result, the maximum pooling features, and the average pooling features to obtain molecular feature information.
[0063] Specifically, in molecular structure generation, molecular feature extraction is crucial, but current technologies face multiple challenges. Existing methods often only focus on the characteristics of individual atoms, ignoring the complex local environment and relationships between atoms, resulting in insufficient understanding of atomic chemical behavior. In addition, the overall properties of molecules are affected by global structures, such as symmetry and spatial arrangement, while existing models focus too much on local feature extraction and fail to effectively capture global information. At the same time, the chemical bond connections in molecules determine structural stability and chemical properties, but existing methods fail to fully represent the bond connections between atoms, affecting the accuracy and rationality of molecular structure generation. These problems limit the effectiveness of molecular feature extraction and urgently need new technologies to solve them.
[0064] This paper proposes an innovative molecular feature extraction method that effectively captures the local information of atoms, the global structure, and the chemical bond connections by introducing multiple attention mechanisms (including a channel attention mechanism, a spatial attention module, and a self-attention module). Through weighted learning, the model automatically identifies key features, improving the quality and accuracy of molecular structure generation. Specifically for intermolecular bond connections, the method explicitly models atomic relationships to ensure that the generated molecular structure conforms to actual chemical laws. This method provides a more accurate and reliable feature representation for molecular structure generation.
[0065] Specifically, if Figure 3 The figure shows a schematic diagram of the multi-attention module for molecular feature extraction of the present invention. First, the true molecular features and Gaussian noise are processed by maximum pooling (MaxPool) and average pooling (AvgPool) to obtain the first maximum pooling feature and the first average pooling feature. The maximum pooling operation and the average pooling operation are used to extract features and information at different levels. The maximum pooling and the average pooling operations help to capture spatial structure and diversity information, providing a solid foundation for subsequent feature fusion; secondly, the pooled features are the first maximum pooling features and the first average pooling features. The pooled features are convolved to obtain convolution results. The convolution operation further extracts local features and enhances information representation; finally, the convolution result is element-wise added to the pooled features to obtain fused molecular features. The fused molecular features fuse features at different levels, aiming to fully retain and enhance important information in the original input data.
[0066] In an exemplary embodiment, the molecular feature extraction multi-attention module includes a channel attention module, a spatial attention module, and a self-attention module; the molecular feature information is extracted by the molecular feature extraction multi-attention module to obtain a molecular feature representation, specifically including:
[0067] The molecular feature information is input into the channel attention module, and a different attention score is assigned to each channel of the molecular feature information to obtain the channel attention feature; each channel in the channel attention feature represents a different molecular feature; the molecular feature information and the channel attention feature are element-wise multiplied to obtain the first weighted feature; the first weighted feature is input into the spatial attention module for processing to obtain the spatial attention feature; the molecular feature information and the spatial attention feature are element-wise multiplied to obtain the second weighted feature; the second weighted feature is input into the self-attention module for processing to obtain the molecular feature representation.
[0068] Specifically, if Figure 3 As shown in the figure, the molecular feature information is passed as input to the channel-wise attention mechanism (WSA). By adaptively weighting the features of each channel, the network can focus on the most critical part of molecular structure generation. The output of the channel attention mechanism, that is, the channel attention feature, is element-wise multiplied with the true feature of the molecule to obtain the first multiplied feature, which further optimizes the generation process and ensures that the network effectively captures and utilizes important features in the molecular structure generation task.
[0069] The calculation of the convolution operation is shown in formula (1):
[0070] X Conv =Conv(M ax Pool(X+N)+AvgPool(X+N)) (1)
[0071] Among them, X Conv is the convolution result, X is the input feature, N is Gaussian noise, M ax Pool is maximum pooling, AvgPool is average pooling, and ConV is convolution.
[0072] The calculation of the fusion operation is shown in formula (2):
[0073] x fusion =x conv +(M ax Pool(X+N)+AvgPool(X+N)) (2)
[0074] Among them, x fusion is the fused feature, x conv is the convolution result of the previous layer.
[0075] The calculation of channel attention is shown in formula (3):
[0076] X att =A(x fusion ) (3)
[0077] Among them, A is the channel attention mechanism, X att is the result of channel attention acting on the fusion feature. Finally, the calculation of element-wise multiplication of the original feature and the channel attention feature is shown in formula (4):
[0078] Y=X⊙X att (4)
[0079] Among them, Y is the final feature and X is the initial input feature.
[0080] Next, the first multiplied feature is passed to the next stage, where it serves as the input feature and is element-wise multiplied with the true molecular features. This step aims to interact with the input features and capture more fine-grained information. Next, the multiplied results are subjected to max pooling (MaxPool) and average pooling (AvgPool), respectively. These pooling operations are used to reduce the spatial dimensionality of the features while retaining important feature information. After the pooling operation, the max pooling and average pooling results are element-wise summed. This operation helps to fuse the maximum and average values, further enhancing the richness of the feature representation. Finally, the summed features are input to the convolution operation, which further extracts high-level features. The convolved feature map and the pooling result are then element-wise summed and finally input to the spatial attention module for further feature fusion and processing. Spatial attention is a specialized spatial attention module designed to enhance key areas in the image through convolution. In spatial attention, the input feature map is pooled and convolved to generate a spatial attention map, and the features of important areas are enhanced in a weighted manner.
[0081] The calculation of the spatial attention mechanism is shown in formula (5):
[0082] X san =SAN(x final ) (5)
[0083] Among them, X san is the output result of spatial attention, SAN is the spatial attention mechanism, x final is the final result feature of the previous level channel attention, such as the Y output of formula (4).
[0084] The calculation of spatial attention score is shown in formula (6):
[0085]
[0086] Among them, Attention Score is the attention score, Q is the query vector, k T is the key vector, d k is the dimension of the key vector.
[0087] The calculation of attention weight is shown in formula (7):
[0088] Attention Weights=Softmax(Attention Score) (7)
[0089] The calculation of weighted summation of value vectors by attention weights is shown in formula (8):
[0090] O=∑(Attention Weights×V) (8)
[0091] Among them, O is the output of the spatial attention mechanism and V is the value vector.
[0092] For each feature in the input sequence, first, three different linear transformations are performed to generate query, key, and value vectors. The inner product of the query vector and the key vector is used to calculate the attention score, which represents the correlation between the parts in the sequence, where d k is the dimension of the key vector. The inner product result is scaled to maintain stability. The attention score is converted into a weight through the Softmax function to ensure that the sum of the weights is 1, and a weighted sum is performed. Finally, the value vector is weighted summed using the attention weights.
[0093] The true molecular features are element-wise multiplied with the upper-level extracted features to integrate local information (such as electronic effects between adjacent atoms). These features are then convolved to extract local structural features (such as chemical groups). The convolution results are then input into a self-attention module (Non-localAttention) to capture long-range dependencies (such as the global influence between different groups in the molecule). Finally, the output of the self-attention module is element-wise multiplied with the upper-level features to fuse global and local information to obtain the final molecular feature representation. The basic idea of the self-attention module is to determine the importance of each element in the input features by calculating its relationship with all other elements. This allows the capture of long-range dependencies, allowing even spatially distant features to influence each other.
[0094] Depthwise separable convolution is a method that optimizes traditional convolution operations. By decomposing the standard convolution into two steps, it significantly reduces the amount of computation and parameters, thereby improving computational efficiency. In the process of molecular feature generation, it is often necessary to extract the relationships between atoms and groups in a molecule. Traditional convolution operations (especially deep convolutional networks) require calculating the correlation between each position and all channels, which incurs a high computational overhead for complex molecular structures. In contrast, depthwise separable convolution decomposes the convolution operation into two independent steps (depthwise convolution and pointwise convolution), effectively reducing the computational overhead and enabling the network to process molecular structure data more efficiently, especially when the data size is large. Furthermore, depthwise separable convolution performs independent processing on each channel, making it flexible to adapt to convolution kernels of different sizes, thereby extracting richer molecular structural features. For example, for smaller molecular structures (such as rings), a small convolution kernel is used for fine feature extraction; for larger structures (such as long-chain molecules), a larger convolution kernel is used to capture a wider range of features. This flexibility gives depthwise separable convolution a significant advantage in molecular feature extraction. The feature generation deep separable convolution module of the present invention introduces a variable convolution kernel and performs independent convolution operations on the features of each atom according to the characteristics of the different number of atoms in the molecular structure, thereby fully mining the feature information at each atomic level. To ensure that the feature output contains as much useful information as possible, a Squeeze-and-Excitation module is added after the deep separable convolution to adaptively weight the features of each channel. Through this process, important channel features are enhanced, while irrelevant or redundant features are suppressed, thereby improving the accuracy and effectiveness of feature expression. This process ensures the maximum utilization of key features in the process of molecular feature generation.
[0095] In an exemplary embodiment, the feature generation deep separable convolution module includes three layers of depthwise separable convolution, squeeze and excitation modules connected in series; the molecular feature representation is processed by the feature generation deep separable convolution module to obtain optimized molecular features, specifically including: for each layer in the feature generation deep separable convolution module, depthwise convolution is performed on each channel of the molecular feature representation through depthwise separable convolution; after the depthwise convolution is performed, each channel is adaptively adjusted through the squeeze and excitation module; after the three layers of depthwise separable convolution, squeeze and excitation modules connected in series are processed, the output features of the squeeze and excitation module of the last layer are determined as optimized molecular features.
[0096] Specifically, if Figure 4The figure shows a schematic diagram of the feature generation deep separable convolution module provided by the present invention. This module processes molecular features through two parallel paths: one path adaptively adjusts the convolution kernel size according to the number of atoms, and performs a separate deep convolution operation on each atom. It then extracts features through batch normalization and ReLU activation function, and then uses 1x1 convolution for dimensionality increase; the other path compresses the features to 1 / 8 of the size through global pooling, and then restores the dimension and introduces nonlinearity through a fully connected layer to enhance the complex correlation between channels. Finally, the scale operation is used to adjust the weighted channel features to further improve the expression of important features. Finally, the final molecular feature output is obtained through batch normalization and ReLU activation. The results are expressed as follows:
[0097] The calculation of the convolution operation using a 1×1 convolution kernel is shown in formula (9):
[0098] X 1×1 =Conv1×1ReLU(BN(DepthwiseConv(X))) (9)
[0099] Among them, X 1×1 is the result of the convolution operation, Conv1×1 is 1×1 convolution, ReLU is the activation function, BN is batch normalization, X is the molecular feature extracted by the previous level spatial attention mechanism, and DepthwiseConv is depthwise convolution.
[0100] The calculation of the activation function is shown in formula (10):
[0101] X Sigmoid =Sigmoid(FC(FC(GlobalPool(X)))) (10)
[0102] Among them, X Sigmoid is the output result of the activation function, GlobalPool(X) is the global pooling of features, FC is the fully connected layer, and Sigmoid is the activation function.
[0103] The calculation of the final molecular feature output is shown in formula (11):
[0104] X final =ReLU(BN(X 1×1 ×X Sigmoid )) (11)
[0105] Among them, X final is the final molecular feature, ReLU is the activation function, BN is batch normalization, X 1×1 is a 1×1 convolution, X Sigmoid Output result of activation function.
[0106] S203: Input the molecular structure into the component constraint module, correct the molecular structure, and obtain the target molecular structure.
[0107] In an exemplary embodiment, the molecular structure is input into a component constraint module, and the molecular structure is corrected to obtain a target molecular structure, specifically including: inputting a feature map corresponding to the molecular structure into the component constraint module, and performing a downsampling operation on the feature map through the component constraint module; after the downsampling operation, repeatedly performing depthwise separable convolution and batch normalization on the feature map to obtain a multidimensional feature map; converting the multidimensional feature map into a one-dimensional vector, and inputting the one-dimensional vector into a fully connected layer for processing to obtain a fully connected layer processing result; converting the fully connected layer processing result into a probability distribution; the probability distribution is used to evaluate the possibility that the molecular structure belongs to the target component category; comparing the molecular structure with the target component category to identify the deviation of the molecular structure in chemical composition; optimizing the molecular structure according to the deviation to obtain the final target molecular structure.
[0108] Specifically, the composition constraint module checks whether the generated molecules contain a given element type and whether they meet certain molecular ratios or chemical bond constraints. By constraining the elemental composition, the composition constraint module can effectively prevent the generated molecular structure from not conforming to the predetermined chemical properties, ensuring that the generated molecules have a practical and feasible chemical configuration. This constraint mechanism plays a corrective role in the generation process, ensuring that the final generated molecules are not only morphologically reasonable but also chemically meet the given constraints. For example, if the data set contains only boron and magnesium, the constraint module will limit the generated elements to only contain these two.
[0109] The calculation method of the loss of the generative adversarial network in the method of the present invention is shown in formula (12):
[0110] L=L Molecule +λ3L Atom (12)
[0111] Among them, L is the loss, L Molecule is the cross entropy loss at the molecular level, L Atom is the cross entropy loss at the atomic level, and λ3 is the coefficient of the cross entropy loss at the atomic level.
[0112] The calculation method of the cross entropy loss at the molecular level is shown in formula (13):
[0113]
[0114] Among them, L Molecule is the cross entropy loss at the molecular level, is the cross entropy loss of the true category, is the cross entropy loss of the generated category, and λ1 is the weight of the cross entropy loss of the generated category;
[0115] The cross entropy loss at the atomic level is shown in formula (14):
[0116]
[0117] Among them, L Atom is the cross entropy loss at the atomic level, is the cross entropy loss of the real atom, is the cross entropy loss of generated atoms, and λ2 is the weight of the cross entropy loss of generated atoms.
[0118] Specifically, the component constraint module first downsamples the input feature map through the average pooling (AvgPool) operation to reduce the spatial dimension and retain key information. Then, the input is efficiently processed by the depth-wise separable convolution (DS Conv, DS) to reduce the amount of computation. The convolution result is standardized by batch normalization (BatchNorm) to accelerate training and improve stability. The model then repeats the depth-wise separable convolution and batch normalization operations to extract features. Next, the multi-dimensional feature map is converted into a one-dimensional vector using the flattening layer (Flatten) and input into the fully connected layer (Dense layer) for further processing. Finally, the Softmax layer converts the output of the fully connected layer into a probability distribution.
[0119] Specifically, the molecules generated by the generation module are input into the discriminator and the composition constraint module for processing. The discriminator is used to evaluate the difference between the generated molecular structure and the real data. The discriminator calculates the similarity between the generated molecular structure and the real data and outputs a probability value to indicate whether the molecular structure is "real" or "false". This output value is fed back to the generator to help the generator optimize the generation process. By evaluating the generated molecular structure, the discriminator not only provides feedback on true and false judgments, but also prompts the generator to continuously adjust the generation strategy through gradient descent, improve the quality of the generated structure, and make it closer to the real molecule. The expression of the final generated molecular structure is shown in formula (15):
[0120] S gen =G(z,X real ) (15)
[0121] Among them, S gen Represents the generated molecular structure, G is the generator, z is the input noise, X real is the true molecular feature of the input.
[0122] The discriminator processes the generated molecular structure as shown in formula (16):
[0123] D(S gen )=f(S gen) (16)
[0124] Among them, D is the discriminator, D(S gen ) is the judgment result of the discriminator on the generated structure, which is usually true or false. Here, f is the probability function of the generated structure judgment. When it is close to 1, the discriminator output is true, otherwise it is false.
[0125] The calculation of the generator's loss function is shown in formula (17):
[0126] L G =-E z ~P z [f(G(z,x real ))] (17)
[0127] Among them, L G is the loss function of the generator, E z is the expected value of the noise z sampled from the noise distribution, P z is the probability distribution of noise, where f is the generating function used to generate the molecular structure.
[0128] The calculation method of the loss function of the component constraint module is shown in formula (18):
[0129] L C =C(S gen ) (18)
[0130] Among them, L C is the loss function of the component constraint module, and C is the component constraint module.
[0131] The calculation of the overall loss function of the method of the present invention is shown in formula (19):
[0132] L total =L G +λL c (19)
[0133] Among them, λ is a hyperparameter that balances the generator loss and the component constraint loss, L total is the overall loss of the method of the present invention.
[0134] In an exemplary embodiment, the present invention uses the Wasserstein distance to evaluate the similarity between the generated material and the real material, uses the mode score to measure the diversity of the generated model, and evaluates the effectiveness of the generated material by calculating the charge neutrality (CN) and electronegativity balance (EN). These indicators comprehensively consider the quality, coverage and practical application potential of the generated material, thereby ensuring the effectiveness of the generated material in terms of performance and feasibility. The calculation formula of the Wasserstein distance is shown in formula (20):
[0135]
[0136] in, is the expected value of the generated sample, represents the expected value of the real sample, is a regularization term used to ensure that the gradient of the discriminator satisfies the Lipschitz continuity condition.
[0137] The calculation method of Mode Score is shown in formula (21):
[0138]
[0139] in, N is the number of samples, R is the recall rate, P is the precision, i is the current sample number (1 to N), y i is the category label of the real sample, To generate the category label of the sample, π is a multiplication operation, which is used to accumulate the correct prediction of the category label to obtain accurate evaluation results.
[0140] The Mode Score is calculated in two steps: first, precision is calculated to measure the quality of each category in the generated samples, indicating the proportion of generated samples belonging to a certain category. Then, recall is calculated. Similar to precision, recall focuses on the coverage of the generated samples for the true categories. Finally, precision and recall are combined to produce the final Mode Score, which comprehensively reflects the quality and diversity of the generated model.
[0141] The present invention uses materials from databases such as ICSD, OQMD, and MP as training datasets. Finally, after 500 epochs of training, the Wasserstein distance approaches 0, indicating that the generated materials are highly similar to the real materials. The percentages of materials generated by the GAN network and those in the training data that meet charge neutrality (CN) and electronegativity (EN) are then compared. Finally, the novelty of the generated samples is analyzed by comparing the coverage of the generated materials to the training data and the presence of new materials. Table 1 shows the effectiveness of the generated materials, and Table 2 shows the diversity of the generated materials.
[0142] Table 1 Evaluation of the effectiveness of generated materials
[0143] data OQMD (%) ICSD (%) MP (%) ICSD_Filter(%) Training charge neutrality 56.8 85 86.3 100 Generate charge neutrality 55.1 83.2 85.6 94.2 Training negative charge balance 42 78.2 79.9 100 Generate negative charge balance 41.2 75.5 73.6 86.3
[0144] Table 2 Evaluation of the diversity of generated materials
[0145] GAN-OQMD GAN-MP GAN-ICSD Training samples 246597 65423 29875 Set aside a sample 32546 7856 3215 Generate samples 2000000 2000000 2000000 Training sample recovery rate 62.2% 48.5% 61.5% Retention sample recovery rate 63.5% 47.3% 63.7% New Sample 1765532 1832562 1923654
[0146] The proposed model not only performs well on publicly available databases but also achieves excellent results on niche and self-built datasets. Compared to traditional methods, this model demonstrates significant performance improvements and significantly accelerates research progress in materials research and development across multiple fields. Specifically, in publicly available databases, the model achieves 98% accuracy and successfully optimizes the prediction of small molecule material properties. For niche datasets, the model effectively adapts to data scarcity and noise, improving prediction accuracy by 11%.
[0147] When applying the molecular structure generation method based on the multi-scale attention mechanism provided by the present invention, it is not necessary to Figure 1 The steps are executed in the order shown. The specific execution order of the steps can be determined according to needs, and the present invention does not limit this.
[0148] The above is a molecular structure generation method based on a multi-scale attention mechanism provided by one or more embodiments of the present invention. Based on the same idea, the present invention also provides a corresponding molecular structure generation device based on a multi-scale attention mechanism, such as Figure 6 shown.
[0149] Figure 6 A schematic diagram of a molecular structure generation device based on a multi-scale attention mechanism provided by the present invention, comprising:
[0150] Construction module 601 is used to construct a generative adversarial network; the generative adversarial network includes a generator and a component constraint module; the generator includes a molecular feature extraction multi-attention module, a feature generation deep separable product convolution module and a feature generation module; the feature generation deep separable product convolution module is used to comprehensively capture the features of the molecule; the molecular feature extraction multi-attention module is used to capture the local information, global structure and chemical bond connection relationship of the molecule; the component constraint module is used to ensure that the molecular structure conforms to the given elemental composition and chemical rules.
[0151] The generation module 602 is used to obtain molecular feature information and input the molecular feature information into the generator, extract the molecular feature information through the molecular feature extraction multi-attention module to obtain a molecular feature representation, and process the molecular feature representation through the feature generation deep separable convolution module to obtain an optimized molecular feature; after inputting the optimized molecular feature into the feature generation module, a molecular structure is generated.
[0152] The correction module 603 is used to input the molecular structure into the component constraint module, correct the molecular structure, and obtain the target molecular structure.
[0153] Regarding the specific definition of a molecular structure generation device based on a multi-scale attention mechanism, please refer to the definition of a molecular structure generation method based on a multi-scale attention mechanism above, which will not be repeated here. The various modules in the above-mentioned molecular structure generation device based on a multi-scale attention mechanism can be implemented in whole or in part by software, hardware, and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the corresponding operations of the above modules.
[0154] The present invention also provides a computer-readable storage medium, which stores a computer program, which can be used to execute the above Figure 1 A molecular structure generation method based on multi-scale attention mechanism is provided.
[0155] The present invention also provides Figure 7 The structural diagram of the computer equipment shown in FIG. Figure 7 As shown in the figure, at the hardware level, the computer device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, it may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 A molecular structure generation method based on multi-scale attention mechanism is provided.
[0156] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program. 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 by the present invention can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0157] The technical features of the above embodiments can be combined arbitrarily. In order 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 the present invention.
Claims
1. A molecular structure generation method based on a multi-scale attention mechanism, characterized in that: include: Constructing a generative adversarial network; the generative adversarial network includes a generator and a component constraint module; the generator includes a molecular feature extraction multi-attention module, a feature generation deep separable convolution module, and a feature generation module; the feature generation deep separable convolution module is used to comprehensively capture the characteristics of the molecule; the molecular feature extraction multi-attention module is used to capture the local information, global structure and chemical bond connection relationship of the molecule; the component constraint module is used to ensure that the molecular structure conforms to the given elemental composition and chemical rules; Acquire molecular feature information and input the molecular feature information into a generator, perform feature extraction on the molecular feature information through the molecular feature extraction multi-attention module to obtain a molecular feature representation, process the molecular feature representation through the feature generation depthwise separable convolution module to obtain an optimized molecular feature; after inputting the optimized molecular feature into the feature generation module, generate a molecular structure; The molecular structure is input into the component constraint module, and the molecular structure is corrected to obtain a target molecular structure.
2. The method according to claim 1, wherein The molecular feature extraction multi-attention module includes a channel attention module, a spatial attention module and a self-attention module; the molecular feature extraction multi-attention module extracts features from the molecular feature information to obtain a molecular feature representation, specifically including: Inputting the molecular feature information into the channel attention module, assigning a different attention score to each channel of the molecular feature information, and obtaining a channel attention feature; each channel in the channel attention feature represents a different molecular feature; Multiplying the molecular feature information and the channel attention feature element-wise to obtain a first weighted feature; Inputting the first weighted feature into the spatial attention module for processing to obtain a spatial attention feature; Multiplying the molecular feature information and the spatial attention feature element-wise to obtain a second weighted feature; The second weighted feature is input into the self-attention module for processing to obtain the molecular feature representation.
3. The method according to claim 1, wherein The feature generation depthwise separable convolution module includes three layers of depthwise separable convolution, squeeze and excitation modules connected in series; the molecular feature representation is processed by the feature generation depthwise separable convolution module to obtain optimized molecular features, specifically including: For each layer in the feature generation depthwise separable convolution module, depthwise convolution is performed on each channel of the molecular feature representation by depthwise separable convolution; After performing the depthwise convolution, adaptively adjusting each channel through the squeeze and excitation module; After the three layers of depth-wise separable convolution and squeeze and excitation modules connected in series are processed, the output features of the squeeze and excitation module of the last layer are determined as the optimized molecular features.
4. The method according to claim 1, wherein The obtaining of molecular characteristic information specifically includes: Obtain the true characteristics of molecules; The molecular true features and Gaussian noise are processed by maximum pooling and average pooling respectively to obtain maximum pooling features and average pooling features; Performing a convolution operation on the maximum pooling feature and the average pooling feature to obtain a convolution result; The convolution result, the maximum pooling feature, and the average pooling feature are element-wise added to obtain the molecular feature information.
5. The method according to claim 1, wherein The method further comprises: After obtaining the molecular structure, the molecular structure is input into a discriminator, in which the similarity between the molecular structure and the true molecular structure is evaluated to obtain a probability value; the probability value represents whether the molecular structure is true or false; And feed back the probability value to the generator to make the generator.
6. The method according to claim 1, wherein Inputting the molecular structure into the component constraint module and correcting the molecular structure to obtain a target molecular structure specifically includes: Inputting the feature map corresponding to the molecular structure into a component constraint module, and performing a downsampling operation on the feature map through the component constraint module; After performing the downsampling operation, repeatedly performing depth-wise separable convolution and batch normalization on the feature map to obtain a multidimensional feature map; Converting the multidimensional feature map into a one-dimensional vector, and inputting the one-dimensional vector into a fully connected layer for processing to obtain a fully connected layer processing result; Converting the fully connected layer processing result into a probability distribution; the probability distribution is used to evaluate the possibility that the molecular structure belongs to the target component category; comparing the molecular structure with the target component class to identify deviations in the chemical composition of the molecular structure; The molecular structure is optimized according to the deviation to obtain the final target molecular structure.
7. A molecular structure generation device based on a multi-scale attention mechanism, characterized in that: include: A construction module for constructing a generative adversarial network; the generative adversarial network includes a generator and a component constraint module; the generator includes a molecular feature extraction multi-attention module, a feature generation deep separable convolution module, and a feature generation module; the feature generation deep separable convolution module is used to comprehensively capture the features of the molecule; the molecular feature extraction multi-attention module is used to capture the local information, global structure and chemical bond connection relationship of the molecule; the component constraint module is used to ensure that the molecular structure conforms to the given elemental composition and chemical rules; A generation module is configured to obtain molecular feature information and input the molecular feature information into a generator, perform feature extraction on the molecular feature information through the molecular feature extraction multi-attention module to obtain a molecular feature representation, process the molecular feature representation through the feature generation depthwise separable convolution module to obtain an optimized molecular feature; and generate a molecular structure after inputting the optimized molecular feature into a feature generation module; The correction module is used to input the molecular structure into the component constraint module, correct the molecular structure, and obtain the target molecular structure.
8. A computer-readable storage medium, characterized in that The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
9. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 6 when executing the program.