Improved LSTM combined attention mechanism distiller's yeast pit temperature prediction method
Through the improved LSTM temperature prediction method combined with the attention mechanism, the problem of insufficient applicability and low efficiency in the temperature prediction of the distiller's cellar is solved, and higher prediction accuracy and stability are achieved, which is suitable for predicting the temperature changes of the distiller's cellar. , ensuring the quality and production efficiency of the koji fermentation process.
Patent Information
- Application Number
- CN202410692449.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-09-03
AI Technical Summary
The existing methods for predicting the temperature of the distiller's yeast cellar have problems such as insufficient applicability, low efficiency, and low accuracy, and cannot effectively guide the fermentation process of the distiller's yeast.
The temperature prediction method uses an improved LSTM combined with an attention mechanism. Through the steps of data collection, preprocessing, model training and optimization, performance evaluation, deployment and feedback, the convolutional neural network, long short-term memory network and attention mechanism are used to process the temperature. Time series data to improve forecast accuracy and applicability.
It improves the accuracy and stability of temperature prediction, enhances the applicability and calculation efficiency of the model, is suitable for predicting temperature changes in distiller's cellars, and ensures the digital management of distiller's yeast quality and production links.
Smart Images

Figure CN118585933A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of time series analysis and temperature prediction, and in particular to a method for predicting the temperature of a koji cellar by improving LSTM combined with an attention mechanism. Background Art
[0002] Koji fermentation is a complex biochemical reaction process. The reaction speed and efficiency are directly affected by temperature. Too high or too low temperature will inhibit yeast activity, resulting in incomplete fermentation or the production of unpleasant flavor substances. Generally, the optimum temperature for koji yeast is 20-30°C. Too high temperature will cause yeast death or mutation. Too low temperature will reduce yeast activity and slow down or stop fermentation, which will affect the quality of the wine. Therefore, the koji fermentation process requires strict temperature control and management to ensure that the yeast ferments within the appropriate temperature range. Different types of wine have different suitable temperatures, and the fermentation temperature also needs to be adjusted to ensure that the koji achieves the best fermentation effect and the wine achieves the best taste quality.
[0003] At present, the temperature prediction methods for koji cellars are divided into prediction methods based on statistics, prediction methods based on traditional machine learning, and prediction methods based on deep learning. The prediction methods based on statistics, such as the ARIMA model, do not have wide applicability, have limited ability to model nonlinear relationships, require manual selection of differential times and lag terms, are relatively sensitive to parameter selection, and have low efficiency. The traditional machine learning method requires manual construction of lag features and does not directly process the dependency structure of time series. The prediction accuracy based on deep learning networks is not high enough, and there is still a gap from actual prediction needs, and lacks effective guidance for the temperature prediction of koji cellars. Summary of the invention
[0004] In view of the above problems, the present invention provides a method for predicting the temperature of a koji cellar by improving LSTM combined with an attention mechanism, so as to solve the problems that the prior art lacks wide applicability, low efficiency, and low accuracy.
[0005] To achieve the above object, the present invention provides a method for predicting the temperature of a wine koji cellar by improving LSTM combined with an attention mechanism, comprising the following steps:
[0006] S1 Data Collection: Collect cellar data from the automated control system and sensor records, and enter the continuous fluctuation mode CFPR analysis module in real time. The continuous fluctuation mode CFPR analysis module is used to detect abnormal fluctuations;
[0007] S2 Data preprocessing: Clean the feature data of the original data set, that is, remove outliers, process missing values, and then normalize the data to meet the input requirements of the model;
[0008] S3 data set division: according to the set training set, validation set and test set division ratio, adaptive time-aware sampling ATAS is performed on the data processed in step S2 to obtain the training set, validation set and test set;
[0009] S4 model training and optimization: Use the training set described in step S3 to train the improved LSTM combined with attention mechanism model, and adjust the learning rate and batch size parameters by monitoring the training and validation losses to find the best model configuration;
[0010] S5 Performance evaluation: Use the test set to evaluate the prediction performance of the model. The evaluation indicators of model performance include weighted mean square error (WMSE), dynamic time warping distance (DTW), and continuous error accumulation (CEA). Based on the evaluation results, further adjust the model structure or parameters.
[0011] S6 deployment and feedback: deploy the trained model to the production environment, receive prediction requests, use the model for prediction services, monitor the model, implement incremental feedback learning (IFL), collect real-time data and feed it back to the model, optimize the model, fine-tune the model, and continuously optimize the model structure and parameters.
[0012] Further, in step S1, the cellar data includes temperature data and humidity data inside the cellar and the external environment, carbon dioxide concentration generated during the fermentation process, time information of data collection, climate data and geographic information data;
[0013] The specific calculation formula of the continuous fluctuation mode CFPR analysis module is as follows:
[0014]
[0015] Among them, X t represents the current observation value, c is a constant term, φ i are model parameters, X t-i is the observed value of the previous i periods, ε t is the error term.
[0016] Furthermore, in step S2, outliers are removed by using an improved local outlier factor detection algorithm ELOF to remove data generated due to erroneous data entry, equipment failure, and atypical experimental conditions, including the following aspects:
[0017] (1) ELOF uses an adaptive distance measurement method to automatically adjust the distance calculation method according to data characteristics. The specific formula is as follows:
[0018]
[0019] Among them, σ k is the standard deviation of the k-th dimension feature;
[0020] (2) ELOF is based on the local adaptive adjustment of density, that is, dynamically adjusts its local density estimation according to the density change of data points in its domain. The specific formula is as follows:
[0021]
[0022] Among them, N k (X i ) is x i k neighbors of j ) is the data point x j The local density of
[0023] (3) ELOF adopts a new penalty function, which comprehensively considers the local density and adaptive distance of data points and accurately penalizes outliers. The penalty function formula is as follows:
[0024]
[0025] The specific formula of the overall loss function is as follows:
[0026]
[0027] Where: L represents the conventional loss function (such as mean square error);
[0028] f(xi;θ) is the prediction model with parameters;
[0029] Penalty(xi) is the penalty function for outliers;
[0030] λ is the coefficient that regulates the influence of the two;
[0031] To handle missing values, interpolation is first used to fill in the missing values, and then the filling results are further refined through local weighted regression;
[0032] The interpolation method uses linear, quadratic and spline interpolation through known data points, where the linear interpolation formula is as follows:
[0033]
[0034] Where: x i and x j is a data point;
[0035] x k is a missing value;
[0036] t i ,t j For x i and x j The corresponding time point;
[0037] The local weighted regression formula is as follows:
[0038]
[0039] Among them, w i Determined by the kernel function K;
[0040]
[0041] Data normalization uses robust normalization combined with adaptive scaling. Robust normalization is used to scale the data to the median and interquartile range (IQR). Adaptive scaling is then used to dynamically adjust the scaling range based on the local statistical characteristics of the data. The specific formula for robust normalization is as follows:
[0042]
[0043] Among them, X' is the normalized data;
[0044] median(X) is the median of the data set X;
[0045] IOR(X) is the interquartile range, and IOR is the difference between the 75th percentile and the 25th percentile;
[0046] For the normalized data X', adaptive scaling adjustment is performed according to the local statistical characteristics of the data. The specific formula is as follows:
[0047]
[0048] Among them, X” adaptively adjusts the data;
[0049] μ local and σ local are the local mean and standard deviation, respectively.
[0050] Further, in step S3, the division ratio of the training set, the validation set and the test set is 7:1:2, and the adaptive time-aware sampling (ATAS) includes the following steps:
[0051] (1) Dynamic adjustment of data window: The size of the data window is dynamically adjusted according to the fluctuation characteristics of the data. The specific adjustment formula is as follows:
[0052]
[0053] W=α·σ+β
[0054] Where, σ is the data volatility;
[0055] x i is a data sample;
[0056] x is the sample mean;
[0057] N is the sample size;
[0058] W is the data window size;
[0059] α and β are adjustment coefficients that can be adjusted according to specific circumstances;
[0060] (2) Stratified sampling: the data are divided into low temperature zone, medium temperature zone and high temperature zone, and random sampling is performed in each zone;
[0061] (3) Historical data reliance survey: Use the exponentially weighted moving average (EWMA) to weight historical data and give more weight to recent data. The specific formula is as follows:
[0062] S t =α·X t +(1-α)·S t-1
[0063] Among them, S t is the smoothed value at time t;
[0064] X t is the original data value at time t;
[0065] α is the smoothing coefficient, usually between 0 and 1.
[0066] Furthermore, in step S4, the improved LSTM combined with attention mechanism model includes a CNN layer, a hybrid Attention layer, an LSTM layer, and a fully connected layer;
[0067] The CNN layer is used to convolve the normalized time series data set to extract the time series features of the data and obtain output data output1;
[0068] The hybrid Attention layer combines the self-attention mechanism and the multi-head attention mechanism to input the data output1 into the hybrid Attention layer, and by calculating the attention weight of each time step, the influence of the important feature data affecting the temperature change in the input is highlighted to obtain the output data output2;
[0069] The LSTM layer is used to input the data output2 into the LSTM layer, and use its hidden state to calculate the time series to obtain output data output3, and at the same time use the improved callback function to save the optimal model;
[0070] The fully connected layer is used to input the data output3 calculated by the LSTM layer into the fully connected layer to obtain output4;
[0071] The set epoch is the condition for completing the training. If the number of epochs reaches the standard, the model training ends. Otherwise, continue to train the model according to the above steps.
[0072] The improved callback function includes ModelCheckpoint, EarlyStopping callback function and ReduceLROnPlateau callback function, wherein the ModelCheckpoint is used to save the optimal model, the EarlyStopping callback function is used to monitor the validation set loss, and when the validation set loss does not decrease within several epochs, the training is stopped in advance, and the ReduceLROnPlateau callback function is used to reduce the learning rate when the validation set loss is within several epochs;
[0073] The improved LSTM combined with attention mechanism model also includes an integrated adaptive learning rate adjustment module, which is used to adaptively and dynamically adjust the learning rate according to the loss change of the model during the model training process, and adjust the model in combination with the AdamW optimizer. The formula is as follows:
[0074] αt=α0·1-β2t1-β1tαt=α0·1-β1t1-β2t
[0075] Among them, αt is the learning rate of the tth step, α0 is the initial learning rate, and β1 and β2 are momentum parameters.
[0076] Further, in step S5, the weighted mean square error WMSE is used to assign different weights to data points of different importance, reflecting the prediction performance of the model on key data points;
[0077] The dynamic time warping distance DTW is used to evaluate the matching degree of the model to the time series data by calculating the DTW distance between the predicted sequence and the actual sequence, and is particularly suitable for temperature data with time series dependence;
[0078] The continuous error accumulation CEA is used to evaluate the stability and reliability of the model in long-term prediction by calculating the cumulative error in continuous time periods.
[0079] Furthermore, in step S6, the model deployment method includes a local deployment method and a cloud deployment method. The local deployment method is used to deploy the model on the same network and system and directly called by the application; the cloud deployment method is used to deploy the model using a cloud service platform (AWS Sagemaker, Google AIPlatform, and AzureML), expose the model as a service through REST API, and use any system that can send HTTP requests to query the model and obtain prediction results;
[0080] When receiving prediction requests and using the model to make predictions, a message queue is used to manage data flow to cope with high concurrency scenarios. The system sends the prediction request to the queue, the model takes data from the queue for prediction, and sends the result back.
[0081] Model monitoring includes indicator monitoring, log analysis, and data drift detection. Indicator monitoring refers to using Prometheus and Grafana tools to monitor in real time and regularly evaluate the accuracy, latency, and throughput indicators of the model. Log analysis refers to analyzing possible errors and performance degradation of the model based on the recorded model prediction logs. Data drift detection is used to monitor the statistical characteristics of input data in real time, compare it with the training data, and detect whether there is data drift.
[0082] Data feedback and model optimization include feedback loop, incremental learning and automatic retraining. The feedback loop is used to establish a mechanism to collect model prediction results and actual results, analyze the difference between the prediction results and the actual results, and use them for subsequent model training and optimization. Incremental learning is used to perform incremental feedback learning (IFL) on the model using newly collected data when data drift and model performance degradation are detected. The specific formula for incremental feedback learning is as follows:
[0083]
[0084] Among them, θ is the model parameter, η is the learning rate, L is the loss function, is the gradient of the loss function;
[0085] Automatic retraining means setting trigger conditions. When the trigger conditions are met, CI / CD tools are enabled to automatically start the model retraining process.
[0086] Beneficial effects of the present invention:
[0087] The present invention adopts an improved LSTM combined with an attention mechanism model to process and predict temperature time series data; a convolutional neural network (CNN) is used to extract features from monitoring data, and LSTM learns better from time series data. On the basis of this CNN-LSTM model, the deep learning algorithm attention mechanism is coupled to highlight the influence of features on input effects, and the calculation speed is improved without affecting the accuracy of the model, and the prediction accuracy and stability of the model are further improved. The prediction model has good temperature change prediction ability and wide applicability, and has good MSE, RMSE, WMSE, DTW, CEA and R 2 It can improve the calculation efficiency, be more suitable for the prediction of the temperature change of the koji cellar, improve the temperature monitoring efficiency of the koji fermentation process, ensure the quality of the koji, and improve the digital management level of the koji production process;
[0088] The self-attention mechanism and multi-head attention mechanism are introduced into the LSTM network layer to optimize the state of the LSTM network, making it more adaptable to the periodic and fluctuating characteristics of temperature data and improving the model's ability to process multi-dimensional feature data.
[0089] The introduction of adaptive mechanisms in multiple modules of the LSTM combined with attention mechanism model enables the model to have better dynamic adjustment capabilities, improves the ability to effectively adjust the deviation data, effectively reduces the impact of outliers, improves the flexibility of data adjustment, and greatly ensures the rationality of the data, thereby ensuring the stability of the model operation and the reliability of the predicted data. BRIEF DESCRIPTION OF THE DRAWINGS
[0090] In order to more clearly illustrate the technical solution of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0091] Figure 1 The flowchart of the prediction method is shown in Figure 2.
[0092] Figure 2 Schematic diagram of the improved LSTM combined with attention mechanism model structure;
[0093] Figure 3 Schematic diagram of the model training and prediction evaluation process. DETAILED DESCRIPTION
[0094] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0095] In a specific embodiment of the present invention, Figures 1 to 3 As shown in the figure, a method for predicting the temperature of a wine koji cellar by improving LSTM combined with an attention mechanism includes the following steps:
[0096] S1 Data collection: Collect cellar data such as ambient temperature, humidity, carbon dioxide concentration, time information, climate data and geographic information data from the automatic control system and sensor records, and enter the continuous fluctuation mode CFPR analysis module in real time. The continuous fluctuation mode CFPR analysis module is used to detect abnormal fluctuations. The specific calculation formula of the continuous fluctuation mode CFPR analysis module is as follows:
[0097]
[0098] Among them, X t represents the current observation value, c is a constant term, are model parameters, X t-i is the observed value of the previous i periods, ε t is the error term.
[0099] S2 Data preprocessing: Clean the feature data of the original data set, that is, remove outliers, process missing values, and then normalize the data to meet the input requirements of the model;
[0100] Outliers are removed by using the improved local outlier factor detection algorithm ELOF to remove data generated by erroneous data entry, equipment failures, and atypical experimental conditions, including the following aspects:
[0101] (1) ELOF uses an adaptive distance measurement method to automatically adjust the distance calculation method according to data characteristics. The specific formula is as follows:
[0102]
[0103] Among them, σ k is the standard deviation of the k-th dimension feature;
[0104] (2) ELOF is based on the local adaptive adjustment of density, that is, dynamically adjusts its local density estimation according to the density change of data points in its domain. The specific formula is as follows:
[0105]
[0106] Among them, N k (X i ) is x i k neighbors of j ) is the data point x j The local density of
[0107] (3) ELOF adopts a new penalty function, which comprehensively considers the local density and adaptive distance of data points and accurately penalizes outliers. The penalty function formula is as follows:
[0108]
[0109] The specific formula of the overall loss function is as follows:
[0110]
[0111] Where: L represents the conventional loss function (such as mean square error);
[0112] f(xi;θ) is the prediction model with parameters;
[0113] Penalty(xi) is the penalty function for outliers;
[0114] λ is the coefficient that regulates the influence of the two;
[0115] To handle missing values, we first use interpolation to fill in the missing values, and then further refine the filling results through Locally Weighted Regression (LWR).
[0116] The linear interpolation formula of the interpolation method is as follows:
[0117]
[0118] Where: x i and x j is a data point;
[0119] x k is a missing value;
[0120] t i ,t j For x i and x j The corresponding time point;
[0121] The local weighted regression formula is as follows:
[0122]
[0123] Among them, w i Determined by the kernel function K;
[0124]
[0125] Normalization uses robust normalization (Robust Scaling) combined with adaptive scaling (Adaptive Scaling). The specific formula is as follows:
[0126]
[0127] Among them, X' is the normalized data;
[0128] median(X) is the median of the data set X;
[0129] IOR(X) is the interquartile range, and IOR is the difference between the 75th percentile and the 25th percentile;
[0130] For the normalized data X', adaptive scaling adjustment is performed according to the local statistical characteristics of the data. The specific formula is as follows:
[0131]
[0132] Among them, X” adaptively adjusts the data;
[0133] μ local and σ local are the local mean and standard deviation respectively.
[0134] S3 data set division: According to the set training set, validation set and test set division ratio, adaptive time-aware sampling ATAS is performed on the processed data to obtain the training set, validation set and test set. The division ratio of the training set, validation set and test set is 7:1:2. Adaptive time-aware sampling includes the following steps:
[0135] (1) Dynamic adjustment of data window: The size of the data window is dynamically adjusted according to the fluctuation characteristics of the data. The specific adjustment formula is as follows:
[0136]
[0137] Where σ is the data volatility,
[0138] x i is a data sample,
[0139] x is the sample mean,
[0140] N is the sample size,
[0141] W is the data window size,
[0142] α and β are adjustment coefficients that can be adjusted according to specific circumstances;
[0143] (2) Stratified sampling: the data are divided into low temperature zone, medium temperature zone and high temperature zone, and random sampling is performed in each zone;
[0144] (3) Historical data reliance survey: Use the exponentially weighted moving average (EWMA) to weight historical data and give more weight to recent data. The specific formula is as follows:
[0145] S t =α·X t +(1-α)·S t-1
[0146] Among them, S t is the smoothed value at time t;
[0147] X t is the original data value at time t;
[0148] α is the smoothing coefficient, usually between 0 and 1.
[0149] Adaptive Time-Aware Sampling (ATAS) ensures that time continuity and seasonality effects are reasonably reflected in the data set partitioning. The specific formula is as follows:
[0150] ATAS t =w t ·S(x t ,y t )
[0151] Among them, S(x t ,y t ) is based on the feature x t and target y t The raw score, w t is the time weight, which can be assigned based on the timeliness of the data point;
[0152] S4 Model training and optimization: Use the data training set in step S3 to train the improved LSTM combined with attention mechanism model, and adjust the learning rate, batch size and other parameters by monitoring the training and validation losses to find the best model configuration;
[0153] Based on Python's Keras library, we built an improved LSTM combined with attention mechanism model, and conducted experiments and verifications by adjusting the parameters of the deep learning model to find the best configuration;
[0154] Improving LSTM combined with attention mechanism model training and optimization includes the following steps:
[0155] (1) The CNN layer convolves the normalized time series data set to extract the time series features of the data and obtain the output data output1; the number of convolution kernels filters is set to 64; the convolution kernel size kernel_size is selected to be 5; the 'padding' in the convolution neural network is used to control the edge processing method of the input data in the convolution operation. Selecting 'same' means zero padding at the edge of the input data to keep the output size the same as the input; the sliding stride (stride) of the convolution kernel on the input data selects the default value 1 to retain more information; the activation function (activation) is compared among 'relu', 'tanh', 'sigmoid', and 'softmax', and finally 'tanh' is selected; the operation of the convolution layer is expressed by the following formula:
[0156]
[0157] Where C(t) is the output of the convolutional layer at time step t; X(t) is the value of the input sequence at time step t; K(α) is the weight of the convolution kernel at position α; k is the size of the convolution kernel; b is the bias term;
[0158] The convolution operation will result in a relatively high dimension of the feature map, increasing the complexity of the network and the training cost. Therefore, the present invention introduces a pooling layer to reduce the size of the feature map by taking the maximum value of a set of values in the feature map (maximum pooling) while retaining key feature information. The output Y of the maximum pooling can be expressed as:
[0159] Y(i)=max j∈pool_window X(i·strides+j)
[0160] Where Y(i) is the output of the pooling layer at position i; i represents the position of the output; pool-window represents the set of position indexes in the pooling window; strides represents the step size of the pooling;
[0161] The fully connected layer is used to connect all neural units in the feature map and output the results through the hidden layer;
[0162] The convolutional layer and pooling layer of the CNN model are used to extract the data features of the influencing factors such as temperature, humidity, and carbon dioxide concentration, and the information is abstracted to obtain feature data;
[0163] (2) Input the data output1 into the hybrid attention layer, and by calculating the attention weight of each time step, highlight the influence of the important feature data that affects the temperature change in the input, and obtain the output data output2; wherein, the working process of the hybrid attention layer is: first, the importance score of the element allocation of the model at a given time step t is calculated in the fully connected layer, then, the output value of the previous stage is normalized using the Softmax function to obtain the attention weight, and finally, the weighted input sequence is obtained to obtain the input sequence weighted according to the attention weight at time step t. The calculation formula is as follows:
[0164] Score(X t )=Dense(X t +b)
[0165]
[0166] Weighted_Sequence=Attention_Weights t ·X t
[0167] Where Xt is the element of the input sequence at time step t, Dense is a fully connected layer, W is the weight matrix, and b is the bias term;
[0168] The attention layer is used to weight the features. The attention weight of each time point determines the contribution of the feature at that time point to the final output, so that the model focuses on important time steps related to the task and reduces the dependence on irrelevant time steps.
[0169] (3) Input the data output2 into the LSTM layer, and use its hidden state to calculate the time series to obtain the output data output3. At the same time, use the improved callback functions ModelCheckpoint, EarlyStopping, and ReduceLROnPlateau to create Checkpoints, automatically save the optimal model best_model.h5 during the training process, and call the optimal model in subsequent predictions;
[0170] LSTM (Long Short-Term Memory Network) uses a gated structure, where the input gate allows control of the update of new inputs, the forget gate determines whether to retain or forget historical information, and the output gate controls the final information output;
[0171] (4) The data output3 calculated by the LSTM layer is input into the fully connected layer to obtain output4; the number of neurons in the fully connected layer is selected as 256, the time step is selected as 10, the optimizer is selected as Adam, the learning rate is debugged as 0.01, and the other parameters are selected as the same as the convolutional layer. In addition, the Dropout layer is added to suppress the overfitting phenomenon of LSTM, the dropout is set to 0.2, the loss function 'mean_squared_error' and the optimizer type 'adam' are specified, and the verification data does not participate in the training. The update calculation formula of the LSTM network layer is as follows:
[0172] i t =σ(V i x t +W i h t-1 +b i )
[0173] f t =σ(V f x t +W f h t-1 +b f )
[0174]
[0175] Where, Xt is the input data at time t, V * and W * is the weight matrix, h * is the number of hidden units, b * is the linear bias of the fully connected layer, σ and tanh are the activation functions of sigmoid and tanh respectively; i t 、f t 、c t and O t They are input gate, forget gate, storage unit and output gate. Represents the element-by-element multiplication between vectors. Finally, the output h is calculated through the information in the output gate and the storage unit. t ;
[0176] (5) The training end condition is to complete the set epoch. If the number of epochs reaches the target, the model training ends. Otherwise, the model training continues according to the above steps. The number of epochs is set to 500, that is, the training is performed 500 times. The optimal model with the smallest loss value of the validation set is retained, and the optimal model is used to predict the data of the test set. During the model training process, the Adam optimizer is used in combination with the adaptive learning rate adjustment. The specific formula is as follows:
[0177] αt=α0·1-β2t1-β1tαt=α0·1-β1t1-β2t
[0178] Among them, αt is the learning rate of the tth step, α0 is the initial learning rate, and β1 and β2 are momentum parameters.
[0179] S5 Performance evaluation: Use the test set to evaluate the prediction performance of the model. The evaluation indicators of model performance include weighted mean square error (WMSE), dynamic time warping distance (DTW), and continuous error accumulation (CEA). Based on the evaluation results, further adjust the model structure or parameters.
[0180] Among them, the weighted mean square error (WMSE) is used to assign different weights to data points of different importance, reflecting the prediction performance of the model on key data points; the dynamic time warping distance (DTW) is used to evaluate the matching degree of the model to the time series data by calculating the DTW distance between the predicted sequence and the actual sequence, which is particularly suitable for temperature data with time series dependence; the continuous error accumulation (CEA) is used to evaluate the stability and reliability of the model in long-term prediction by calculating the cumulative error in a continuous time period.
[0181] S6 Deployment and Feedback: Deploy the trained model to the production environment, receive prediction requests, use the model for prediction services, monitor the model, implement incremental feedback learning (IFL), collect real-time data feedback to the model, optimize the model, fine-tune the model, and continuously optimize the model structure and parameters.
[0182] Model deployment methods include local deployment and cloud deployment. The local deployment method is used to deploy the model on the same network and system and directly called by the application; the cloud deployment method is used to deploy the model using cloud service platforms (AWS Sagemaker, Google AIPlatform, and Azure ML), expose the model as a service through REST API, and use any system that can send HTTP requests to query the model and obtain prediction results.
[0183] When receiving prediction requests and using the model to make predictions, a message queue is used to manage data flow to cope with high concurrency scenarios. The system sends the prediction request to the queue, the model takes data from the queue for prediction, and sends the result back.
[0184] Model monitoring includes indicator monitoring, log analysis, and data drift detection. Indicator monitoring refers to using Prometheus and Grafana tools to monitor in real time and regularly evaluate the accuracy, latency, and throughput indicators of the model. Log analysis refers to analyzing possible errors and performance degradation of the model based on the recorded model prediction logs. Data drift detection is used to monitor the statistical characteristics of input data in real time, compare it with the training data, and detect whether there is data drift.
[0185] Data feedback and model optimization include feedback loop, incremental learning and automatic retraining. The feedback loop is used to establish a mechanism to collect model prediction results and actual results, analyze the difference between the prediction results and the actual results, and use them for subsequent model training and optimization. Incremental learning is used to perform incremental feedback learning (IFL) on the model using newly collected data when data drift and model performance degradation are detected. The specific formula for incremental feedback learning is as follows:
[0186]
[0187] Among them, θ is the model parameter, η is the learning rate, L is the loss function, is the gradient of the loss function;
[0188] Automatic retraining means setting trigger conditions. When the trigger conditions are met, CI / CD tools are enabled to automatically start the model retraining process.
[0189] Finally, it should be noted that the above are only preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, it is still possible for those skilled in the art to modify the technical solutions described in the aforementioned embodiments, or to make equivalent substitutions for some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for predicting the temperature of a wine koji cellar by improving LSTM combined with attention mechanism, characterized in that: The steps include: S1 Data Collection: Collect cellar data from the automated control system and sensor records, and enter the continuous fluctuation mode CFPR analysis module in real time. The continuous fluctuation mode CFPR analysis module is used to detect abnormal fluctuations; S2 Data preprocessing: Clean the feature data of the original data set, that is, remove outliers, process missing values, and then normalize the data to meet the input requirements of the model; S3 data set division: according to the set training set, validation set and test set division ratio, adaptive time-aware sampling ATAS is performed on the data processed in step S2 to obtain the training set, validation set and test set; S4 model training and optimization: Use the training set described in step S3 to train the improved LSTM combined with attention mechanism model, and adjust the learning rate and batch size parameters by monitoring the training and validation losses to find the best model configuration; S5 Performance evaluation: Use the test set to evaluate the prediction performance of the model. The evaluation indicators of model performance include weighted mean square error (WMSE), dynamic time warping distance (DTW), and continuous error accumulation (CEA). Based on the evaluation results, further adjust the model structure or parameters. S6 Deployment and Feedback: Deploy the trained model to the production environment, receive prediction requests, use the model for prediction services, monitor the model, implement incremental feedback learning (IFL), collect real-time data and feed it back to the model, optimize the model, fine-tune the model, and continuously optimize the model structure and parameters.
2. According to claim 1, a method for predicting the temperature of a wine koji cellar by improving LSTM combined with an attention mechanism, characterized in that: In step S1, the cellar data includes temperature data and humidity data inside the cellar and the external environment, carbon dioxide concentration generated during the fermentation process, time information of data collection, climate data and geographic information data; The specific calculation formula of the continuous fluctuation mode CFPR analysis module is as follows: Among them, X t represents the current observation value, c is a constant term, φ i are model parameters, X t-i is the observed value of the previous i periods, ε t is the error term.
3. According to claim 1, a method for predicting the temperature of a wine koji cellar by improving LSTM combined with an attention mechanism, characterized in that: In step S2, outliers are removed by using an improved local outlier factor detection algorithm ELOF to remove data generated by incorrect data entry, equipment failure, and atypical experimental conditions, including the following aspects: (1) ELOF uses an adaptive distance measurement method to automatically adjust the distance calculation method according to data characteristics. The specific formula is as follows: Among them, σ k is the standard deviation of the k-th dimension feature; (2) ELOF is based on the local adaptive adjustment of density, that is, dynamically adjusts its local density estimation according to the density change of data points in its domain. The specific formula is as follows: Among them, N k (X i ) is x i k neighbors of j ) is the data point x j The local density of (3) ELOF adopts a new penalty function, which comprehensively considers the local density and adaptive distance of data points and accurately penalizes outliers. The penalty function formula is as follows: The specific formula of the overall loss function is as follows: Where: L represents the conventional loss function (such as mean square error); f(xi;θ) is the prediction model with parameters; Penalty(xi) is the penalty function for outliers; λ is the coefficient that regulates the influence of the two; To handle missing values, interpolation is first used to fill in the missing values, and then the filling results are further refined through local weighted regression; The interpolation method uses linear, quadratic and spline interpolation through known data points, where the linear interpolation formula is as follows: Where: x i and x j is a data point; x k is a missing value; t i ,t j For x i and x j The corresponding time point; The local weighted regression formula is as follows: Among them, w i Determined by the kernel function K; Data normalization uses robust normalization combined with adaptive scaling. Robust normalization is used to scale the data to the median and interquartile range (IQR). Adaptive scaling is then used to dynamically adjust the scaling range based on the local statistical characteristics of the data. The specific formula for robust normalization is as follows: Among them, X' is the normalized data; median(X) is the median of the data set X; IOR(X) is the interquartile range, and IOR is the difference between the 75th percentile and the 25th percentile; For the normalized data X', adaptive scaling adjustment is performed according to the local statistical characteristics of the data. The specific formula is as follows: Among them, X” adaptively adjusts the data; μ local and σ local are the local mean and standard deviation respectively.
4. According to claim 1, a method for predicting the temperature of a wine koji cellar by improving LSTM combined with an attention mechanism, characterized in that: In step S3, the division ratio of the training set, the validation set and the test set is 7:1:2, and the adaptive time-aware sampling ATAS includes the following steps: (1) Dynamic adjustment of data window: The size of the data window is dynamically adjusted according to the fluctuation characteristics of the data. The specific adjustment formula is as follows: W=α·σ+β Where, σ is the data volatility; x i is a data sample; x is the sample mean; N is the sample size; W is the data window size; α and β are adjustment coefficients that can be adjusted according to specific circumstances; (2) Stratified sampling: the data are divided into low temperature zone, medium temperature zone and high temperature zone, and random sampling is performed in each zone; (3) Historical data reliance survey: Use the exponentially weighted moving average (EWMA) to weight historical data and give more weight to recent data. The specific formula is as follows: S t =α·X t +(1-α)·S t-1 Among them, S t is the smoothed value at time t; X t is the original data value at time t; α is the smoothing coefficient, usually between 0 and 1.
5. According to claim 1, a method for predicting the temperature of a wine koji cellar by improving LSTM combined with an attention mechanism, characterized in that: In step S4, the improved LSTM combined with attention mechanism model includes a CNN layer, a hybrid Attention layer, an LSTM layer, and a fully connected layer; The CNN layer is used to convolve the normalized time series data set to extract the time series features of the data and obtain output data output1; The hybrid Attention layer combines the self-attention mechanism and the multi-head attention mechanism to input the data output1 into the hybrid Attention layer, and by calculating the attention weight of each time step, the influence of the important feature data affecting the temperature change in the input is highlighted to obtain the output data output2; The LSTM layer is used to input the data output2 into the LSTM layer, and use its hidden state to calculate the time series to obtain output data output3, and at the same time use the improved callback function to save the optimal model; The fully connected layer is used to input the data output3 calculated by the LSTM layer into the fully connected layer to obtain output4; The set epoch is the condition for completing the training. If the number of epochs reaches the standard, the model training ends. Otherwise, continue to train the model according to the above steps. The improved callback function includes ModelCheckpoint, EarlyStopping callback function and ReduceLROnPlateau callback function, wherein the ModelCheckpoint is used to save the optimal model, the EarlyStopping callback function is used to monitor the validation set loss, and when the validation set loss does not decrease within several epochs, the training is stopped in advance, and the ReduceLROnPlateau callback function is used to reduce the learning rate when the validation set loss is within several epochs; The improved LSTM combined with attention mechanism model also includes an integrated adaptive learning rate adjustment module, which is used to adaptively and dynamically adjust the learning rate according to the loss change of the model during the model training process, and adjust the model in combination with the AdamW optimizer. The formula is as follows: αt=α0·1-β2t1-β1tαt=α0·1-β1t1-β2t Among them, αt is the learning rate of the tth step, α0 is the initial learning rate, and β1 and β2 are momentum parameters.
6. According to claim 1, a method for predicting the temperature of a wine koji cellar by improving LSTM combined with an attention mechanism, characterized in that: In step S5, the weighted mean square error WMSE is used to assign different weights to data points of different importance, reflecting the prediction performance of the model on key data points; The dynamic time warping distance DTW is used to evaluate the matching degree of the model to the time series data by calculating the DTW distance between the predicted sequence and the actual sequence, and is particularly suitable for temperature data with time series dependence; The continuous error accumulation CEA is used to evaluate the stability and reliability of the model in long-term prediction by calculating the cumulative error in continuous time periods.
7. According to claim 1, a method for predicting the temperature of a wine koji cellar by improving LSTM combined with an attention mechanism, characterized in that: In step S6, the model deployment method includes a local deployment method and a cloud deployment method. The local deployment method is used to deploy the model on the same network and system and directly called by the application; the cloud deployment method is used to use the cloud service platform (AWS Sagemaker, Google AIPlatform and Azure ML) to deploy the model, expose the model as a service through REST API, and use any system that can send HTTP requests to query the model and obtain the prediction results; When receiving prediction requests and using the model to make predictions, a message queue is used to manage data flow to cope with high concurrency scenarios. The system sends the prediction request to the queue, the model takes data from the queue for prediction, and sends the result back. Model monitoring includes indicator monitoring, log analysis, and data drift detection. Indicator monitoring refers to using Prometheus and Grafana tools to monitor in real time and regularly evaluate the accuracy, latency, and throughput indicators of the model. Log analysis refers to analyzing possible errors and performance degradation of the model based on the recorded model prediction logs. Data drift detection is used to monitor the statistical characteristics of input data in real time, compare it with the training data, and detect whether there is data drift. Data feedback and model optimization include feedback loops, incremental learning, and automatic retraining. The feedback loop is used to establish a mechanism to collect model prediction results and actual results, analyze the differences between the prediction results and the actual results, and use them for subsequent model training and optimization. Incremental learning is used to perform incremental feedback learning (IFL) on the model using newly collected data when data drift and model performance degradation are detected. The specific formula for incremental feedback learning is as follows: Among them, θ is the model parameter, η is the learning rate, L is the loss function, is the gradient of the loss function; Automatic retraining means setting trigger conditions. When the trigger conditions are met, CI / CD tools are enabled to automatically start the model retraining process.
Citation Information
Cited By
Self-adaptive pressure adjusting device for fermentation tank
CN118909763A
Die production information data analysis method and system
CN119151396A
Industrial control network threat trend detection method and system based on time sequence characteristics
CN119210897A
Lightning arrester temperature compensation method and system based on DSA-CTCM network
CN119514364A
A lightning arrester temperature compensation method and system based on DSA-CTCM network
CN119514364B
