Three-dimensional electron density prediction method and device, equipment, storage medium and product
By mapping the scattering curve characteristics to the electron density vector through a lightweight MLP model, the problems of high computational complexity and low automation in the existing technology are solved, and efficient and automated prediction of three-dimensional electron density distribution is achieved, which is suitable for real-time analysis of ordinary computing devices.
Patent Information
- Application Number
- CN202510826798.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-19
- Publication Date
- 2025-10-17
AI Technical Summary
In the existing technology, the inversion of three-dimensional electron density through SAXS scattering curves has high computational complexity, low prediction efficiency, strong model dependence, low degree of automation, and is difficult to apply on a large scale.
A lightweight MLP model is used for three-dimensional electron density prediction. The scattering curve characteristics are mapped to the electron density vector through the trained electron density prediction model, and three-dimensional reshaping is performed to achieve end-to-end automated prediction and simplify the network structure without the need for manual physical model establishment.
It achieves efficient and automated prediction of three-dimensional electron density distribution with low computational complexity, is suitable for common computing devices, has a wide range of applications, and has strong real-time analysis capabilities.
Smart Images

Figure CN120804536A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, and in particular to a three-dimensional electron density prediction method, device, equipment, storage medium and product. BACKGROUND
[0002] With the development of biomolecular structure analysis and material science, predicting three-dimensional electron density based on SAXS (Small-Angle X-ray Scattering) curve has become a research hotspot. Electron density distribution is an important basis for understanding molecular structure and function, and is widely used in protein structure analysis, nanomaterial design and other scenarios.
[0003] In the traditional analysis of electron density method, the three-dimensional electron density is mainly inverted through the SAXS scattering curve, which mainly depends on the iterative algorithm based on the physical model (such as inverse Monte Carlo method, iterative phase retrieval method, etc.), but such method has significant limitations: (1) high computational complexity, which needs repeated iteration optimization, and a single inversion takes several hours to several days, which requires harsh computing resources; (2) strong model dependence: the inversion result is sensitive to the initial assumption model, and if the initial model deviates from the true structure, it is easy to fall into a local optimal solution; (3) frequent manual intervention: the parameters (such as scattering body shape factor, size distribution) need to be manually adjusted by domain experts, which has low automation degree and is difficult to be applied on a large scale.
[0004] Therefore, how to efficiently predict the three-dimensional electron density distribution is a problem to be solved at present. SUMMARY
[0005] The present application provides a three-dimensional electron density prediction method, device, equipment, storage medium and product, which solves the defects of high computational complexity and low prediction efficiency in the prior art for inverting three-dimensional electron density through SAXS scattering curve, and realizes efficient and automatic prediction of three-dimensional electron density distribution.
[0006] The present application provides a three-dimensional electron density prediction method, comprising: inputting the scattering curve features into a trained electron density prediction model to obtain an electron density vector output by the electron density prediction model; performing three-dimensional remodeling based on the electron density vector to obtain a three-dimensional electron density distribution; The electron density prediction model comprises an input layer, a first hidden layer, a second hidden layer and an output layer; the input layer is used to receive scattering curve features; the first hidden layer and the second hidden layer are used to perform nonlinear mapping and regularization processing of the scattering curve features from the scattering curve to the electron density, to obtain electron density potential features; and the output layer is used to map the electron density potential features to a final output space to output an electron density vector.
[0007] The three-dimensional electron density prediction method provided by the present application further comprises the following steps before training the electron density prediction model: obtaining training parameters input through a graphical user interface; the training parameters include at least one of the following: sample quantity, optimizer type, maximum iteration round number, mini-batch size, initial learning rate, learning rate adjustment strategy, execution environment, and validation patience value; estimating GPU requirement based on the training parameters; displaying the GPU requirement on the graphical user interface, so that a user optimizes the training parameters based on the GPU requirement to obtain final training parameters.
[0008] The three-dimensional electron density prediction method provided by the present application adopts the final training parameters to train the electron density prediction model, and the electron density prediction model is trained in the following manner: obtaining a sample data set; the sample data includes sample scattering curve features and corresponding sample electron density vectors; in a current iteration training process, dividing the sample data set into a training data set and a validation data set, training an electron density prediction model to be trained based on the training data set, and verifying the performance of the electron density prediction model obtained in the current iteration training based on the validation data set; when a preset training termination condition is met, obtaining a trained electron density prediction model.
[0009] The three-dimensional electron density prediction method provided by the present application comprises the following steps of obtaining a sample data set: obtaining a reference data set; the reference data includes original scattering curve data and corresponding three-dimensional electron density distribution reference data; normalizing each scattering intensity value in the original scattering curve data to obtain normalized scattering intensity values, and converting each normalized scattering intensity value into a one-dimensional feature vector to obtain sample scattering curve features; adjusting the three-dimensional electron density distribution reference data to a preset size, and normalizing each electron density value in the three-dimensional electron density distribution reference data of the preset size to obtain normalized three-dimensional electron density distribution reference data; flattening the normalized three-dimensional electron density distribution reference data to obtain a sample electron density vector corresponding to the sample scattering curve features; obtaining a sample data set based on the sample scattering curve features and the corresponding sample electron density vectors.
[0010] According to the three-dimensional electron density prediction method provided by the application, in the current iteration training process, the method further comprises: calculating the training loss, the validation loss and the validation root mean square error in the current iteration training process; real-time drawing the training loss, the validation loss and the validation root mean square error in the current iteration training process into a historical training process curve to obtain a real-time training process curve, and displaying the real-time training process curve on a graphical user interface.
[0011] According to the three-dimensional electron density prediction method provided by the application, after obtaining the trained electron density prediction model, the method further comprises: saving the trained electron density prediction model and the training index into a first preset format file, and storing the electron density vector training result output by the model in each iteration training process in a second preset format; in response to a training result import operation, importing the electron density vector training result stored in the second preset format into analysis software for visual analysis; in response to a training process query operation, displaying historical training data.
[0012] The application further provides a three-dimensional electron density prediction device, comprising: a prediction module configured to input the scattering curve features into the trained electron density prediction model to obtain an electron density vector output by the electron density prediction model; a remodeling module configured to perform three-dimensional remodeling based on the electron density vector to obtain a three-dimensional electron density distribution; The electron density prediction model comprises an input layer, a first hidden layer, a second hidden layer and an output layer; the input layer is configured to receive the scattering curve features; the first hidden layer and the second hidden layer are configured to perform nonlinear mapping and regularization processing from the scattering curve to the electron density on the scattering curve features to obtain electron density potential features; and the output layer is configured to map the electron density potential features to a final output space to output the electron density vector.
[0013] The application further provides an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the three-dimensional electron density prediction method according to any one of the above-mentioned methods when executing the computer program.
[0014] The application further provides a non-transitory computer readable storage medium having a computer program stored thereon, wherein the computer program is executable by a processor to implement the three-dimensional electron density prediction method according to any one of the above-mentioned methods.
[0015] The application further provides a computer program product comprising a computer program which, when executed by a processor, implements the three-dimensional electron density prediction method according to any one of the above.
[0016] The three-dimensional electron density prediction method, device, equipment, storage medium and product provided by the application can obtain an electron density vector output by an electron density prediction model by inputting scattering curve features into the trained electron density prediction model, and can obtain a three-dimensional electron density distribution by three-dimensional remodeling based on the electron density vector, so that a physical model does not need to be established manually, efficient mapping from a scattering curve to electron density can be realized by using a simplified network structure of an MLP model, and three-dimensional density can be automatically predicted by inputting one-dimensional scattering curve features, so that the three-dimensional electron density distribution can be efficiently and automatically predicted; and the electron density prediction model has low computational complexity, can be efficiently run on a common computing device to realize real-time analysis, and has a wider application range. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description are some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative labor.
[0018] Figure 1 is one of the flowcharts of the three-dimensional electron density prediction method provided by the embodiments of the application.
[0019] Figure 2 is a schematic diagram of a prediction interface provided by the embodiments of the application.
[0020] Figure 3 is a network structure schematic diagram of an electron density prediction model provided by the embodiments of the application.
[0021] Figure 4 is a schematic diagram of a training interface provided by the embodiments of the application.
[0022] Figure 5 is a schematic diagram of a training process curve provided by the embodiments of the application.
[0023] Figure 6 is another flowchart of the three-dimensional electron density prediction method provided by the embodiments of the application.
[0024] Figure 7 is a structural schematic diagram of the three-dimensional electron density prediction device provided by the embodiments of the application.
[0025] Figure 8 is a structural schematic diagram of the electronic device provided by the embodiments of the application. DETAILED DESCRIPTION
[0026] In order to make the objects, technical solutions and advantages of the present application clearer, the technical solutions in the present application will be described clearly and completely below with reference to the drawings in the present application. Obviously, the described embodiments are only a part of embodiments of the present application, rather than all embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0027] In the description of the embodiments of the present application, the terms “comprising”, “containing” or any other variants thereof are intended to cover the non-exclusive inclusion, so that the process, method, article or equipment including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or equipment. The specific meaning of the above terms in the present application can be understood by those of ordinary skill in the art according to specific circumstances.
[0028] Figure 1 is a flowchart of the three-dimensional electron density prediction method provided by the embodiments of the present application. With reference to Figure 1 , the embodiments of the present application provide a three-dimensional electron density prediction method, which can specifically include the following steps: Step 101, inputting the scattering curve features into a trained electron density prediction model to obtain an electron density vector output by the electron density prediction model; wherein the electron density prediction model includes an input layer, a first hidden layer, a second hidden layer and an output layer; the input layer is used to receive the scattering curve features; the first hidden layer and the second hidden layer are used to perform nonlinear mapping and regularization processing from the scattering curve to the electron density on the scattering curve features to obtain electron density potential features; and the output layer is used to map the electron density potential features to a final output space to output the electron density vector.
[0029] It should be noted that the execution subject of the three-dimensional electron density prediction method provided in the embodiments of the present application can be an electronic device, a component in the electronic device, an integrated circuit, or a chip. The electronic device can be a mobile electronic device or a non-mobile electronic device. Illustratively, the mobile electronic device can be a mobile phone, a tablet computer, a notebook computer, a palm computer, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), and the like, and the non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine, or a self-service machine, and the like, and the embodiments of the present application do not make a specific limitation thereon. The embodiments of the present application are described below with the server as the execution subject.
[0030] Figure 2 is a schematic diagram of a prediction interface provided in the embodiments of the present application. Referring to Figure 2 In some embodiments, the user can load the trained electron density prediction model through the prediction interface, select the input of the scattering curve data to be predicted, and select the prediction result output path.
[0031] The prediction result output path can refer to the file storage path of the prediction result. The trained electron density prediction model can be saved in the.mat format, and the scattering curve data to be predicted can be saved in the.dat format.
[0032] In some embodiments, the scattering curve is drawn with the scattering vector as the horizontal coordinate and the scattering intensity value as the vertical coordinate, and the scattering curve data can include a plurality of scattering intensity values corresponding to the respective scattering vectors. The scattering curve data to be predicted can be read, each scattering intensity value in the scattering curve data to be predicted can be normalized to obtain a normalized scattering intensity value, and the normalized scattering intensity value can be converted into a one-dimensional feature vector (XNew) to obtain the scattering curve feature. The embodiments of the present application have strong data adaptability, and by normalizing and dynamically adjusting the data, the scattering curve data of different resolutions and formats can be adapted, the flexibility of data processing is improved, and the versatility of predicting the three-dimensional electron density distribution for diversified scattering curve data is enhanced.
[0033] As an example, the scattering curve feature can be expressed as , ,… ], is the normalized scattering intensity value corresponding to the nth-dimensional scattering vector Q. n is the data dimension, which can be determined according to the data resolution. For example, n can be 1504, that is, the scattering curve feature is composed of 1504-dimensional scattering intensity values.
[0034] In some embodiments, the electron density prediction model can be a MLP (Multilayer Perceptron) model. By inputting the scattering curve feature into the trained MLP model, an electron density vector (YPredNewFlat) can be obtained, and reshaped into a three-dimensional electron density distribution (64x64x64). The three-dimensional electron density distribution prediction result can be saved as a.mrc format file, and the pixel size (PixelSize, for example, 50) is recorded.
[0035] The electron density vector can be a one-dimensional array in which each electron density value is arranged in a certain order. For example, the electron density vector can be represented as [Y0, Y1, Y2, …, Yn-1], where n is the data dimension, which can be determined by the neuron dimension of the output layer of the model. , , …, ] n is the data dimension, which can be determined by the neuron dimension of the output layer of the model.
[0036] In some embodiments, when displaying the processing status (such as “Processing file 1 of N”), success or error information can be reported.
[0037] Figure 3 is a network structure schematic diagram of the electron density prediction model provided by the embodiments of the present application. Referring to Figure 3 In some embodiments, the electron density prediction model can include an input layer, a first hidden layer, a second hidden layer, and an output layer.
[0038] The input layer can be used to receive the scattering curve feature. The first hidden layer can include a first fully connected layer, a first ReLU activation layer, and a first Dropout regularization layer, and the second hidden layer can include a second fully connected layer, a second ReLU activation layer, and a second Dropout regularization layer. Through the multi-layer fully connected network, the nonlinear mapping relationship between the scattering curve and the electron density can be learned, the feature expression capability can be enhanced through the use of the ReLU activation function, and the overfitting can be prevented through Dropout and L2 regularization, so as to realize the nonlinear mapping and regularization processing of the scattering curve feature from the scattering curve to the electron density, and obtain the electron density latent feature. The output layer can include a third fully connected layer and a regression layer. The electron density latent feature is mapped to the final output space through the fully connected layer, and a plurality of dimensions of electron density prediction values are output, and then the electron density vector prediction result (i.e., high-dimensional electron density data) is output through the regression layer.
[0039] In some embodiments, the dropout probability of the Dropout regularization layer can be set to 0.3, i.e., there is a 30% probability that the output of each neuron is set to 0 (i.e., there is a 30% probability of being discarded), thereby preventing overfitting.
[0040] In some embodiments, to prevent overfitting, an L2 regularization factor (1e-4) can be set for each fully connected layer.
[0041] In some embodiments, the first fully connected layer can contain 512 neurons, the second fully connected layer can contain 256 neurons, and the third fully connected layer can contain 262144 (i.e., 64x64x64, corresponding to the dimension of the flattened three-dimensional electron density) neurons.
[0042] The embodiments of the present application implement electron density prediction based on a lightweight MLP network. The simplified network structure of the MLP model can achieve efficient mapping of scattering curve features to three-dimensional electron density, without the need for manual establishment of a physical model. The one-dimensional scattering curve is directly inputted to output the predicted three-dimensional electron density, realizing end-to-end three-dimensional electron density prediction automation.
[0043] The electron density prediction model based on the lightweight MLP network provided by the embodiments of the present application has cross-material universality and can be migrated to different material systems, and is universally applicable to electron density distribution prediction under various material systems.
[0044] Furthermore, compared with the traditional CPU (Central Processing Unit, CPU) parallel computing iterative algorithm, the lightweight MLP network used for three-dimensional electron density prediction in the present application has lower computational complexity, can significantly reduce the demand for computing resources, and is suitable for ordinary PC (Personal Computer, PC) or small and medium-sized GPU (Graphics Processing Unit, GPU) operation. When predicting on a small-sized GPU Nvidia Quadro P600, the single prediction time is less than 1 second, which is suitable for real-time analysis.
[0045] Step 102, based on the electron density vector, three-dimensional remodeling is performed to obtain a three-dimensional electron density distribution.
[0046] In some embodiments, the reshape function can be used to reshape the electron density vector into three-dimensional volume data (64x64x64), thereby obtaining the three-dimensional electron density distribution.
[0047] The embodiment of the present application receives normalized scattering curve features by using the trained MLP model, outputs flattened electron density vectors, and then restores the three-dimensional electron density distribution structure through reshaping and saves it in a standard format, thereby realizing end-to-end three-dimensional electron density prediction automation.
[0048] The embodiment of the present application inputs scattering curve features into the trained electron density prediction model, obtains the electron density vector output by the electron density prediction model, and performs three-dimensional reshaping based on the electron density vector to obtain the three-dimensional electron density distribution, thereby realizing efficient mapping from scattering curve to electron density without manually establishing a physical model, using the simplified network structure of the MLP model, automatically predicting three-dimensional density from one-dimensional scattering curve features, and thereby efficiently and automatically predicting the three-dimensional electron density distribution.
[0049] In an alternative embodiment, before training the electron density prediction model, the method can further include: Step S11, obtaining training parameters input through a graphical user interface; the training parameters include at least one of sample quantity, optimizer type, maximum iteration number, small batch size, initial learning rate, learning rate adjustment strategy, execution environment, and validation patience value; Step S12, estimating video memory requirement based on the training parameters; Step S13, displaying the video memory requirement on the graphical user interface, so that the user adjusts and optimizes the training parameters based on the video memory requirement to obtain final training parameters.
[0050] Figure 4 is a schematic diagram of the training interface provided by the embodiment of the present application. Referring to Figure 4 In some embodiments, before model training, the user can select a folder containing original scattering curve data (saved in.dat format) and a folder containing three-dimensional electron density distribution reference data (saved in.mrc format) through a graphical user interface, and select a saving path for the trained electron density prediction model.
[0051] The user can also set multiple training parameters through the graphical user interface. The training parameters can include the number of input samples (numSamples), the training set ratio (trainRatio, for example, 80%), and the validation set ratio (valRatio, for example, 20%), and ensure that the sum of the training set ratio and the validation set ratio is 100% to avoid data allocation errors. The training parameters can also include the optimizer type (adam or sgd, sgd supports the momentum parameter Momentum), the maximum number of iteration rounds (MaxEpochs, for example, which can be set to 500), the mini-batch size (MiniBatchSize, for example, which can be set to 4), the initial learning rate (InitialLearnRate, for example, which can be set to 0.001), the learning rate scheduling strategy (LearnRateSchedule, such as piecewise, in combination with DropFactor and DropPeriod), the execution environment (ExecutionEnvironment, for example, auto, cpu, or gpu), the validation patience value (ValidationPatience, for example, 10), and the like.
[0052] In the embodiments of the present application, the video memory requirement can be estimated according to the training parameters input by the user through the graphical user interface, and the video memory requirement is displayed to the user through the graphical user interface, so that the user can dynamically adjust the training parameters until the re-estimated video memory requirement meets the preset video memory requirement. The video memory requirement estimation method can be as follows: ; wherein, is the estimated video memory requirement, is the number of samples, is the maximum number of iteration rounds, is the mini-batch size.
[0053] In some embodiments, in the case of selecting the sgd optimizer, the momentum parameter (Momentum, for example, 0.9) can be enabled to enhance the stability of gradient descent.
[0054] In some embodiments, the graphical user interface can respond to the user's training parameter input operation through a callback function to update the state and video memory estimation in real time, thereby ensuring intuitive and efficient operation.
[0055] The embodiments of the present application support dynamic adjustment of training parameters and visualization of video memory estimation through integrated graphical user interfaces, so that non-professional users can quickly start predicting three-dimensional electron density distribution, have high user friendliness, and are beneficial to improving application efficiency.
[0056] The embodiment of the present application can realize efficient video memory management by dynamic video memory estimation and training parameter optimization, which is beneficial to avoid memory overflow and ensure the stability and efficiency of the model training and prediction process.
[0057] In an optional embodiment, the electron density prediction model is trained by using the final training parameters, and the electron density prediction model is trained by the following method: In step S21, a sample data set is obtained; the sample data includes sample scattering curve features and corresponding sample electron density vectors; In step S22, in the current iteration training process, the sample data set is divided into a training data set and a validation data set, the training electron density prediction model is trained based on the training data set, and the performance of the electron density prediction model obtained by the current iteration training is verified based on the validation data set. In step S23, when the preset training termination condition is met, a trained electron density prediction model is obtained.
[0058] In some embodiments, after obtaining the final training parameters, model training can be started, and the user-set optimizer and the final training parameters are used to update the weight parameters of the training electron density prediction model through small batch gradient descent.
[0059] In some embodiments, the sample data set can include multiple sample data, each sample data can include sample scattering curve features and corresponding sample electron density vectors (sample electron density vectors as labels), thereby being used for model training. In the current iteration training process, the sample data set can be divided into a training data set (XTrain, YTrain) and a validation data set (XVal, YVal) according to a preset training set proportion and a preset validation set proportion by using randperm, thereby training the training electron density prediction model based on the training data set, and verifying the performance of the electron density prediction model after the current iteration training based on the validation data set, thereby obtaining a trained electron density prediction model by continuous training iteration when the preset training termination condition (for example, the iteration training round number reaches the maximum iteration round number) is met, and saving the trained electron density prediction model to the specified saving path in the final training parameters.
[0060] In some embodiments, if the validation loss of the current iteration training round continuously does not decrease for a number of times reaching the set value of the validation patience value (ValidationPatience) in the training parameters, the training is stopped in advance to prevent overfitting.
[0061] The embodiments of the present invention utilize a training parameter optimization mechanism to perform model training, including learning rate scheduling, Dropout regularization, and verification patience strategy, which is beneficial to improving the model generalization ability and training efficiency.
[0062] The embodiment of the present invention is based on the Adam or SGD optimizer, and can minimize the mean square error loss function through small-batch gradient descent; dynamically adjust the learning rate through learning rate scheduling (such as piecewise) to improve the convergence speed; and ensure the generalization ability of the model through the verification mechanism.
[0063] In an optional embodiment, obtaining the sample data set may specifically include: Step S211, obtaining a reference data set; the reference data includes original scattering curve data and corresponding three-dimensional electron density distribution reference data; Step S212, normalizing each scattering intensity value in the original scattering curve data to obtain a normalized scattering intensity value, and converting each normalized scattering intensity value into a one-dimensional feature vector to obtain a sample scattering curve feature; Step S213, adjusting the three-dimensional electron density distribution reference data to a preset size, and normalizing each electron density value in the three-dimensional electron density distribution reference data of the preset size to obtain normalized three-dimensional electron density distribution reference data; Step S214, flattening the normalized three-dimensional electron density distribution reference data to obtain a sample electron density vector corresponding to the sample scattering curve feature; Step S215 : obtaining a sample data set based on the sample scattering curve characteristics and the corresponding sample electron density vector.
[0064] In an embodiment of the present invention, before performing model training, a reference data set may be obtained, and each reference data in the reference data set may be preprocessed to obtain a sample data set.
[0065] Continue to refer to Figure 4 In some embodiments, a user can import a reference dataset by selecting a folder containing raw scattering curve data (saved in .dat format) and a folder containing three-dimensional electron density distribution reference data (saved in .mrc format) through a graphical user interface. The raw scattering curve data can be read, and all scattering intensity values in the raw scattering curve data can be extracted and normalized to ensure uniform data scaling. The scattering intensity value normalization formula can be as follows: ; in, is the scattering intensity value corresponding to the scattering vector Q, is the maximum value among multiple scattering intensity values, is the scattering intensity value corresponding to the normalized scattering vector Q.
[0066] In some embodiments, the three-dimensional electron density distribution reference data can be read, and the three-dimensional electron density distribution reference data can be adjusted to a preset size to obtain three-dimensional electron density distribution reference data of the preset size. For example, assuming that the preset size is 64x64x64, the three-dimensional electron density distribution space can be divided into 64x64x64 grids, each spatial grid having a respective electron density value, i.e., having 64x64x64 data points.
[0067] The three-dimensional electron density distribution reference data of the preset size can be normalized to ensure uniform data scale. The three-dimensional electron density distribution reference data normalization formula can be as follows: ; wherein, is the respective electron density value of the spatial grid of the preset size, is the maximum value of the respective electron density values of the plurality of spatial grids, is the respective normalized electron density value of the spatial grid.
[0068] In some embodiments, the Reshape function can be used to flatten the normalized three-dimensional electron density distribution reference data according to a preset grid mapping order, and after flattening, a sample electron density vector (the sample electron density vector as a label annotation) with a length of 64x64x64 can be obtained. The grid mapping order information can be recorded in the Reshape function.
[0069] As an example, the sample electron density vector can be represented as , , …, n can be 262144 (i.e., 64x64x64); may be the normalized electron density value corresponding to the spatial grid at [1, 1, 1], may be the normalized electron density value corresponding to the spatial grid at [1, 1, 2], and so on, may be the normalized electron density value corresponding to the spatial grid at [64, 64, 64].
[0070] In some embodiments, when constructing the sample data set based on the sample scattering curve features and the corresponding sample electron density vectors (the sample electron density vectors are labeled as tags), all sample electron density vectors can be summarized into a two-dimensional matrix, and model training can be performed based on all sample scattering curve features and the two-dimensional matrix, that is, the preprocessed scattering curve data can be converted into a one-dimensional feature vector (X), and the electron density data can be flattened into a two-dimensional matrix (YFlat) for subsequent model training. Each column of the two-dimensional matrix can correspond to a sample electron density vector, the number of columns of the two-dimensional matrix is determined by the number of sample electron density vectors, and the number of rows of the two-dimensional matrix is determined by the data length of the sample electron density vectors.
[0071] The embodiment of the present application can adapt diversified scattering curve data by normalizing the original scattering curve data before model training, and ensure the consistency of model input. By performing data preprocessing such as normalization and size adjustment on the reference data to obtain sample data for model training based on the sample data, the format of model input data (scattering curve) and model output data (electron density) can be unified, and the difficulty of model training can be reduced.
[0072] In an alternative embodiment, during the current iteration training process, the method can further include: Step S31, calculating the training loss, validation loss and validation root mean square error in the current iteration training process; Step S32, real-time plotting the training loss, validation loss and validation root mean square error in the current iteration training process into the historical training process curve to obtain a real-time training process curve, and displaying the real-time training process curve on the graphical user interface.
[0073] In some embodiments, after starting the model training, a user-specified optimizer and final training parameters can be used to update the model weights through small batch gradient descent. Validation can be performed once in each iteration training process, and the training loss (TrainingLoss), validation loss (ValidationLoss) and validation root mean square error (Root Mean Square Error, RMSE) in the current iteration training process can be calculated.
[0074] In some embodiments, by inputting the sample scattering curve features into the to-be-trained electron density prediction model, the electron density vector training result output by the to-be-trained electron density prediction model can be obtained, and the training loss between the calculated sample electron density vector and the electron density vector training result can be calculated.
[0075] Figure 5is a schematic diagram of a training process curve provided by an embodiment of the present application. In some embodiments, the historical training process curve can include a training loss change curve, a validation loss change curve, and a validation root mean square error change curve. The training loss in the current iteration training process can be plotted in real time into the training loss change curve, the validation loss in the current iteration training process can be plotted in real time into the validation loss change curve, and the validation root mean square error in the current iteration training process can be plotted in real time into the validation root mean square error change curve, to obtain a real-time training process curve and display the real-time training process curve on a graphical user interface, thereby helping the user to monitor the model convergence.
[0076] The embodiment of the present application supports real-time visualization of the training process through an integrated intuitive graphical user interface, thereby enabling real-time monitoring of the training process and enabling non-professional users to quickly start predicting three-dimensional electron density distribution, thereby improving application efficiency.
[0077] The embodiment of the present application can achieve real-time monitoring and feedback through real-time updating of the training process visualization and prediction state, thereby helping the user to optimize the model or troubleshoot errors in a timely manner.
[0078] In an alternative embodiment, after obtaining the trained electron density prediction model, the method can further include: Step S41, saving the trained electron density prediction model and the training indicators into a first preset format file, and storing the electron density vector training results output by the model in each iteration training process in a second preset format; Step S42, in response to a training result import operation, importing the electron density vector training results stored in the second preset format into analysis software for visualization analysis; Step S43, in response to a training process query operation, displaying historical training data.
[0079] In some embodiments, after the model training is completed, the trained electron density prediction model can be saved as a first preset format (.mat format) file, and the training indicators (such as the number of iterations, loss, and RMSE) can be saved as a metricsData.mat file; the electron density vector training results output in each iteration training process can also be stored in a second preset format (.mrc format), thereby facilitating the user to import professional software (such as Chimera) for visualization analysis.
[0080] In some embodiments, in response to a training result import operation performed by the user, the electron density vector training results output by the model in each iteration training process and saved in the.mrc format can be imported into professional software for visualization analysis.
[0081] In some embodiments, the historical training data can be displayed on the graphical user interface in response to a training process query operation, thereby supporting user query of historical training and prediction records and improving data management efficiency.
[0082] The model prediction result is saved in the.mrc format in the embodiments of the present application, so that standardized output can be realized, mainstream analysis software can be compatible, and subsequent research and verification can be facilitated.
[0083] To make the skilled in the art better understand the embodiments of the present application, the embodiments of the present application are described below through a specific embodiment.
[0084] Figure 6 is a second flowchart of the three-dimensional electron density prediction method provided by the embodiments of the present application. Refer to Figure 6 In a specific embodiment, the three-dimensional electron density prediction method provided by the embodiments of the present application can specifically include the following steps: Step 1, data input and preprocessing.
[0085] Step 1-1, the user selects a folder containing scattering curve data (.dat format) and reference electron density data (.mrc format) through a graphical user interface.
[0086] Step 1-2, the system reads the scattering curve data, extracts the intensity value (I Q ) and performs normalization processing to ensure uniform data scale.
[0087] Step 1-3, the system reads the reference electron density data, adjusts to a uniform size (64x64x64), and performs normalization processing.
[0088] Step 1-4, the preprocessed scattering curve data is converted into a one-dimensional feature vector (X), and the electron density data is flattened into a two-dimensional matrix (YFlat) for subsequent model training.
[0089] Step 2, training set and validation set division.
[0090] Step 2-1, the user inputs the sample number (numSamples), the training set ratio (trainRatio, such as 80%) and the validation set ratio (valRatio, such as 20%).
[0091] Step 2-2, the system divides the data into a training set (XTrain, YTrain) and a validation set (XVal, YVal) by randomly shuffling the index (randperm).
[0092] Step 2-3, ensure that the training set and validation set ratio is 100% to avoid data allocation errors.
[0093] Step3、Multi-Layer Perceptron model construction.
[0094] Step3-1、System defines the MLP network structure, including: Input layer: receives the scattering curve features (dimension about 1504, depending on the data resolution).
[0095] Hidden layer 1: 512 nodes, using ReLU activation function, adding 0.3 Dropout to prevent overfitting.
[0096] Hidden layer 2: 256 nodes, using ReLU activation function, adding 0.3 Dropout.
[0097] Output layer: 262144 nodes (corresponding to the flattened dimension of 64x64x64 electron density), using regression layer to output the prediction results.
[0098] Step3-2、To prevent overfitting, L2 regularization factor (1e-4) is set for each fully connected layer.
[0099] Step4、Training parameter setting and optimization.
[0100] Step4-1、User sets the training parameters through the graphical user interface, including: Optimizer type (adam or sgd, sgd supports momentum parameter Momentum); maximum iteration rounds (MaxEpochs, such as 500); small batch size (MiniBatchSize, such as 4); initial learning rate (InitialLearnRate, such as 0.001); learning rate scheduling strategy (LearnRateSchedule, such as piecewise, combined with DropFactor and DropPeriod); execution environment (ExecutionEnvironment, such as auto, cpu or gpu); validation patience value (ValidationPatience, such as 10).
[0101] Step4-2、System estimates the video memory requirement according to the parameters and displays it to the user.
[0102] Step4-3、If you choose sgd optimizer, the system enables momentum parameter (Momentum, such as 0.9) to enhance the stability of gradient descent.
[0103] Step5、Model training and visualization.
[0104] Step5-1、System starts training, using the optimizer and parameters specified by the user to update the network weights through small batch gradient descent.
[0105] Step5-2, Validate once per iteration, calculate Training Loss, Validation Loss, and Validation Root Mean Squared Error (RMSE).
[0106] Step5-3, System real-time plots training process curves, including Training Loss, Validation Loss, and RMSE, to help users monitor model convergence.
[0107] Step5-4, If Validation Loss does not decrease consecutively for a number of times equal to ValidationPatience, the system stops training early to prevent overfitting.
[0108] Step6, Model Prediction.
[0109] Step6-1, User loads trained model (.mat format), selects input scattering curve data (.dat format), and chooses output path through the prediction interface.
[0110] Step6-2, System performs the following operations for each input file: Reads scattering curve, normalizes, and converts to one-dimensional vector (XNew).
[0111] Uses MLP model to predict electron density (YPredNewFlat) and reshapes to three-dimensional volume data (64x64x64).
[0112] Saves prediction results as.mrc format file, records pixel size (PixelSize, e.g., 50).
[0113] Step6-3, System displays processing status (e.g., "Processing file 1 of N") and reports success or error information.
[0114] Step7, Result Saving and Management.
[0115] Step7-1, After training, system saves model as.mat file and training metrics (number of iterations, loss, RMSE) as metricsData.mat file.
[0116] Step7-2, Prediction results are stored in.mrc format for easy import into professional software (e.g., Chimera) for visual analysis.
[0117] Step7-3, System supports user queries for historical training and prediction records, improving data management efficiency.
[0118] The present application breaks through the technical bottlenecks through the following innovations: (1) One-dimensional signal special network design: MLP directly processes one-dimensional scattering curves, avoiding information loss in data format conversion; (2) Dynamic regularization mechanism: introducing Dropout layer and L2 weight decay effectively suppresses overfitting and improves model generalization ability; (3) Standardized preprocessing procedure: scattering curve intensity normalization and three-dimensional density resolution unification ensure input data consistency; (4) Efficient resource utilization: supporting GPU acceleration and batch prediction, single sample inference time is less than 1 second, and the present application is more than 100 times more efficient than traditional iterative phase retrieval algorithms because it does not need to iterate Fourier transform; (5) Real-time visual progress in training process: real-time calculation of Loss and RMSE and output.
[0119] The three-dimensional electron density prediction device provided by the present application is described below, and the three-dimensional electron density prediction device described below can be correspondingly referred to the three-dimensional electron density prediction method described above.
[0120] Figure 7 FIG. 1 is a structural schematic diagram of the three-dimensional electron density prediction device provided by the present application. Referring to FIG. 1, Figure 7 The present application provides a three-dimensional electron density prediction device, which can specifically include the following modules: The prediction module 710 is configured to input the scattering curve feature into the trained electron density prediction model to obtain an electron density vector output by the electron density prediction model; The remodeling module 720 is configured to perform three-dimensional remodeling based on the electron density vector to obtain a three-dimensional electron density distribution. The electron density prediction model includes an input layer, a first hidden layer, a second hidden layer and an output layer; the input layer is configured to receive a scattering curve feature; the first hidden layer and the second hidden layer are configured to perform nonlinear mapping and regularization processing from the scattering curve to the electron density on the scattering curve feature to obtain an electron density latent feature; and the output layer is configured to map the electron density latent feature to a final output space to output an electron density vector.
[0121] The present application inputs the scattering curve feature into the trained electron density prediction model to obtain an electron density vector output by the electron density prediction model, and performs three-dimensional remodeling based on the electron density vector to obtain a three-dimensional electron density distribution, so that a physical model does not need to be established manually, and the MLP model can realize efficient mapping from the scattering curve to the electron density by using the simplified network structure, and the three-dimensional density can be automatically predicted by inputting the one-dimensional scattering curve feature, so that the three-dimensional electron density distribution can be efficiently and automatically predicted; and the calculation complexity of the electron density prediction model in the present application is low, which can be efficiently run on ordinary computing devices to realize real-time analysis, and the application scope is wider.
[0122] Figure 8 An example of a physical structure diagram of an electronic device is shown below. Figure 8 As shown, the electronic device may include: a processor 810, a communications interface 820, a memory 830, and a communications bus 840, wherein the processor 810, the communications interface 820, and the memory 830 communicate with each other via the communications bus 840. The processor 810 may call logic instructions in the memory 830 to execute a three-dimensional electron density prediction method, which includes: inputting scattering curve features into a trained electron density prediction model to obtain an electron density vector output by the electron density prediction model; performing three-dimensional reconstruction based on the electron density vector to obtain a three-dimensional electron density distribution; wherein the electron density prediction model includes an input layer, a first hidden layer, a second hidden layer, and an output layer; the input layer is used to receive scattering curve features; the first hidden layer and the second hidden layer are used to perform nonlinear mapping and regularization processing from the scattering curve features to electron density to obtain electron density potential features; the output layer is used to map the electron density potential features to a final output space and output an electron density vector.
[0123] Furthermore, the logic instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product, stored in a storage medium, includes instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.
[0124] In another aspect, the present application also provides a computer program product comprising a computer program, which can be stored on a non-transitory computer readable storage medium, and the computer program can be executed by a processor to enable a computer to perform the three-dimensional electron density prediction method provided by the above-mentioned methods, which comprises: inputting the scattering curve features into a trained electron density prediction model to obtain an electron density vector output by the electron density prediction model; and performing three-dimensional remodeling based on the electron density vector to obtain a three-dimensional electron density distribution; wherein the electron density prediction model comprises an input layer, a first hidden layer, a second hidden layer, and an output layer; the input layer is configured to receive the scattering curve features; the first hidden layer and the second hidden layer are configured to perform nonlinear mapping and regularization processing from the scattering curve to the electron density on the scattering curve features to obtain electron density latent features; and the output layer is configured to map the electron density latent features to a final output space to output the electron density vector.
[0125] In another aspect, the present application also provides a non-transitory computer readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a three-dimensional electron density prediction method provided by the above-mentioned methods, which comprises: inputting the scattering curve features into a trained electron density prediction model to obtain an electron density vector output by the electron density prediction model; and performing three-dimensional remodeling based on the electron density vector to obtain a three-dimensional electron density distribution; wherein the electron density prediction model comprises an input layer, a first hidden layer, a second hidden layer, and an output layer; the input layer is configured to receive the scattering curve features; the first hidden layer and the second hidden layer are configured to perform nonlinear mapping and regularization processing from the scattering curve to the electron density on the scattering curve features to obtain electron density latent features; and the output layer is configured to map the electron density latent features to a final output space to output the electron density vector.
[0126] The apparatus embodiments described above are merely illustrative, wherein the units shown as separate components can or can not be physically separate, and the components shown as units can or can not be physical units, i.e., they can be located in one place, or distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the present embodiment according to actual needs. Those skilled in the art can understand and implement it without creative labor.
[0127] Those skilled in the art can clearly understand the technical solutions of the various embodiments from the above description of the embodiments, and the various embodiments can be implemented by means of software with the necessary general hardware platforms, and of course, can also be implemented by hardware. Based on such understanding, the above technical solutions, essentially or in other words, the part of the prior art that makes a contribution, can be embodied in the form of a software product, which can be stored in a computer readable storage medium, such as a ROM / RAM, a magnetic disk, an optical disk, and the like, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0128] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application, and not to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing embodiments, or make equivalent replacement for some technical features therein; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A three-dimensional electron density prediction method, characterized in that: include: Inputting the scattering curve characteristics into a trained electron density prediction model to obtain an electron density vector output by the electron density prediction model; Performing three-dimensional reshaping based on the electron density vector to obtain a three-dimensional electron density distribution; The electron density prediction model includes an input layer, a first hidden layer, a second hidden layer and an output layer; the input layer is used to receive scattering curve features; the first hidden layer and the second hidden layer are used to perform nonlinear mapping and regularization processing on the scattering curve features from the scattering curve to the electron density to obtain the electron density potential features; the output layer is used to map the electron density potential features to the final output space and output the electron density vector.
2. The three-dimensional electron density prediction method according to claim 1, characterized in that: Before training the electron density prediction model, the method further includes: Obtaining training parameters input through a graphical user interface; the training parameters include at least one of the number of samples, optimizer type, maximum number of iterations, mini-batch size, initial learning rate, learning rate adjustment strategy, execution environment, and verification patience value; estimating video memory requirements based on the training parameters; The video memory requirement is displayed on the graphical user interface, so that the user can adjust and optimize the training parameters based on the video memory requirement to obtain final training parameters.
3. The three-dimensional electron density prediction method according to claim 2, characterized in that: The electron density prediction model is trained using the final training parameters, and the electron density prediction model is trained in the following manner: Acquire a sample data set; the sample data includes a sample scattering curve characteristic and a corresponding sample electron density vector; In the current iterative training process, the sample data set is divided into a training data set and a validation data set, the electron density prediction model to be trained is trained based on the training data set, and the performance of the electron density prediction model obtained by the current iterative training is verified based on the validation data set; When the preset training termination conditions are met, a trained electron density prediction model is obtained.
4. The method according to claim 3, characterized in that The obtaining of the sample data set includes: Acquire a reference data set; the reference data includes original scattering curve data and corresponding three-dimensional electron density distribution reference data; Normalizing each scattering intensity value in the original scattering curve data to obtain a normalized scattering intensity value, and converting each normalized scattering intensity value into a one-dimensional feature vector to obtain a sample scattering curve feature; Adjusting the three-dimensional electron density distribution reference data to a preset size, and normalizing each electron density value in the three-dimensional electron density distribution reference data of the preset size to obtain normalized three-dimensional electron density distribution reference data; Flattening the normalized three-dimensional electron density distribution reference data to obtain a sample electron density vector corresponding to the sample scattering curve feature; A sample data set is obtained based on the sample scattering curve characteristics and the corresponding sample electron density vector.
5. The three-dimensional electron density prediction method according to claim 3, characterized in that: During the current iterative training process, the method further includes: Calculate the training loss, validation loss, and validation root mean square error during the current iterative training process; The training loss, validation loss, and validation root mean square error in the current iterative training process are plotted in real time onto the historical training process curve to obtain a real-time training process curve, and the real-time training process curve is displayed on a graphical user interface.
6. The three-dimensional electron density prediction method according to claim 3, characterized in that: After obtaining the trained electron density prediction model, the method further includes: Saving the trained electron density prediction model and training indicators as a file in a first preset format, and storing the electron density vector training results output by the model during each iterative training process in a second preset format; In response to the training result importing operation, the electron density vector training result stored in the second preset format is imported into the analysis software for visual analysis; In response to a training process query operation, historical training data is displayed.
7. A three-dimensional electron density prediction device, characterized in that: include: A prediction module, configured to input the scattering curve characteristics into a trained electron density prediction model to obtain an electron density vector output by the electron density prediction model; A reshaping module, configured to perform three-dimensional reshaping based on the electron density vector to obtain a three-dimensional electron density distribution; The electron density prediction model includes an input layer, a first hidden layer, a second hidden layer and an output layer; the input layer is used to receive scattering curve features; the first hidden layer and the second hidden layer are used to perform nonlinear mapping and regularization processing on the scattering curve features from the scattering curve to the electron density to obtain the electron density potential features; the output layer is used to map the electron density potential features to the final output space and output the electron density vector.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the three-dimensional electron density prediction method according to any one of claims 1 to 6 is implemented.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the three-dimensional electron density prediction method according to any one of claims 1 to 6 is implemented.
10. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the three-dimensional electron density prediction method according to any one of claims 1 to 6 is implemented.