# Research on Process Quality Prediction and Control of Spindle Housings in Flexible Production Lines
## 4 Optimization of Critical Process Quality Prediction Control Based on GM(1,1)-BP
### GM(1,1)-BP Combined Prediction Optimization
#### 4.3.2 Selection of Residual Values to Predict Model Parameters  
(1) Network initial parameters and the expected error value  
The BP neural network adjusts the initial parameters by way of feedback iteration. Before the neural network makes a prediction, it needs to initialize the weights between each layer and the threshold value of each layer, whose practical value range is (\(-2.4\)/F, \(2.4\)/F), and F is the number of neurons at the input of the weights. The expected error and the number of nodes in the hidden layer determine the prediction accuracy of the network model. Choosing a reasonable value of the expected error can change the network's convergence, shorten the network's training time, and improve the accuracy of the model prediction. (2) Transfer function and training algorithm  
The BP neural network's input-implicit layer of the nonlinear relationship is generally a selected S-type transfer function, and the implicit-output layer of the linear relationship is generally a selected Purelin linear transfer function. As shown in Figure 8, the S-type transfer function is selected as the transfer function of the input-implicit layer because the input sample data of this paper needs to be mapped in the interval [\(-\)1, 1]. The network model determines the network learning algorithm between layers according to the training object and requirements. Backpropagation training algorithms commonly used for BP neural network models mainly include gradient descent (TRAINED), Newton's (TRAINBPG), the conjugate gradient method, and the Levenberg-Marquardt algorithm. The experimental comparison by MATLAB in illustrates that without considering memory, the LM algorithm can be used as the model training learning algorithm in this paper due to its fast convergence and high prediction accuracy, as it avoids the direct calculation of the Hessian matrix. (3) Learning rate and determination of hidden layer nodes  
The role of the network model learning rate lr is to constantly adjust the weights and thresholds between the layers. If the learning rate is too low to update the weights in the network at a microscopic level, the training rate will become slow; conversely, it may lead to undesirable divergence behavior in the loss function, failing convergence of the data. In the BP network established by the TrainLm function, the learning efficiency is generally taken as 0.001-0.1. According to the number of nodes in the hidden layer there is a relationship with the number of input and output nodes and the number of nodes is selected as small as possible within a certain range. A smaller number of nodes is chosen as far as possible within a specific range. To ensure that the values obtained are suitable for the learning rate and the number of nodes in the hidden layer in this paper, a combination of simulated training with a learning efficiency interval [0.001, 0.5] and several nodes in the hidden layer interval [3,12] was performed with a fixed constraint of 1000 iterations, a root mean square error of 0.000001, and a training function for the LM learning algorithm, using the average error of the output values from the six test sets as the comparison ratio. The presented calculations are shown in Table 12 \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline \multirow{2}{*}{**Learning Rate**} & \multicolumn{8}{c}{**Number of Implicit Layer Nodes**} \\ \cline{2-9}  & **5** & **6** & **7** & **8** & **9** & **10** & **11** & **12** \\ \hline
0.001 & 3.609 & 2.686 & 2.689 & 4.391 & 1.872 & 3.390 & **1.020** & 1.970 \\
0.01 & 5.599 & 1.770 & 6.091 & 3.886 & 2.993 & 3.714 & 2.433 & 3.274 \\
0.1 & 6.183 & 1.585 & 2.846 & 3.430 & 2.339 & 3.189 & 5.540 & 3.626 \\
0.2 & 3.563 & 2.079 & 2.551 & 2.381 & 2.459 & 9.471 & 3.7587 & 3.139 \\
0.5 & 5.054 & 6.004 & 3.377 & 3.120 & 1.477 & 5.903 & 1.714 & 4.540 \\ \hline \hline \end{tabular}
\end{table} 
Table 12: Average error values of the network training output.