Abstract:To address the problems of insufficient modeling accuracy, weak generalization under multiple operating conditions, and the heavy reliance of traditional deep learning models on empirical parameter tuning in spindle thermal error prediction for computer namerical control (CNC) spiral bevel gear grinding machines, a spindle thermal error modeling method based on whale optimization algorithm (WOA), transfer learning, and a long short-term memory network (LSTM) network is proposed. First, a spindle thermal error experimental platform is established, and temperature data from 10 measuring points together with the axial thermal error of the spindle are synchronously collected under three rotational speeds of 1 000, 1 500, and 2 000 r/min, thereby obtaining complete thermal behavior samples from cold start to thermal equilibrium. Second, K-means clustering combined with grey relational analysis is employed to screen the temperature variables, and T1, T5, and T8 are identified as thermal error-sensitive measuring points, which preserves the main thermal feature information while reducing input redundancy and multicollinearity. Furthermore, WOA is introduced to globally optimize hyperparameters of the LSTM model, including the time step, learning rate, and batch size, and a WOA-LSTM thermal error prediction model is established to improve convergence speed, training stability, and prediction accuracy. On this basis, a model fine-tuning-based transfer learning strategy is constructed. The source-domain pre-training is completed using data under 1 000 and 1 500 r/min conditions, and the model is then transferred to the 2 000 r/min target condition for small-sample fine-tuning, thus enabling cross-condition knowledge reuse and rapid adaptation. Experimental results show that the proposed WOA-LSTM transfer learning model achieves an root mean square error (RMSE) of 1.364×10-3 mm, an mean absolute error (MAE) of 1.361×10-3 mm, and an R-square (R2) of 0.983 9 in spindle thermal error prediction, outperforming the back propagation network (BP), WOA-BP, and conventional LSTM models. The proposed method exhibits good adaptability and cross-condition generalization ability under complex thermal environments, and provides a new and practical approach for thermal error modeling and compensation of machine tools.