Drug quality intelligent detection method based on deep learning
By using deep learning methods for drug quality testing, spatiotemporal alignment and feature fusion of multi-source heterogeneous data in the drug production process have been achieved, solving the problems of insufficient detection accuracy and reliability, and improving the accuracy and credibility of drug quality testing.
Patent Information
- Application Number
- CN202511178222.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-22
- Publication Date
- 2025-11-21
AI Technical Summary
Existing drug quality testing methods suffer from low detection accuracy and insufficient reliability of test results. In particular, they fail to effectively integrate the synergistic characteristics of temporal evolution and spatial distribution during the drug production process, and neglect the quantification of uncertainty and risk probability modeling of test results.
Using a deep learning-based approach, a quality spatiotemporal interaction matrix is generated by collecting drug production datasets, performing spatiotemporal alignment and multi-scale feature extraction, and then using a spatiotemporal joint attention model for feature transformation and a Bayesian decision engine for probability distribution modeling. Finally, a drug quality score is generated and encrypted for storage.
It significantly improves the accuracy and reliability of drug quality testing, and enhances the risk perception capability and decision reliability of test results through multi-scale feature fusion and probability distribution modeling.
Smart Images

Figure CN120998400A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of intelligent technology in the pharmaceutical industry, and particularly to a drug quality intelligent detection method based on deep learning. BACKGROUND
[0002] With the rapid development of the pharmaceutical industry and the continuous improvement of the intelligent level, drug quality detection technology is undergoing profound changes from traditional methods to automation and intelligence. Traditional drug quality detection mainly relies on manual sampling, laboratory chemical analysis and physical testing. In recent years, deep learning technology has been widely used in drug quality detection due to its strong feature extraction capability and pattern recognition advantage. Existing research has applied convolutional neural network (CNN), recurrent neural network (RNN) and its variants to drug appearance defect recognition, ingredient content prediction and other fields, significantly improving detection accuracy and efficiency.
[0003] However, the existing drug quality detection method still has some shortcomings. On the one hand, the traditional deep learning model only focuses on single-dimensional data modeling and fails to effectively integrate the time evolution and spatial distribution of the drug production process, resulting in insufficient accuracy of drug quality detection. On the other hand, the existing quality determination mechanism uses a single threshold for anomaly detection, ignoring the quantification of detection result uncertainty and risk probability modeling, affecting the reliability of drug quality detection results. SUMMARY
[0004] In view of the above existing problems, the present application is proposed.
[0005] Therefore, the present application provides a drug quality intelligent detection method based on deep learning, which solves the problems of low detection accuracy and insufficient reliability of existing drug quality detection methods.
[0006] To solve the above technical problems, the present application provides the following technical solutions: In a first aspect, the present application provides a drug quality intelligent detection method based on deep learning, which comprises: collecting drug production data set and performing spatiotemporal alignment and multi-scale feature extraction to obtain structured quality feature data; performing spatiotemporal dynamic correlation analysis on the structured quality feature data to generate a quality spatiotemporal interaction matrix; inputting the quality spatiotemporal interaction matrix into a spatiotemporal joint attention model, a weight distribution layer performing time step weight calculation and spatial feature enhancement, a feature conversion layer performing feature compression and nonlinear feature mapping to form quality decision data; inputting the quality decision data into a Bayesian decision engine, performing Monte Carlo sampling and probability distribution aggregation to form a quality anomaly matrix, performing information entropy calculation on the quality anomaly matrix to obtain an abnormal probability distribution; The abnormal probability distribution is analyzed and the comprehensive risk assessment is performed, the drug quality score is obtained, the drug quality score is executed blockchain distribution encryption storage, and the final quality judgment report is formed.
[0007] As a preferred scheme of the drug quality intelligent detection method based on deep learning, the drug production data set includes sensor time series data, hyperspectral spatial data, drug ingredient data, and drug quality traceability data.
[0008] As a preferred scheme of the drug quality intelligent detection method based on deep learning, the generation of the quality space-time interaction matrix specifically includes the following steps: The affine transformation is performed on the drug production data set by using the multi-point least square method to obtain the spatial alignment data; The nearest neighbor interpolation is performed on the spatial alignment data to generate the spatial grid data, and the multi-scale feature extraction is performed on the spatial grid data to output the structured quality feature data; The graph convolution and feature fusion are performed on the structured quality feature data to generate the space-time correlation feature map, and the node credibility weighting is performed to obtain the quality space-time interaction matrix.
[0009] As a preferred scheme of the drug quality intelligent detection method based on deep learning, the space-time joint attention model is specifically constructed as follows: The weight distribution layer and the feature conversion layer are built through the gated recurrent architecture and the fully connected network, and the multi-head attention is applied to perform the interaction weighting and the hierarchical aggregation to construct the space-time joint attention model.
[0010] As a preferred scheme of the drug quality intelligent detection method based on deep learning, the formation of the quality decision data specifically includes the following steps: The quality space-time interaction matrix is input into the space-time joint attention model, the weight distribution layer performs the time step weight calculation and the spatial feature enhancement through the bidirectional gated recurrent unit to form the drug quality defect heat map; The feature conversion layer performs the feature compression and the nonlinear feature mapping through the fully connected network to generate the core quality feature vector; The channel cascading fusion is performed on the drug quality defect heat map and the core quality feature vector to obtain the enhanced quality feature set; The multi-dimensional feature quantization analysis is performed on the enhanced quality feature set to form the quality decision data.
[0011] As a preferred scheme of the drug quality intelligent detection method based on deep learning, the formation of the quality anomaly matrix specifically includes the following steps: Orthogonalizing and variance converting the quality decision data to obtain key quality covariates; The Bayesian decision engine models a posteriori density field of the key quality covariates to form a quality anomaly density field, and performs Monte Carlo sampling on the quality anomaly density field to generate a quality anomaly sample set; The quality anomaly sample set is subjected to probability distribution aggregation to form a quality anomaly matrix.
[0012] As a preferred scheme of the intelligent drug quality detection method based on deep learning, the step of obtaining the abnormal probability distribution comprises the following steps: The quality anomaly matrix is subjected to singular value decomposition to obtain a principal singular vector, and the principal singular vector is subjected to Varimax rotation to generate a rotated singular matrix; The rotated singular matrix is subjected to information divergence measurement and entropy value accumulation by using a Shannon entropy formula to form an entropy value spectrum, and the entropy value spectrum is subjected to exponential moving average to obtain a standardized spectrum; The standardized spectrum is subjected to probability density mapping and cumulative distribution integration to generate the abnormal probability distribution.
[0013] As a preferred scheme of the intelligent drug quality detection method based on deep learning, the step of forming the final quality judgment report comprises the following steps: The abnormal probability distribution is subjected to binning discretization and skewness quantization to obtain a skewness degree vector; The skewness degree vector is subjected to weight distribution and comprehensive weighting by using a risk factor to generate a drug quality score; The drug quality score is subjected to hash verification and timestamp binding to obtain a storage hash parameter, and the storage hash parameter is subjected to asymmetric encryption and digital signature to form the final quality judgment report.
[0014] In a second aspect, the present application provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, and wherein the computer program is executed by the processor to implement any step of the intelligent drug quality detection method based on deep learning according to the first aspect of the present application.
[0015] In a third aspect, the present application provides a computer readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement any step of the intelligent drug quality detection method based on deep learning according to the first aspect of the present application.
[0016] The application has the beneficial effects that: by constructing the spatio-temporal joint attention model, the spatio-temporal alignment and multi-scale feature fusion of multi-source heterogeneous data in the drug production process are realized, so as to break through the limitation of data modeling in a single dimension, and the precision of drug quality detection is significantly improved. At the same time, the Bayesian decision engine and the information entropy calculation mechanism are used to model the probability distribution of quality abnormalities and quantify the uncertainty, the risk perception ability and decision reliability of the detection result are enhanced, and the accuracy and reliability of the intelligent detection of drug quality are improved as a whole. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0018] Figure 1 The flowchart of the intelligent detection method of drug quality based on deep learning.
[0019] Figure 2 The flowchart for generating the quality spatio-temporal interaction matrix.
[0020] Figure 3 The flowchart for constructing the spatio-temporal joint attention model.
[0021] Figure 4 The flowchart for processing the Bayesian decision engine. DETAILED DESCRIPTION
[0022] In order to make the above-mentioned purposes, features and advantages of the present application more apparent and easy to understand, the specific embodiments of the present application will be described in detail below with reference to the drawings of the specification.
[0023] In the following description, many specific details are set forth in order to provide a thorough understanding of the present application, but the present application can also be implemented in other ways different from those described herein, and those skilled in the art can make similar generalizations without departing from the connotation of the present application, therefore the present application is not limited to the specific embodiments disclosed below.
[0024] Secondly, the "one embodiment" or "embodiment" referred to herein means that the specific features, structures or characteristics can be included in at least one implementation of the present application. "In one embodiment" appearing in different places in the specification does not mean the same embodiment, nor is it an independent or alternative embodiment that excludes other embodiments.
[0025] REFERENCE Figure 1For an embodiment of the present application, the embodiment provides a deep learning-based intelligent drug quality detection method, including the following steps: S1, collect the drug production dataset, and perform spatiotemporal alignment and multi-scale feature extraction to obtain structured quality feature data, perform spatiotemporal dynamic correlation analysis on the structured quality feature data, and generate a quality spatiotemporal interaction matrix, please refer to Figure 2 , the specific operation is as follows: S1.1, collect the drug production dataset, which includes sensor time series data, hyperspectral spatial data, drug ingredient data, and drug quality traceability data.
[0026] The sensor time series data includes temperature and humidity, pressure, and air flow; the temperature and humidity are collected by a temperature and humidity sensor, the pressure is collected by a piezoresistive pressure sensor, and the air flow is collected by a turbine flowmeter; The hyperspectral spatial data includes drug surface images, reflectance information, and drug absorption characteristics; the drug surface images are collected by a hyperspectral camera, the reflectance information is collected by a spectrophotometer, and the drug absorption characteristics are collected by an infrared spectrometer; The drug ingredient data includes main drug content, auxiliary material proportion, and impurity concentration; the main drug content is collected by a high-performance liquid chromatograph, the auxiliary material proportion is collected by a near-infrared spectrometer, and the impurity concentration is collected by a gas chromatograph-mass spectrometer; The drug quality traceability data includes raw material batch, production equipment number, and process parameter version number; the raw material batch is collected by a bar code scanner, the production equipment number is collected by an RFID tag, and the process parameter version number is collected by an industrial gateway.
[0027] S1.2, pre-process the drug production dataset, in the specific operation, for the sensor time series data, apply sliding window filtering to perform noise suppression, and use Min-Max normalization to unify the dimension, synchronize the multi-channel timestamp alignment, and ensure the time sequence consistency of the sensor time series data; for the hyperspectral spatial data, use a standard reflector to perform reflectance correction to eliminate environmental interference, and simultaneously perform spectral compression through principal component analysis to reduce redundant information; for the drug ingredient data, use linear interpolation to fill in the missing data to maintain the integrity of the drug ingredient data, simultaneously identify and eliminate outliers to ensure the accuracy of the drug ingredient data; for the drug quality traceability data, use NTP time synchronization protocol to perform timestamp binding to ensure time consistency, and simultaneously standardize the JSON format to improve the compatibility and readability of the drug quality traceability data, and output the pre-processed drug production dataset.
[0028] S1.3, affine transformation is performed on the preprocessed drug production data set by using the multi-point least square method to obtain spatial alignment data. In the specific operation, the spatial corresponding points of the preprocessed drug production data set are extracted by using the SIFT feature matching algorithm. Further, the preprocessed drug production data set is subjected to frequency spectrum decomposition to obtain frequency domain features, and the frequency domain features are subjected to spatial convolution to generate a frequency-space feature map. Edge enhancement and feature point extraction are performed on the frequency-space feature map to obtain an initial feature point set. Then, density clustering and outlier rejection are performed on the initial feature point set to generate a density balanced point set. The density balanced point set is subjected to random sampling and dynamic weight distribution to obtain the spatial corresponding points; The spatial corresponding points are subjected to affine transformation by using the multi-point least square method. Further, the spatial corresponding points are subjected to geometric transformation to obtain transformation parameters. At the same time, the transformation parameters are subjected to matrix inversion and parameter normalization to generate an affine transformation matrix. Then, the affine transformation matrix is subjected to coordinate system mapping to obtain a preliminary alignment result. Grid interpolation and data smoothing are performed on the preliminary alignment result to output the spatial alignment data.
[0029] S1.4, nearest neighbor interpolation and multi-scale feature extraction are performed on the spatial alignment data to output structured quality feature data. In the nearest neighbor interpolation stage, the spatial alignment data is subjected to discrete sampling to obtain a discrete data point set. The discrete data point set is subjected to grid parameterization to obtain grid node coordinates. The discrete data point set is taken as the x-axis in the three-dimensional space coordinate system, and the grid node coordinates are taken as the y-axis in the three-dimensional space coordinate system to construct a regular grid. The regular grid is subjected to boundary filling and weight distribution to obtain a neighborhood index. The neighborhood index is subjected to neighborhood search to obtain a neighborhood point set. The neighborhood point set is simultaneously subjected to nearest neighbor interpolation to generate an initial interpolation result. The initial interpolation result is subjected to data mapping to output spatial grid data. In the multi-scale feature extraction stage, the spatial grid data is subjected to scale decomposition by using the Gaussian pyramid decomposition method. Further, the spatial grid data is subjected to convolution filtering to obtain a multi-scale feature map. The multi-scale feature map is subjected to feature fusion to form a feature pyramid. Next, the feature pyramid is subjected to layer-by-layer downsampling to extract macro-level features and micro-level features. The macro-level features capture the overall quality distribution trend of the drug, and the micro-level features focus on the local detail abnormalities of the drug. Finally, the macro-level features and the micro-level features are subjected to channel splicing and normalization processing to output structured quality feature data. The structured quality feature data represents the spatio-temporal distribution characteristics of the drug quality, which can support subsequent intelligent quality detection and decision-making.
[0030] S1.5, perform graph convolution and feature fusion on the structured quality feature data, generate a spatiotemporal correlation feature map, and perform node credibility weighting to obtain a quality spatiotemporal interaction matrix. In specific operations, the structured quality feature data is subjected to feature dimension decomposition to extract a multi-modal feature vector, and the multi-modal feature vector is subjected to node feature initialization to output a node feature matrix; simultaneously, the multi-modal feature vector is subjected to edge weight distribution to generate a weighted adjacency matrix; the output node feature matrix and the generated weighted adjacency matrix are subjected to topological aggregation to obtain an initial graph representation; Then, the initial graph representation is subjected to graph convolution to obtain updated node features, and the updated node features are subjected to nonlinear activation and feature normalization to output intermediate graph features; the intermediate graph features are subjected to feature fusion to generate multi-level graph features, and the multi-level graph features are subjected to attention weighting to obtain a spatiotemporal correlation feature map; The spatiotemporal correlation feature map is subjected to spatial pooling and time slicing to obtain multi-scale spatiotemporal features, and the multi-scale spatiotemporal features are subjected to matrix transformation and dimension reorganization to obtain a node feature tensor; the node feature tensor is subjected to credibility weighting to obtain a weighted node feature matrix, which is unfolded according to the time dimension and subjected to spatial attention fusion to generate a quality spatiotemporal interaction matrix; the matrix element values of the quality spatiotemporal interaction matrix quantify the mutual influence strength of the pharmaceutical production process units in a specific time period (such as the fermentation stage).
[0031] S2, input the quality spatiotemporal interaction matrix into a spatiotemporal joint attention model, the weight distribution layer performs time step weight calculation and spatial feature enhancement, the feature conversion layer performs feature compression and nonlinear feature mapping to form quality decision data.
[0032] Please refer to Figure 3 , which specifically includes the following operations: S2.1, construct and train a spatiotemporal joint attention model. In specific operations, in the PyTorch framework, the gated recurrent architecture is called through nn.GRU parameters, the hidden layer dimension is set to 256, the number of layers is set to 2, and the dropout rate is set to 0.1; a LayerNorm layer is connected after the gated recurrent architecture for feature normalization to improve feature stability, and a residual connection is used for gradient optimization to complete the construction of the weight distribution layer; a fully connected network is called using the nn.Linear function, the input dimension is set to 512, the output dimension is set to 256, and the hidden layer dimension is set to 128; a Dropout layer is connected after the fully connected network for regularization to prevent overfitting, and a skip connection is used for feature preservation to complete the construction of the feature conversion layer; The multi-head attention is used for feature fusion and interactive weighting of the weight distribution layer and the feature conversion layer to generate a weighted feature representation; the LayerNorm layer is used for feature stabilization of the weighted feature representation to obtain normalized features; the Softmax function is used for weight distribution of the normalized features to generate attention weights; the hierarchical aggregation of the weight distribution layer and the feature conversion layer is performed according to the attention weights, and dynamic balance is performed through a gating mechanism to complete the construction of the spatio-temporal joint attention model; Next, the spatio-temporal joint attention model is trained, and further, the quality spatio-temporal interaction matrix is divided into a sample set, a training set and a validation set; on the sample set, random disturbance is performed by using data enhancement, and normalization processing is performed by using the Min-Max standardization to form an enhanced sample; on the training set, the enhanced sample is updated by using the Adam optimizer, and training optimization is simultaneously applied by using the learning rate decay to obtain the training loss; on the validation set, the training loss is back propagated to obtain the validation loss; when the validation loss exceeds the convergence threshold for 5 consecutive rounds, the training is terminated, and the trained spatio-temporal joint attention model is simultaneously output; It should be noted that the convergence threshold is defined based on the statistical distribution of the validation loss, and the value range is 0.001 to 0.005.
[0033] S2.2, the weight distribution layer performs time step weight calculation and spatial feature strengthening through the bidirectional gated recurrent unit to form a drug quality defect heat map, in the specific operation, the quality spatio-temporal interaction matrix is input into the spatio-temporal joint attention model through the Input interface, the weight distribution layer expands the quality spatio-temporal interaction matrix according to the time dimension, and performs feature projection and dimension alignment to obtain a time sequence feature sequence; the time sequence feature sequence is input into the forward and backward gated recurrent units respectively; the update gate of the forward gated recurrent unit integrates the historical information of the time sequence feature sequence to obtain a forward candidate state, and the reset gate reconstructs the forward candidate state to obtain a historical time sequence dependent feature; the update gate of the backward gated recurrent unit performs reverse feature extraction on the time sequence feature sequence to generate a backward candidate state, and the reset gate modulates and updates the state of the backward candidate state to capture a future time sequence dependent feature; The historical time sequence dependent feature and the future time sequence dependent feature are spliced to form a bidirectional feature vector; then, the bidirectional feature vector is subjected to time step weight calculation, further, the bidirectional feature representation is subjected to attention weight calculation to generate a time attention score, and the time attention score is subjected to score normalization to obtain a normalized time step weight, and the normalized time step weight is subjected to feature weighting to output a time step weighted feature value, and the specific mathematical formula is as follows: ; wherein, represents the time step weighted feature value, denotes the total number of time steps, denotes the time step index, denotes the normalized time step weight at time step denotes the normalized time step weight at time step denotes the bidirectional feature vector at time step denotes the bidirectional feature vector at time step The time step weighted feature values are normalized using a Softmax function to obtain a weight distribution feature, and a GELU function is applied to the weight distribution feature for feature channel fusion and nonlinear transformation to enhance the feature expression capability, to obtain a spatial feature enhanced feature; the spatial feature enhanced feature is compressed and probability mapped to generate a defect probability distribution, and the defect probability distribution is simultaneously subjected to pixel value normalization and heat map rendering to output a pharmaceutical quality defect heat map; each pixel value in the pharmaceutical quality defect heat map represents the defect probability at the corresponding position and time point, and the higher the pixel value, the greater the defect risk of the pharmaceutical.
[0034] S2.3, the feature conversion layer utilizes a fully connected network to perform feature compression and nonlinear feature mapping to generate a core quality feature vector, in specific operations, the quality space-time interaction matrix is input into a double-layer fully connected network for linear transformation, the first layer of fully connected network performs feature compression and dimension reduction on the quality space-time interaction matrix to obtain a high-dimensional feature representation, the high-dimensional feature representation is projected to a hidden space using a scaling factor, and a GELU activation function is introduced to introduce nonlinearity, and a hidden layer feature is output; It should be noted that the scaling factor is defined based on the variance stability of the high-dimensional feature representation, and the value range is 0.8-1.2.
[0035] The second layer of fully connected network performs secondary compression and feature refinement on the hidden layer feature to obtain a low-dimensional feature, and performs nonlinear feature mapping and feature enhancement on the low-dimensional feature to form a refined feature representation; at the same time, a Dropout layer is added in each layer of fully connected network to perform random shielding operation to prevent overfitting; finally, the refined feature representation is connected to the high-dimensional feature representation through residual connection to retain key information and alleviate the gradient vanishing problem, and a core quality feature vector is output, which represents the global statistical characteristics (such as ingredient uniformity) and local abnormal patterns (such as surface defects) of the pharmaceutical quality, and can provide high information density quality decision basis.
[0036] S2.4, perform channel cascade fusion on the drug quality defect heat map and the core quality feature vector to obtain an enhanced quality feature set, in specific operations, apply the drug quality defect heat map to global average pooling to compress the heat map feature vector, at the same time, adjust the core quality feature vector to the same number of channels as the heat map feature vector using a fully connected layer to ensure dimension matching, and output an aligned feature vector; then, splice the heat map feature vector and the aligned feature vector along the channel dimension to form a joint feature vector; then, perform cross-channel information interaction on the joint feature vector through a 1x1 convolution to compress the channel number and enhance the feature expression capability, and obtain a fusion feature representation; finally, perform nonlinear transformation and numerical stabilization on the fusion feature representation using BatchNorm and GELU activation functions, and output the enhanced quality feature set.
[0037] S2.5, perform multi-dimensional feature quantization analysis on the enhanced quality feature set to form quality decision data, in specific operations, perform principal component analysis on the enhanced quality feature set, further, perform eigenvalue decomposition on the enhanced quality feature set, extract the first k principal components, and perform linear transformation projection on the first k principal components to eliminate redundant information, and output a low-dimensional feature representation; perform clustering analysis on the low-dimensional feature representation using the K-mean clustering method, further, perform distance measurement and iterative optimization on the low-dimensional feature representation to generate an initial clustering center, perform density clustering on the initial clustering center to obtain a quality level cluster, perform weight adjustment and weighted aggregation on the quality level cluster to obtain an optimized clustering result; use the descriptive statistical method to optimize the clustering result for statistical quantization, further, perform mean value extraction and variance statistics on the optimized clustering result to obtain statistical distribution parameters, perform linear mapping on the statistical distribution parameters to obtain quantitative statistical indicators; integrate the low-dimensional feature representation, the optimized clustering result and the quantitative statistical indicators to generate quality decision data.
[0038] S3, input the quality decision data into the Bayesian decision engine, perform Monte Carlo sampling and probability distribution aggregation to form a quality anomaly matrix, perform information entropy calculation on the quality anomaly matrix to obtain an abnormal probability distribution.
[0039] Please refer to Figure 4 , which specifically includes the following operations: S3.1, orthogonalize the quality decision data and perform variance conversion to obtain key quality covariates, the Bayesian decision engine models the posterior density field and performs Monte Carlo sampling on the key quality covariates to generate a quality abnormal sample set, the specific operation is as follows, perform Gram-Schmidt orthogonalization on the quality decision data, further, perform vector projection on the quality decision data, obtain projection residual, and perform orthogonal normalization on the projection residual to generate orthogonal vectors, at the same time, integrate the orthogonal vectors into basis vectors to obtain an orthogonal basis vector group; the Box-Cox transformation is used to convert the orthogonal basis vector group to stable variance, further, perform feature decomposition and gradient optimization on the orthogonal basis vector group to obtain transformation parameters, perform nonlinear mapping on the transformation parameters to convert the transformation parameters to stable variance data, and perform variance equalization on the stable variance data to ensure that the variances of each dimension are homogeneous, and output the key quality covariates; Then input the key quality covariates into the Bayesian decision engine to perform posterior density field modeling, further, perform parameter initialization on the key quality covariates (set the mean parameter to the historical mean and the variance parameter to the benchmark variance) to obtain the prior distribution parameter, and perform parameter fusion on the prior distribution parameter to obtain the joint distribution representation, then perform iterative sampling on the joint distribution representation to generate the posterior probability representation, and perform density smoothing and weighted aggregation on the posterior probability representation to output the quality abnormal density field; Use Metropolis-Hastings algorithm to perform Monte Carlo sampling on the quality abnormal density field, further, perform uniform sampling on the quality abnormal density field to obtain candidate sample points, and perform probability comparison and state transition on the candidate sample points to generate an effective sample chain, then remove the burning period and sample sparsification of the effective sample chain to output the quality abnormal sample set; Each sample point in the quality abnormal sample set carries a posterior probability representation, which can quantitatively represent the abnormal risk degree in the drug production process; It should be noted that the burning period removal refers to removing the sampling points in the unstable stage (such as the first 20% of the total sampling times) of the effective sample chain.
[0040] S3.2, aggregate the probability distribution of the quality abnormal sample set to form a quality abnormal matrix, perform singular value decomposition and principal component rotation on the quality abnormal matrix to generate a rotated singular matrix, in the probability distribution aggregation stage, perform feature weighting and probability density fusion on the quality abnormal sample set to obtain a weighted probability feature field, and perform regional aggregation and grid mapping on the weighted probability feature field to generate a discrete feature distribution, at the same time, perform matrix conversion and missing value filling on the discrete feature distribution to obtain a complete feature matrix; Discretize the complete feature matrix into a two-dimensional matrix according to the space-time dimension (such as production batch timestamp and equipment position grid), and perform matrix normalization to output the quality abnormal matrix; In the singular value decomposition stage, matrix decomposition is performed on the quality anomaly matrix to decompose the quality anomaly matrix into a left singular vector matrix, a singular value matrix, and a right singular vector matrix, and the first t column vectors of the left singular vector matrix are extracted as principal singular vectors; Next, the principal singular vector matrix is subjected to Varimax rotation, and further, the load of the principal singular vector is optimized to obtain a rotation parameter, and the rotation parameter is subjected to orthogonal transformation to obtain a rotated singular matrix; The column vectors in the rotated singular matrix represent the key abnormal patterns in the production of the drug (such as sudden temperature change, pressure fluctuation, etc.), and the row vectors represent the quality risk distribution characteristics of the drug.
[0041] S3.3, the Shannon entropy formula is applied to the rotated singular matrix to measure the information divergence and accumulate the entropy value, form an entropy spectrum, and perform exponential moving average on the entropy spectrum to obtain a standardized spectrum. In the information divergence measurement stage, the probability distribution vector is obtained by performing probability normalization on the rotated singular matrix, and the logarithmic probability vector is generated by performing logarithmic conversion on the probability distribution vector; the logarithmic probability vector is weighted and summed by the Shannon entropy formula and the sign is reversed to quantify the discrete degree of the probability distribution vector, and the information entropy value is output. The specific mathematical format is as follows: ; Wherein, represents the information entropy value, represents the dimension of the probability distribution vector, represents the dimension index of the probability distribution vector, represents the logarithmic probability vector in the dimension .
[0042] In the entropy accumulation stage, the local accumulation of the information entropy value is performed by time window sliding to generate a cumulative entropy value sequence, and the cumulative entropy value sequence is divided into intervals and weighted to obtain a weighted entropy value interval. The entropy value spectrum is obtained by linear combination of the weighted entropy value interval. Then, the entropy spectrum is subjected to exponential moving average, and further, the moving average is performed on the entropy spectrum to generate an optimized entropy sequence, and the frequency domain filtering is performed on the optimized entropy sequence to eliminate high frequency fluctuations and retain trend information, and the refined entropy spectrum is obtained. At the same time, the range scaling is performed on the refined entropy spectrum, and finally the standardized spectrum is output.
[0043] S3.4, the standardized spectrum is subjected to probability density mapping and cumulative distribution integration to generate an abnormal probability distribution. In the specific operation, Gaussian kernel density estimation (KDE) is applied to the standardized spectrum to perform probability density mapping, and further, Gaussian kernel convolution is performed on the standardized spectrum to map the standardized spectrum to a continuous probability space to obtain a probability density field. The local weighted average and curve smoothing are performed on the probability density field to generate a continuous probability density function, and the range truncation and baseline alignment are performed on the continuous probability density function to obtain a calibrated density function. The trapezoidal integration method is used to perform cumulative distribution integration on the calibration density function. Further, the calibration density function is discretely sampled at equal intervals to obtain discrete sampling points, and the discrete sampling points are segmented and linearly integrated to obtain an original cumulative distribution. Then, linear interpolation and monotonicity adjustment are performed on the original cumulative distribution to generate a strictly increasing cumulative function, and the strictly increasing cumulative function is interval scaled to constrain its value range to the interval [0, 1] to output a standardized cumulative distribution. The standardized cumulative distribution is inversely mapped to generate an anomaly probability distribution.
[0044] S4. The anomaly probability distribution is analyzed for deviation degree and comprehensively evaluated for risk to obtain a drug quality score, and the drug quality score is encrypted and stored in a blockchain distribution to form a final quality determination report.
[0045] Specifically, the following steps are included: S4.1. The anomaly probability distribution is discretized by binning and quantified for skewness to obtain a deviation degree vector. In specific operations, the anomaly probability distribution is discretized by binning using the equal-width binning method, and further, the probability values in the anomaly probability distribution are extracted and linearly combined to obtain a probability value sequence. The probability value sequence is divided into a plurality of discrete intervals (such as 20 discrete intervals, each with a width of 0.05) according to a certain interval width, ensuring that each discrete interval covers a consistent range of probability values, and a set of discrete probability intervals is output. Then, the set of discrete probability intervals is statistically aggregated to obtain interval representative values, and the interval representative values are reorganized into a sequence to generate a discrete probability distribution sample. Subsequently, the discrete probability distribution sample is quantified for skewness. Further, the third moment and the variance of the discrete probability distribution sample are calculated to obtain a skewness coefficient, and the skewness coefficient is subjected to interval density weighting and discrete error compensation to eliminate the deviation caused by binning, and a binning weighted skewness value is output. The specific mathematical formula is as follows: ; Wherein, represents the binning weighted skewness value, represents the bin index, represents the number of discrete probability distribution samples in the th bin, represents the total number of discrete probability distribution samples, represents the third central moment of the th bin, represents the variance of the th bin; Finally, the binning weighted skewness value is sequentially spliced to obtain a deviation degree vector, which directly reflects the skewness characteristics of the anomaly probability distribution in different discrete intervals and can locate the abnormal risk tendency of the discrete interval.
[0046] S4.2, the risk factor is applied to the bias degree vector to perform weight distribution and comprehensive weighting, and a drug quality score is generated. In the weight distribution stage, the risk factor is used to linearly scale the bias degree vector to form a risk weight coefficient. According to the risk weight coefficient, the bias degree vector is assigned a weight. For example, when the risk weight coefficient is greater than the weight threshold, the bias degree vector is assigned a high weight (such as 0.9). When the risk weight coefficient is less than the weight threshold, the bias degree vector is assigned a low weight (such as 0.3). According to the assigned weight, the bias degree vector is weighted and superimposed and range adjusted to form a standard weighted bias vector. It should be noted that the risk factor is defined based on the historical abnormal correlation strength of the bias degree vector, and the value range is [0.5, 1.5]. The weight threshold is defined based on the process sensitivity level of the bias degree vector, and the value range is [0.6, 1.0].
[0047] Then the standard weighted bias vector is summed, the weighted comprehensive score is calculated, and the weighted comprehensive score is subjected to Sigmoid normalization and risk interval mapping to output the drug quality score. The specific mathematical formula is as follows: ; Among them, represents the drug quality score, represents the natural logarithm base, represents the slope adjustment coefficient of the Sigmoid function, represents the weighted comprehensive score, represents the offset coefficient of the Sigmoid function. It should be noted that the slope adjustment coefficient is defined based on the data distribution dispersion of the weighted comprehensive score, and the value range is [0.3, 1.0]. The offset coefficient is defined based on the historical score median of the weighted comprehensive score, and the value range is [4.0, 6.0].
[0048] S4.3, the drug quality score is subjected to hash check and timestamp binding to obtain a storage hash parameter, and the storage hash parameter is subjected to asymmetric encryption and digital signature to form a final quality judgment report. In the specific operation, the SHA-256 algorithm is used to serialize and encode the drug quality score and the drug quality traceability data. Further, the drug quality score and the drug quality traceability data are subjected to byte stream conversion to obtain an original data stream, and the original data stream is subjected to hash iteration compression to obtain a hash check intermediate value. The hash check intermediate value is padded and grouped to generate an optimized hash value. A trusted timestamp is obtained from a timestamp server (such as a national time service center). The optimized hash value and the trusted timestamp are spliced and then serialized and encoded by the SHA-256 algorithm to form a composite hash identifier. The length of the composite hash identifier is standardized to obtain the storage hash parameter. The evidence storage hash parameter is then asymmetrically encrypted, and further, the evidence storage hash parameter is key-bound to obtain an encrypted input block, a modulus power operation is performed on the encrypted input block and data expansion is performed to generate a signature base; then the signature base is digitally signed, and further, the signature base is encrypted by a private key to obtain a digital signature, and the digital signature is format-encapsulated to form a signature certificate, and the signature certificate is simultaneously structured for reporting to output a final quality determination report.
[0049] The embodiment also provides a computer device, comprising a memory and a processor; the memory is used to store computer executable instructions, and the processor is used to execute the computer executable instructions to implement the deep learning-based intelligent drug quality detection method proposed in the above embodiment.
[0050] The computer device can be a terminal, and the computer device comprises a processor, a memory, a communication interface, a display screen and an input device connected through a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device comprises a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for running the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner. The wireless manner can be achieved through WIFI, an operator network, NFC (near field communication) or other technologies. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer overlaid on the display screen, or a key, trackball or touchpad arranged on the shell of the computer device, or an external keyboard, touchpad or mouse, etc.
[0051] The embodiment also provides a storage medium on which a computer program is stored, the program being executed by a processor to implement the deep learning-based intelligent drug quality detection method proposed in the above embodiment; the storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as a static random access memory (SRAM), an electrically erasable programmable read-only memory (EEPROM), an erasable programmable read-only memory (EPROM), a programmable read-only memory (PROM), a read-only memory (ROM), a magnetic memory, a flash memory, a magnetic disk, or an optical disk.
[0052] To sum up, by constructing a spatio-temporal joint attention model, the spatio-temporal alignment and multi-scale feature fusion of multi-source heterogeneous data in the drug production process are realized, thereby breaking through the limitation of data modeling in a single dimension, and the precision of drug quality detection is significantly improved. Meanwhile, by using a Bayesian decision engine and an information entropy calculation mechanism, the probability distribution modeling and uncertainty quantification of quality abnormalities are performed, the risk perception ability and decision reliability of the detection result are enhanced, and the accuracy and reliability of the intelligent drug quality detection are improved as a whole.
[0053] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present application but not limit the present application. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or replaced equivalently without departing from the spirit and scope of the technical solutions of the present application, and all of them should be covered in the scope of the claims of the present application.
Claims
1. A deep learning-based intelligent drug quality detection method, characterized in that: The method comprises the following steps: Collect a drug production data set, perform spatio-temporal alignment and multi-scale feature extraction, obtain structured quality feature data, perform spatio-temporal dynamic correlation analysis on the structured quality feature data, and generate a quality spatio-temporal interaction matrix; Input the quality spatio-temporal interaction matrix into a spatio-temporal joint attention model, and perform time step weight calculation and spatial feature enhancement through a weight distribution layer, perform feature compression and nonlinear feature mapping through a feature conversion layer, and form quality decision data; Input the quality decision data into a Bayesian decision engine, perform Monte Carlo sampling and probability distribution aggregation, form a quality anomaly matrix, perform information entropy calculation on the quality anomaly matrix, obtain an abnormal probability distribution, and perform deviation degree analysis and comprehensive risk assessment on the abnormal probability distribution, obtain a drug quality score, perform blockchain distributed encryption storage on the drug quality score, and form a final quality judgment report. The drug production data set comprises sensor time series data, hyperspectral spatial data, drug ingredient data, and drug quality traceability data. 2.The deep learning-based intelligent drug quality detection method of claim 1, wherein: The quality spatio-temporal interaction matrix is generated by the following steps: 3.The deep learning-based intelligent drug quality detection method of claim 2, wherein: Perform affine transformation on the drug production data set by using a multi-point least square method to obtain spatially aligned data; Perform nearest neighbor interpolation on the spatially aligned data to generate spatial grid data, and perform multi-scale feature extraction on the spatial grid data to output structured quality feature data; Perform graph convolution and feature fusion on the structured quality feature data to generate a spatio-temporal correlation feature map, and perform node credibility weighting to obtain a quality spatio-temporal interaction matrix. The spatio-temporal joint attention model is constructed as follows: 4.The deep learning-based intelligent drug quality detection method of claim 1, wherein: Build a weight distribution layer and a feature conversion layer through a gated recurrent architecture and a fully connected network, apply multi-head attention to perform interaction weighting and hierarchical aggregation, and construct a spatio-temporal joint attention model. The quality decision data is formed by the following steps: 5.The deep learning-based intelligent drug quality detection method of claim 4, wherein: Input the quality spatio-temporal interaction matrix into the spatio-temporal joint attention model, and perform time step weight calculation and spatial feature enhancement through the bidirectional gated recurrent unit of the weight distribution layer to form a drug quality defect heat map; The feature conversion layer utilizes a fully connected network to perform feature compression and nonlinear feature mapping to generate a core quality feature vector; Perform channel cascading fusion on the drug quality defect heat map and the core quality feature vector to obtain an enhanced quality feature set; Perform multi-dimensional feature quantization analysis on the enhanced quality feature set to form quality decision data. The quality anomaly matrix is formed by the following steps: 6.The deep learning-based intelligent drug quality detection method of claim 1, wherein: Orthogonalize and variance convert the quality decision data to obtain key quality covariates; The Bayesian decision engine models the posterior density field of the key quality covariates to form a quality anomaly density field, and performs Monte Carlo sampling on the quality anomaly density field to generate a quality anomaly sample set; Perform probability distribution aggregation on the quality anomaly sample set to form a quality anomaly matrix. The abnormal probability distribution is obtained by the following steps: 7.The deep learning-based intelligent drug quality detection method of claim 1, wherein: Perform singular value decomposition on the quality anomaly matrix to obtain a principal singular vector, and perform Varimax rotation on the principal singular vector to generate a rotated singular matrix; The Shannon entropy formula is applied to measure the information divergence of the singular rotation matrix and accumulate the entropy value to form an entropy value spectrum; an exponential moving average is performed on the entropy value spectrum to obtain a standardized spectrum; The standardized spectrum is subjected to probability density mapping and cumulative distribution integration to generate an abnormal probability distribution. 8.The deep learning-based intelligent drug quality detection method of claim 7, wherein: The final quality judgment report is formed, specifically including the following steps: The abnormal probability distribution is discretized by binning and quantified by skewness to obtain a skewness degree vector; A risk factor is applied to perform weight distribution and comprehensive weighting on the skewness degree vector to generate a drug quality score; Hash verification and timestamp binding are performed on the drug quality score to obtain a storage hash parameter, and asymmetric encryption and digital signature are performed on the storage hash parameter to form the final quality judgment report. 9.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is characterized in that: The processor executes the computer program to realize the steps of the deep learning-based intelligent drug quality detection method according to any one of claims 1-8.
10. A computer readable storage medium having stored thereon a computer program, characterized in that: The computer program is executed by the processor to realize the steps of the deep learning-based intelligent drug quality detection method according to any one of claims 1-8.