Machine tool thermal error prediction modeling method and device based on dual attention mechanism and hybrid deep learning network, and electronic equipment

By employing a dual attention mechanism and a hybrid deep learning network, the system automatically identifies temperature-sensitive points and reinforces key temperature rise moments, thus resolving the nonlinear relationship and hysteresis issues in the thermal error prediction model and achieving accurate prediction and improved stability of machine tool thermal errors.

CN121637374APending Publication Date: 2026-03-10NANJING UNIV OF AERONAUTICS & ASTRONAUTICS
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511487438.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-17
Publication Date
2026-03-10

AI Technical Summary

Technical Problem

Existing thermal error prediction models are unable to describe the nonlinear relationship between temperature and thermal error. They are sensitive to the placement of temperature measurement points and cannot capture the critical period of thermal hysteresis, resulting in low model accuracy and poor stability.

Method used

A method based on dual attention mechanism and hybrid deep learning network is adopted. The temperature sensitive point is automatically identified by the input attention mechanism, the spatial feature is extracted by the convolutional neural network, the temporal feature is mined by the long short-term memory neural network, and the key temperature rise moment is enhanced at the output to suppress hysteresis noise, so as to achieve deep fusion of spatial and temporal features.

Benefits of technology

The model's stability and generalization ability under different working conditions and measurement point configurations have been improved, enabling accurate prediction of machine tool thermal errors, reducing reliance on temperature measurement point optimization, and enhancing prediction accuracy and robustness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121637374A_ABST
    Figure CN121637374A_ABST
Patent Text Reader

Abstract

The invention discloses a machine tool thermal error prediction modeling method and device based on a double attention mechanism and a hybrid deep learning network and electronic equipment. The method comprises the steps that Pt100 sensors are arranged on a spindle motor, a front bearing, a rear bearing and an environment to collect temperature, and an eddy current displacement sensor synchronously obtains thermal errors; automatically identifying temperature sensitive points and distributing weights by using an input end attention mechanism; spatial features are extracted through CNN, time features are extracted through LSTM, and finally key temperature rise moments are strengthened through an output end attention mechanism. Training takes MAE as loss, RMSE evaluation is carried out, and Dropout is embedded to prevent overfitting. Experiments show that the model can control the prediction error within the range under the rotating speed change working condition, has high precision, robustness and generalization ability, and can be widely applied to real-time prediction and compensation of the thermal error of the numerical control machine tool.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of thermal error prediction technology, and relates to a machine tool thermal error prediction modeling method, device and electronic device based on dual attention mechanism and hybrid deep learning network. Background Technology

[0002] With the rapid development of global manufacturing, intelligent manufacturing has become a key variable shaping the global industrial competitive landscape. In modern manufacturing, CNC machine tools, as the "mother machines of industry," are undeniably important, with high-end CNC machine tools finding widespread application in aerospace, military, and automotive industries. Under current circumstances, the advancement of CNC machine tools towards precision and ultra-precision, and high-speed and ultra-high-speed operation is an inevitable trend. This places extremely high demands on the machining accuracy and stability of CNC machine tools. Statistics show that thermal errors caused by temperature account for 40%-70% of the total error in high-precision CNC machine tools. However, due to the causes and characteristics of thermal errors, it is difficult to establish an accurate thermal error prediction model.

[0003] To address the impact of temperature-induced errors on machine tool machining accuracy under complex processing conditions, an efficient, convenient, robust, and generalizable prediction model is needed. Currently, thermal error prediction models for spindle systems are mainly divided into mechanistic models and data-driven models. Mechanistic models are based on the physical principles of the spindle system, with each component having a clear physical meaning. Models built on the same mechanism can be applied to thermal error prediction under different operating conditions, exhibiting strong generalization ability. However, model construction requires a deep understanding of the system mechanism and suffers from difficulties in parameter acquisition and high computational complexity. Data-driven thermal error models are mostly mathematical models with temperature as input and thermal error as output, although some studies use spindle speed, motor current, and historical information as input. Data-driven models are often used to solve problems that mechanistic models struggle with due to their low requirement for prior knowledge and strong data adaptability. However, because they rely on data for model construction, they often suffer from insufficient generalization ability when the data is outside the range or of poor quality.

[0004] Existing related thermal error prediction technologies mainly suffer from the following shortcomings:

[0005] 1. Traditional thermal error prediction models are designed for linear problems, but the relationship between temperature and thermal error is non-linear, resulting in low model accuracy and poor reliability.

[0006] 2. Deep learning models overcome the shortcomings of traditional methods to some extent, but simple neural network models often struggle to fully capture the complex characteristics of thermal errors, resulting in limited improvement in prediction performance.

[0007] 3. The machine tool thermal error prediction model is greatly affected by the temperature measurement points. The establishment and accuracy of the model depend on the optimized selection and layout of the temperature-sensitive points of the machine tool.

[0008] 4. Temperature changes during machine tool processing have a strong lag, making it difficult to capture critical time points. Summary of the Invention

[0009] The purpose of this invention is to overcome the shortcomings of existing thermal error prediction models, such as difficulty in describing the nonlinear relationship between temperature and thermal error, sensitivity to the arrangement of temperature measurement points, and inability to capture key periods of thermal hysteresis. This invention provides a machine tool thermal error prediction modeling method, device, and electronic device based on a dual-attention mechanism and a hybrid deep learning network. Specifically: the input attention first dynamically weights the temperature sequence of multiple measurement points, automatically locking sensitive locations; the convolutional neural network (CNN) then extracts the spatial distribution features of the temperature field, and the long short-term memory neural network (LSTM) further mines the thermal error variation patterns along the time dimension; the output attention further assigns high weights to key temperature rise moments to suppress hysteresis noise. The dual-attention (DAT) mechanism collaboratively achieves deep fusion of spatial and temporal features, enabling the model to maintain excellent stability and generalization ability under different operating conditions and measurement point configurations, thus achieving accurate prediction of machine tool thermal errors under complex machining conditions.

[0010] To solve the above problems, the present invention adopts the following technical solution.

[0011] The present invention provides a machine tool thermal error prediction modeling method based on a dual attention mechanism and a hybrid deep learning network, comprising the following steps:

[0012] S1. Acquire temperature data and thermal error data of the machine tool spindle at different temperature measurement points under various working conditions, including arranging multiple Pt100 platinum resistance temperature sensors at the motor, front bearing, rear bearing and the surrounding environment of the machine tool spindle, and collecting the axial thermal elongation data of the spindle in real time with an eddy current displacement sensor.

[0013] S2. The collected data is sent to the input attention mechanism to assign dynamic weights to the temperature data of the multiple temperature measurement points and automatically identify temperature-sensitive points.

[0014] S3. Input the weighted temperature data and thermal error data into a convolutional neural network to extract spatial features and obtain a spatial feature vector;

[0015] S4. Input the spatial feature vector into a long short-term memory neural network (LSTM) to extract temporal features and obtain a spatiotemporal feature vector;

[0016] S5. The extracted spatiotemporal feature vector is fed to the output attention mechanism to assign dynamic weights to the thermal error data at different time points, strengthen the features of key temperature rise moments, and suppress interference from irrelevant time points.

[0017] S6. Based on the spatial features, temporal features, input attention weights, and output attention weights, the model is trained to predict the thermal error of the machine tool spindle.

[0018] The aforementioned dual attention mechanism includes an output-side attention mechanism and an input-side attention mechanism module with identical structures. Different importance levels are defined at both the feature level and the temporal level to improve the model's prediction accuracy. The output-side attention layer needs to combine the input and output values ​​of the LSTM network. The formulas for its similarity calculation layer, weight allocation layer, and feature reconstruction layer are shown below:

[0019]

[0020]

[0021]

[0022] in, Indicates the weight value; Indicates in The weight of each moment; express Output value of the time-mapping model; Indicates the feature number;

[0023] In S1:

[0024] The Pt100 platinum resistance temperature sensor is positioned around the circumference of the spindle motor housing, the outer ring of the front bearing, the outer ring of the rear bearing, and the ambient temperature of the machine tool. It has a temperature resolution of 0.1℃, a temperature accuracy of ±0.5℃, and a temperature acquisition range of 20-40℃. The eddy current displacement sensor is installed at the center of the front end face of the spindle, with a measurement range of [missing information]. Error resolution The error accuracy is 0.5% × measurement range; temperature data and thermal error data are sampled synchronously at a sampling frequency of not less than 10Hz, and the sampling is continuously collected for a duration of not less than the machine tool thermal balance cycle to obtain the original dataset; the original dataset is preprocessed by linear interpolation of missing values, removal of outliers using the 3σ criterion, and normalization to construct a standard dataset.

[0025] Specifically, in step S2, the process of sending the collected data to the input attention mechanism assigns dynamic weights to the temperature data of the multiple temperature measurement points and automatically identifies temperature-sensitive points; this specifically includes:

[0026] S2.1 The similarity calculation layer obtains the similarity between features by calculating the attention score of the input features. The formula is as follows:

[0027]

[0028] in, Indicates feature similarity; Indicates the characteristics of the input temperature sequence; Indicates the weight value; Indicates the bias value; Indicates the feature number;

[0029] S2.2, The Softmax weight allocation layer uses the Softmax function to transform the correlation coefficients output by the previous layer into weights. The formula is as follows:

[0030]

[0031] in, Indicate feature weights; Indicates the length of the input feature vector;

[0032] S2.3 The feature reconstruction layer obtains the output features of the attention mechanism by weighting the input features with the obtained feature weights. The formula is as follows:

[0033]

[0034] in, This represents the output features of the convolutional layer.

[0035] Specifically, in step S3, the step of inputting the weighted temperature data and thermal error data into a convolutional neural network to extract spatial features and obtain a spatial feature vector includes:

[0036] S3.1. Convolutional layers use convolution kernels to perform convolution operations on the input feature vectors, and simultaneously use non-linear activation functions to construct output features. The output of each convolutional layer is the result of convolving its input features, and its formula is:

[0037]

[0038] in, Represents the convolution kernel; Indicates the bias value of the convolutional layer; Receptive field representing temperature feature learning; Indicates the activation function; Indicates the convolutional layer number of the model; Indicates the feature index of the current layer; Indicates the feature index of the previous layer;

[0039] S3.2 The ReLU function is selected as the nonlinear activation function, and its formula is as follows:

[0040]

[0041] in, Represents the input variables of the function;

[0042] S3.3 Pooling layers reduce the dimensionality of features by decreasing the size of the feature vectors, preserving as much original information as possible. Max pooling is used, and its formula is:

[0043]

[0044] in, Indicates weight; Indicates the pooling layer bias value;

[0045] S3.4. The fully connected layer unfolds a multi-dimensional feature map into a single-dimensional feature vector. Its formula is:

[0046]

[0047] in, This represents the output features of the fully connected layer, i.e., the temperature features after processing by the convolutional neural network; , These represent the weight and bias values ​​of the fully connected layer, respectively.

[0048] Specifically, in step S4, the step of inputting the spatial feature vector into a Long Short-Term Memory (LSTM) neural network to extract temporal features and obtain a spatiotemporal feature vector includes:

[0049] S4.1 The cell structure of the LSTM model includes a storage cell and three gates: a forget gate, an input gate, and an output gate, to regulate which information in the information flow must be "forgotten" and which information must be "remembered," thereby learning long-term dependencies in the data; the central component in the cell is the cell state. This is to enable information transmission within the unit;

[0050] S4.2, Forget Gate Activation Vector Used to control The formula for determining which information from the cell state should be discarded is as follows:

[0051]

[0052] in, This indicates hidden information from the previous moment; , Represents the weight matrix; Represents the bias matrix; Indicates the activation function;

[0053] S4.3, Input gate activation vector Used together with cell state for control Stored in cell state at all times New information is obtained from the forget gate and input gate temperature feature sequence information. The state unit of the current update state is calculated. Its formula is:

[0054]

[0055]

[0056]

[0057] in, , , , Indicates the weight value; , Indicates the bias value;

[0058] S4.4, Output gate activation vector control The formula for determining how many unit state information outputs as hidden state information at any given time is:

[0059]

[0060]

[0061] in, This represents hidden information at the current moment. , Represents the weight matrix; This represents the bias matrix.

[0062] Specifically, in step S5, the output-end attention mechanism generates an attention weight for each time point by calculating the contribution of thermal error data at different time points to the current prediction result; the greater the contribution, the higher the weight. The output-end attention mechanism has the same structure as the input-end attention mechanism, including a similarity calculation layer, a Softmax weight allocation layer, and a feature reconstruction layer, specifically:

[0063] Similarity calculation layer:

[0064]

[0065] in, Indicates the weight value;

[0066] S5.2, Softmax weight allocation layer:

[0067]

[0068] in, Indicates in The weight of each moment;

[0069] S5.3 Feature Reconstruction Layer:

[0070]

[0071] in, express Output value of the time-mapping model; Indicates the feature number.

[0072] Specifically, in step S6, the CNN-LSTM module of the network model includes a convolutional neural network and a long short-term memory neural network; the convolutional neural network is used to extract the spatial features of the temperature data, and then connected with the LSTM network to obtain the temporal features of the temperature data; the model is trained based on the spatial features, temporal features, input attention weights, and output attention weights to predict the thermal error of the machine tool spindle. During the training and testing of the model, mean absolute error and root mean square error are introduced to evaluate the predictive performance of the model, specifically including:

[0073] S6.1 During model training, the Mean Absolute Error (MAE) is used as the loss function, and its formula is as follows:

[0074]

[0075] in, Represents the actual value; Indicates the predicted value; Indicates the number of samples;

[0076] S6.2 During the testing process, the root mean square error (RMSE) is used to determine the difference between the predicted value and the true value. The smaller the RMSE, the closer the predicted value is to the true value, and the better the prediction effect. The formula is as follows:

[0077] .

[0078] The present invention provides a machine tool thermal error prediction modeling device based on a dual attention mechanism and a hybrid deep learning network, comprising:

[0079] The data acquisition module includes multiple Pt100 platinum resistance temperature sensors arranged at various points on the machine tool spindle motor, front bearing, rear bearing, and the surrounding environment. An eddy current displacement sensor is used to collect real-time axial thermal elongation data of the spindle. The Pt100 platinum resistance temperature sensors are positioned around the circumference of the spindle motor housing, the outer ring of the front bearing, the outer ring of the rear bearing, and the ambient temperature of the machine tool. The temperature resolution is 0.1℃, the temperature accuracy is ±0.5℃, and the temperature acquisition range is 20-40℃. The eddy current displacement sensor is installed at the center of the front end face of the spindle, and its measurement range is [missing information]. Error resolution The error accuracy is 0.5% × measurement range; temperature data and thermal error data are sampled synchronously at a sampling frequency of not less than 10Hz, and the sampling is continuously collected for a duration of not less than the machine tool thermal balance cycle to obtain the original dataset; the original dataset is preprocessed by linear interpolation of missing values, removal of outliers using the 3σ criterion, and normalization to construct a standard dataset;

[0080] The temperature identification module is used to send the collected data to the input attention mechanism, assign dynamic weights to the temperature data of the multiple temperature measurement points, and automatically identify temperature-sensitive points.

[0081] The spatial feature module is used to input the weighted temperature data and thermal error data into the convolutional neural network to extract spatial features and obtain a spatial feature vector.

[0082] The spatiotemporal feature module is used to input the spatial feature vector into a long short-term memory neural network to extract temporal features and obtain a spatiotemporal feature vector.

[0083] The interference suppression module is used to send the extracted spatiotemporal feature vector to the output attention mechanism, assign dynamic weights to the thermal error data at different time points, strengthen the features of key temperature rise moments, and suppress interference from irrelevant time points.

[0084] The model training module is used to train the model based on the spatial features, temporal features, input attention weights, and output attention weights to predict the thermal error of the machine tool spindle.

[0085] The dual attention mechanism includes an output-side attention mechanism and an input-side attention mechanism module with the same structure. Different importance levels are defined at both the feature level and the temporal level to improve the model's prediction accuracy. The output-side attention layer needs to combine the input and output values ​​of the LSTM network. The formulas for its similarity calculation layer, weight allocation layer, and feature reconstruction layer are shown below:

[0086]

[0087]

[0088]

[0089] in, Indicates the weight value; Indicates in The weight of each moment; express Output value of the time-mapping model; Indicates the feature number.

[0090] An electronic device according to the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the machine tool thermal error prediction modeling method based on a dual attention mechanism and a hybrid deep learning network as described above.

[0091] The present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, it implements the machine tool thermal error prediction modeling method based on a dual attention mechanism and a hybrid deep learning network as described above.

[0092] Compared with the prior art, the present invention has the following advantages and beneficial effects:

[0093] 1. By introducing an attention mechanism at the output, a three-level network consisting of a similarity calculation layer, a Softmax weight allocation layer, and a feature reconstruction layer is constructed. This allows for real-time quantification of the correlation between each measurement point and the current thermal error, generating dynamic weights of 0 to 1. These weights are then multiplied point-by-point by the five Pt100 temperature sequences to form a reconstructed input that enhances sensitive points and suppresses redundant points. Experimental results show that even when the combination of temperature measurement points changes, it can still maintain good prediction results in the new combination, with a maximum RMSE fluctuation of [value missing]. The maximum fluctuation in RMSE in the inattentive control group was... This indicates that the process of optimizing temperature measurement points can be omitted without sacrificing accuracy, thus overcoming the bottleneck of being greatly affected by temperature measurement points to a certain extent.

[0094] 2. A cascaded CNN-LSTM hybrid neural network structure is used. First, two 3x3 convolutional-max-pooling modules spatially scan the input temperature matrix. After the convolutional blocks, the feature map size is halved but local thermal gradient information is preserved. Then, the flattened 32-dimensional spatial features are fed into two LSTM layers with 64 and 16 hidden units respectively. Forget gates, input gates, and output gates are used to capture the thermal inertia of the data. This cascaded network structure enables the full extraction of spatial and temporal information contained in the data, significantly improving the accuracy and precision of feature extraction, thereby effectively improving the accuracy of the prediction results.

[0095] 3. By introducing an attention mechanism at the output end, a three-level network is constructed, consisting of a similarity calculation layer, a Softmax weight allocation layer, and a feature reconstruction layer. This allows for real-time quantification of the contribution of thermal error data at different time points within the same batch of input data to the current prediction result, generating dynamic weights ranging from 0 to 1. These weights are multiplied by the thermal error data at each time point to extract key temperature rise moments and suppress lag noise. The attention mechanism at the output end enables the automatic learning of which historical information is more critical, while amplifying the contribution of thermal errors during critical abrupt changes such as start-up, shutdown, blade changes, and speed adjustments, thereby improving the model's ability to fit non-stationary segments.

[0096] 4. By introducing a dual attention mechanism into the neural network, the weight ratio of each factor can be flexibly adjusted based on the actual situation, resulting in high flexibility. Furthermore, by using machine tool thermal error data under different speed conditions as training samples to train the target model, the same model can be used to predict thermal errors under multiple operating conditions. The model has high versatility and robustness, and its prediction accuracy is also high. Attached Figure Description

[0097] Figure 1 This is a flowchart of an embodiment of the machine tool thermal error prediction modeling method based on dual attention mechanism and hybrid deep learning network of the present invention.

[0098] Figure 2 This is a schematic diagram of the attention mechanism structure in one embodiment of the present invention.

[0099] Figure 3 This is a schematic diagram of the CNN convolutional neural network model structure in one embodiment of the present invention.

[0100] Figure 4 This is a schematic diagram of the LSTM (Long Short-Term Memory) neural network model structure in one embodiment of the present invention.

[0101] Figure 5 This is a schematic diagram of the overall architecture of the prediction model in one embodiment of the present invention.

[0102] Figure 6 This is a schematic diagram of the prediction results of the prediction model in one embodiment of the present invention, wherein the solid line represents the thermal error measurement data, the dashed line represents the predicted value of the model established by the present invention, and the dotted line represents the residual between the measured value and the predicted value.

[0103] Figure 7 This is a schematic diagram comparing the root mean square error of an embodiment of the present invention with that of CNN-LSTM, CNN, and LSTM models when the combination of temperature measurement points changes. Detailed Implementation

[0104] This invention discloses a method, apparatus, and electronic device for predicting and modeling machine tool thermal errors based on a dual attention mechanism and a hybrid deep learning network. The method includes: firstly, during machine tool operation, arranging Pt100 temperature sensors at multiple locations such as the machine tool spindle motor, front bearing, rear bearing, and ambient temperature to measure temperature signals; and secondly, using an eddy current displacement sensor to record axial thermal elongation in real time to measure thermal error signals. Then, the data is preprocessed, with missing values ​​filled in using linear interpolation, and abnormal data values ​​are processed using... First, data is eliminated based on established principles, and other data is normalized. Second, a hybrid neural network model incorporating a dual attention mechanism is established. A set of processed data is selected as the input for model training. The input layer's attention mechanism first assigns weights to temperature data obtained from different temperature measurement points, thus automatically selecting temperature-sensitive points. Its advantage lies in eliminating the need for pre-selection of temperature measurement points and providing greater attention to temperature measurement points with higher correlation, which is more conducive to improving accuracy. The weighted feature vector is then input into the CNN-LSTM model to extract spatiotemporal features, and the model is trained through automatic updates of the weight matrix during operation. Subsequently, the feature-extracted vector is input into the output layer's attention mechanism to assign dynamic weights to thermal error data at different time points, strengthening features at key temperature rise moments and suppressing interference from irrelevant time points. Finally, the trained model is tested using test set data. Experimental results show that the machine tool thermal error prediction modeling method of this invention can achieve accurate prediction under complex processing conditions and has good robustness and generalization ability.

[0105] This invention organically combines attention mechanisms and neural network models and applies them to thermal error prediction, solving the main defects of current thermal error prediction models. It can accurately model the nonlinear relationship between temperature and thermal error, and solves the problems of difficulty in selecting temperature sensitive points and capturing key time points, thus showing good application prospects.

[0106] The present invention will now be described in further detail with reference to the accompanying drawings.

[0107] Figure 1 This is a flowchart of an embodiment of the machine tool thermal error prediction modeling method based on a dual attention mechanism and a hybrid deep learning network, according to the present invention. Figure 1 As shown, the method in this embodiment includes the following steps:

[0108] S1. Obtain temperature data and spindle thermal error data at different temperature measurement points under various working conditions of the machine tool spindle.

[0109] S2. The collected data is sent to the input attention mechanism to assign dynamic weights to the temperature data of the multiple temperature measurement points and automatically identify temperature-sensitive points.

[0110] S3. Input the weighted temperature data and thermal error data into the convolutional neural network to extract spatial features and obtain the spatial feature vector.

[0111] S4. Input the spatial feature vector into a long short-term memory neural network to extract time features and obtain a spatiotemporal feature vector.

[0112] S5. The extracted spatiotemporal feature vector is fed to the output attention mechanism to assign dynamic weights to the thermal error data at different time points, strengthen the features of key temperature rise moments, and suppress interference from irrelevant time points.

[0113] S6. Based on the spatial features, temporal features, input attention weights, and output attention weights, the model is trained to predict the thermal error of the machine tool spindle.

[0114] Specifically, in step S1, multiple Pt100 platinum resistance temperature sensors are arranged at the motor, front bearing, rear bearing, and surrounding environment of the machine tool spindle, and eddy current displacement sensors are used to collect the axial thermal elongation data of the spindle in real time, including:

[0115] S1.1 The Pt100 platinum resistance temperature sensor is positioned around the circumference of the spindle motor housing, the outer ring of the front bearing, the outer ring of the rear bearing, and the ambient temperature of the machine tool. It has a temperature resolution of 0.1℃, a temperature accuracy of ±0.5℃, and a temperature acquisition range of 20-40℃. The eddy current displacement sensor is installed at the center of the front end face of the spindle, with a measurement range of... Error resolution Error accuracy 0.5% × measurement range.

[0116] S1.2. The temperature data and thermal error data are sampled synchronously at a sampling frequency of not less than 10Hz, and the sampling is continuously collected for a duration of not less than the machine tool thermal balance cycle to obtain the original dataset; the original dataset is preprocessed by linear interpolation of missing values, removal of outliers using the 3σ criterion, and normalization to construct a standard dataset.

[0117] Specifically, the attention mechanisms in steps S2 and S5 are as follows: Figure 2 As shown, its essence is to filter out irrelevant information and amplify relevant information by mining the internal correlations of features, thereby enhancing the importance of key information. Weights are dynamically assigned to the input features. The input attention mechanism assigns different weights to temperature data from different measurement points, thus obtaining weighted reconstructed features, specifically including:

[0118] S2.1 The similarity calculation layer obtains the similarity between features by calculating the attention score of the input features. The formula is as follows:

[0119]

[0120] in, Indicates feature similarity; Indicates the characteristics of the input temperature sequence; Indicates the weight value; Indicates the bias value; Indicates the feature number.

[0121] S2.2, The Softmax weight allocation layer uses the Softmax function to transform the correlation coefficients output by the previous layer into weights. The formula is as follows:

[0122]

[0123] in, Indicate feature weights; This indicates the length of the input feature vector.

[0124] S2.3 The feature reconstruction layer obtains the output features of the attention mechanism by weighting and summing the input features using the obtained feature weights. The formula is as follows:

[0125]

[0126] in, This represents the output features of the convolutional layer.

[0127] Specifically, the structure of the convolutional neural network in step S3 is as follows: Figure 3 As shown, this is a type of feedforward neural network. Its essence is to extract features from the input data through multiple filters. These filters perform convolution and pooling operations on the input data layer by layer to extract topological features. The features weighted by the input attention mechanism are used as input to the CNN for temporal feature extraction, specifically including:

[0128] S3.1. Convolutional layers use convolution kernels to perform convolution operations on the input feature vectors, and simultaneously use non-linear activation functions to construct output features. The output of each convolutional layer is the result of convolving its input features, and its formula is:

[0129]

[0130] in, Represents the convolution kernel; Indicates the bias value of the convolutional layer; Receptive field representing temperature feature learning; Represents a non-linear activation function; Indicates the convolutional layer number of the model; Indicates the feature index of the current layer; This indicates the feature number of the previous layer.

[0131] S3.2. The ReLU function is usually chosen as the nonlinear activation function. Its advantage is that it makes some neurons output 0, which can reduce the dependence between parameters and thus alleviate the overfitting problem of the network model. Its formula is:

[0132]

[0133] in, This represents the input variables of the function, i.e., the formulas used in convolutional layer calculations.

[0134] S3.3 Pooling layers reduce the dimensionality of features by decreasing the size of the feature vectors, thus reducing computational complexity while preserving as much original information as possible. In practical applications, max pooling is commonly used, and its formula is:

[0135]

[0136] in, Indicates weight; This represents the pooling layer bias value.

[0137] S3.4. The fully connected layer unfolds a multi-dimensional feature map into a single-dimensional feature vector. Its formula is:

[0138]

[0139] in, This represents the output features of the fully connected layer, i.e., the temperature features after processing by the convolutional neural network; , These represent the weight and bias values ​​of the fully connected layer, respectively.

[0140] Specifically, the structure of the long short-term memory neural network in step S4 is as follows: Figure 4 As shown, this special type of RNN has the ability to learn long-term dependencies using feedback connections, giving it a significant advantage in time series prediction models and making it effective at predicting thermal errors of machine tool spindles. The feature vectors extracted by the CNN are used as input to the LSTM for spatial feature extraction, specifically including:

[0141] S4.1 The cell structure of the LSTM model includes a storage cell and three gates: a forget gate, an input gate, and an output gate. This structure is used to regulate which information in the information flow must be "forgotten" and which information must be "remembered," thereby learning long-term dependencies in the data. The central component in the cell is the cell state. Its function is similar to a conveyor belt, used to realize the transmission of information within the unit.

[0142] S4.2, Forget Gate Activation Vector Used to control The formula for determining which information from the cell state should be discarded is as follows:

[0143]

[0144] in, This indicates hidden information from the previous moment; , Represents the weight matrix; Represents the bias matrix; This represents the activation function.

[0145] S4.3, Input gate activation vector Used together with cell state for control Stored in cell state at all times New information is obtained from the forget gate and input gate temperature feature sequence information. The state unit of the current update state is calculated. Its formula is:

[0146]

[0147]

[0148]

[0149] in, , , , Indicates the weight value; , This represents the bias value.

[0150] S4.4, Output gate activation vector control The formula for determining how many unit state information outputs as hidden state information at any given time is:

[0151]

[0152]

[0153] in, This represents hidden information at the current moment. , Represents the weight matrix; This represents the bias matrix.

[0154] In step S5, the output attention mechanism generates an attention weight for each time point by calculating the contribution of thermal error data at different time points to the current prediction result. The greater the contribution, the higher the weight. The output attention mechanism has the same structure as the input attention mechanism, specifically including:

[0155] S5.1, Similarity Calculation Layer:

[0156]

[0157] in, This represents the weight value.

[0158] S5.2, Softmax weight allocation layer:

[0159]

[0160] in, Indicates in Weight of time.

[0161] S5.3 Feature Reconstruction Layer:

[0162]

[0163] in, express Output value of the time-mapping model; Indicates the feature number.

[0164] Specifically, in step S6, the overall framework structure of the network model established based on S2-S5 is as follows: Figure 5 As shown, the CNN-LSTM module includes a convolutional neural network and a long short-term memory neural network. The convolutional neural network is used to extract the spatial features of the temperature data, which are then connected to the LSTM network to obtain the temporal features of the temperature data. This invention designs a dual attention mechanism module, which divides different importance levels at both the feature level and the temporal level to improve the accuracy of model prediction.

[0165] The training and testing of the model also incorporates metrics such as mean absolute error and root mean square error to evaluate the model's predictive performance. Specifically, these include:

[0166] S6.1 During model training, the mean absolute error (MAE) is used as the loss function, and its formula is as follows:

[0167]

[0168] in, This represents the actual measured thermal error value; This indicates the predicted thermal error value output by the established model; Indicates the number of samples.

[0169] S6.2 During the testing process, the root mean square error (RMSE) is used to determine the difference between the predicted value and the true value. The smaller the RMSE, the closer the predicted value is to the true value, and the better the prediction effect. The formula is as follows:

[0170]

[0171] In this embodiment of the invention, model training and testing were conducted based on the Python platform, and the effectiveness and generalization ability of the proposed thermal error prediction method were verified. Figure 6 As shown, the experiment used data collected at a spindle speed of 2500 rpm as the training set and measured data at a speed of 3500 rpm as the test set to verify the predictive performance of the model under unknown working conditions. Figure 6 The solid line represents the thermal error measurement data, the dashed line represents the predicted value of the model established in this invention, and the dotted line represents the residual between the measured and predicted values. It can be seen that the model's predicted values ​​and measured values ​​basically coincide, and the residual values ​​are evenly distributed around 0, indicating that the model's prediction effect is quite ideal. The results show that the model trained on 2500 rpm data can not only accurately predict the thermal error at this speed, but also effectively predict the thermal error at 3500 rpm, demonstrating good robustness across operating conditions. The prediction accuracy of the finally established model on the entire test set is stable at 2. Within this range, both MAE and RMSE remain at low levels, while the predicted residuals are uniformly distributed around 0 with small fluctuations, which fully demonstrates that the thermal error prediction modeling method proposed in this invention has high accuracy and stability.

[0172] In this embodiment of the invention, to evaluate the robustness of the model under different temperature measurement point configurations, the prediction performance of the proposed DAT-CNN-LSTM model was compared with that of CNN-LSTM and CNN and LSTM models under different combinations of temperature measurement points. Figure 7 As shown, the predicted RMSE of each model fluctuates to some extent under different combinations of temperature measurement points (combinations 1 to 6). Experimental results show that, compared with the comparison models, the proposed DAT-CNN-LSTM model exhibits superior and more stable prediction performance in different combinations, with a significantly smaller RMSE fluctuation range. This indicates that after introducing the attention mechanism, the model can automatically identify and assign higher weights to temperature-sensitive points, effectively suppressing prediction uncertainty caused by changes in the selection of temperature measurement points, thereby significantly improving the robustness of thermal error prediction. This result further verifies the adaptability and superiority of the method of this invention in practical applications.

Claims

1. A machine tool thermal error prediction modeling method based on a double attention mechanism and a hybrid deep learning network, comprising the following steps: S1, acquiring temperature data of different temperature measuring points of a machine tool spindle under various working conditions and thermal error data of the spindle, including arranging Pt100 platinum resistance temperature sensors at the motor, front bearing, rear bearing of the machine tool spindle and the surrounding environment of the machine tool, and collecting spindle axial thermal elongation data in real time with an eddy current displacement sensor; S2, the collected data is sent to the input attention mechanism, and dynamic weights are given to the temperature data of the plurality of temperature measuring points to automatically identify temperature sensitive points; S3, the temperature data after weighting and the thermal error data are input into a convolutional neural network to extract spatial features and obtain a spatial feature vector; S4, the spatial feature vector is input into a long short-term memory neural network LSTM to extract time features and obtain a spatio-temporal feature vector; S5, the extracted spatio-temporal feature vector is sent to the output attention mechanism, dynamic weights are given to the thermal error data at different time points to strengthen the key temperature rise time features and suppress irrelevant time point interference; S6, based on the spatial features, time features, input attention weights and output attention weights, the model is trained for predicting the thermal error of the machine tool spindle; The double attention mechanism includes an output attention mechanism and an input attention mechanism module with the same structure, different importance levels are divided from the feature level and the time level respectively to improve the accuracy of model prediction; The output attention layer needs to combine the input value and the output value of the LSTM network, and the formulas of the similarity calculation layer, the weight distribution layer and the feature reconstruction layer are as follows: ; ; ; wherein, represents a weight value; represents a weight at a time point ; represents an output value of a model at a time point ; represents a feature number; In the S1, The Pt100 platinum resistance temperature sensor is arranged at positions including the circumference of the main shaft motor shell, the circumference of the front bearing outer ring, the circumference of the rear bearing outer ring and the environment temperature of the machine tool, the temperature resolution is 0.1 DEG C, the temperature precision is ±0.5 DEG C, and the temperature collection range is 20-40 DEG C. , the error resolution is 0.5%*measurement range; the temperature data and the thermal error data are synchronously sampled, the sampling frequency is not less than 10 Hz, the continuous collection is not less than the length of the thermal balance period of the machine tool, and the original data set is obtained; the original data set is subjected to linear interpolation of missing values, 3sigma criterion rejection of abnormal values and normalization pretreatment, and the standard data set is constructed.

2. The machine tool thermal error prediction modeling method based on dual attention mechanism and hybrid deep learning network according to claim 1, characterized in that, In step S2, the collected data is sent to the input attention mechanism, and dynamic weights are given to the temperature data of the plurality of temperature measuring points to automatically identify temperature sensitive points; Specifically, it includes: S2.1, the similarity calculation layer obtains the similarity between features by calculating the attention score of the input features, and the formula is: ; wherein, represents a feature similarity; represents an input temperature sequence feature; represents a weight value; represents a bias value; represents a feature number; S2.2, the Softmax weight distribution layer uses the Softmax function to convert the correlation coefficient output by the previous layer network, and the formula is: ; wherein, denotes a characteristic weight; denotes the length of the input feature vector; S2.3, the feature reconstruction layer weights the input features by the obtained feature weights to obtain the output features of the attention mechanism, and the formula is: ; wherein, denotes the output feature of the convolutional layer.

3. The machine tool thermal error prediction modeling method based on dual attention mechanism and hybrid deep learning network according to claim 1, characterized in that, In step S3, the temperature data after weighting and the thermal error data are input into a convolutional neural network to extract spatial features and obtain a spatial feature vector, including: S3.1, the convolution layer uses a convolution kernel to perform convolution operation on the input feature vector, and uses a nonlinear activation function to construct the output feature, and the output of each convolution layer is the convolution result of its input feature, and the formula is: ; wherein, denotes a convolution kernel; denotes a convolution layer bias value; denotes a receptive field of temperature feature learning; denotes an activation function; denotes a model convolution layer sequence number; denotes a current layer feature sequence number; denotes a previous layer feature sequence number; S3.2, the nonlinear activation function selects the ReLU function, and the formula is: ; wherein denotes the input variable of the function; S3.3, the pooling layer reduces the size of the feature vector while retaining as much original information as possible, and adopts the maximum pooling operator, and the formula is: ; wherein, denotes a weight; denotes a pooling layer bias value; S3.4, the fully connected layer expands the multi-dimensional feature map into a single-dimensional feature vector, and the formula is: ; wherein, represents the full connection layer output feature, i.e. the temperature feature processed by the convolutional neural network; , respectively represent the full connection layer weight value and the bias value.

4. The machine tool thermal error prediction modeling method based on dual attention mechanism and hybrid deep learning network according to claim 1, characterized in that, In step S4, the spatial feature vector is input into the long short-term memory neural network LSTM to extract time features, and a space-time feature vector is obtained. S4.1, The unit structure of the LSTM model includes a memory unit and three gates: a forget gate, an input gate, and an output gate, to regulate which information in the information flow must be "forgotten" and which information must be "remembered", so as to learn the long-term dependence of the data; the central component in the unit is the unit state , to realize the information transmission inside the unit; S4.2, forget gate activation vector to control which of the information from the cell state needs to be discarded at the moment, which is formulated as: ; wherein, represents hidden information at the previous time; , represents a weight matrix; represents a bias matrix; represents an activation function; S4.3, input gate activation vector and cell state are used to control the new information stored in cell state at the moment; after obtaining the temperature feature sequence information of the forget gate and the input gate, the state cell of the current update state is calculated , and the formula is: ; ; ; wherein, , , , denotes a weight value; , denotes a bias value; S4.4, output gate activation vector controlling At each time step, how much of the cell state information is output as hidden state information, which is given by the formula: ; ; wherein, represents a hidden information of a current time point; , represents a weight matrix; represents a bias matrix.

5. The machine tool thermal error prediction modeling method based on dual attention mechanism and hybrid deep learning network according to claim 1, characterized in that, In step S5, the output attention mechanism is used to calculate the contribution of the thermal error data at different time points to the current prediction result, and the attention weight of each time point is generated; the greater the contribution, the higher the weight; the output attention mechanism has the same structure as the input attention mechanism, including a similarity calculation layer, a Softmax weight distribution layer and a feature reconstruction layer, specifically: The similarity calculation layer: ; wherein denotes a weight value; S5.2, the Softmax weight distribution layer: ; wherein represents the weight at the time instant t. S5.3, the feature reconstruction layer: ; wherein, represents the output value of the time model; represents a feature number.

6. The machine tool thermal error prediction modeling method based on dual attention mechanism and hybrid deep learning network according to claim 1, characterized in that, In step S6, the CNN-LSTM module of the network model includes a convolutional neural network and a long short-term memory neural network; the convolutional neural network is used to extract the spatial features of the temperature data, and then connected with the LSTM network to obtain the time features of the temperature data; based on the spatial features, time features, input attention weights and output attention weights, the model is trained for predicting the thermal error of the machine tool spindle, wherein the mean absolute error and the root mean square error are introduced in the process of training and testing the model to evaluate the prediction performance of the model, specifically including: S6.1, in the model training process, the mean absolute error MAE is used as the loss function, and its formula is: ; wherein, represents a true value; represents a predicted value; represents a sample number; S6.2, in the testing process, the root mean square error is used to judge the difference between the predicted value and the true value, the smaller the RMSE, the closer the predicted value to the true value, and the better the prediction effect, and its formula is: 。 7. A machine tool thermal error prediction modeling device based on a dual attention mechanism and a hybrid deep learning network, characterized in that, including: The acquisition data module is used for arranging multiple point Pt100 platinum resistance temperature sensors on the motor, front bearing, rear bearing of the machine tool spindle and the environment of the machine tool, and collecting the spindle axial thermal elongation data in real time by an eddy current displacement sensor; wherein the Pt100 platinum resistance temperature sensor arrangement position comprises the circumference of the spindle motor shell, the circumference of the front bearing outer ring, the circumference of the rear bearing outer ring and the environment temperature of the machine tool, the temperature resolution is 0.1 DEG C, the temperature accuracy is ± 0.5 DEG C, and the temperature collection range is 20-40 DEG C; the eddy current displacement sensor is installed on the center of the front end surface of the spindle, and the measurement range is , the error resolution , the error accuracy is 0.5%*measurement range; the temperature data and the thermal error data are synchronously sampled, the sampling frequency is not less than 10Hz, the continuous collection time is not less than the thermal equilibrium period of the machine tool, and the original data set is obtained; the original data set is subjected to linear interpolation of missing values, 3sigma criterion rejection of abnormal values and normalization pretreatment, and the standard data set is constructed; The temperature recognition module is used to deliver the collected data to the input attention mechanism, and dynamically assigns weights to the temperature data of the plurality of temperature measuring points to automatically identify temperature sensitive points; The spatial feature module is used to input the weighted temperature data and thermal error data into the convolutional neural network to extract spatial features and obtain a spatial feature vector; The space-time feature module is used to input the spatial feature vector into the long short-term memory neural network to extract time features and obtain a space-time feature vector; The interference suppression module is used to deliver the extracted space-time feature vector to the output attention mechanism, dynamically assign weights to the thermal error data at different time points, strengthen the key temperature rise time features and suppress irrelevant time point interference; The model training module is used to train the model based on the spatial features, time features, input attention weights and output attention weights for predicting the thermal error of the machine tool spindle; The double attention mechanism includes the output attention mechanism and the input attention mechanism module with the same structure, which respectively divides different importance levels from the feature level and the time level to improve the accuracy of the model prediction; the input value and the output value of the LSTM network are combined in the similarity calculation layer, the weight distribution layer and the feature reconstruction layer of the output attention layer, and the formulas are as follows: ; ; ; wherein, represents a weight value; represents a weight at a time point; represents an output value of a model at a time point; represents a feature number.​​ 8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the computer program to implement the machine tool thermal error prediction modeling method based on the double attention mechanism and the hybrid deep learning network according to any one of claims 1-6. 9.A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by a processor to implement the machine tool thermal error prediction modeling method based on the dual attention mechanism and the hybrid deep learning network according to any one of claims 1 to 6.