# Main Factors on Effect of Precise Measurement and Precise Tamping Based on BP Neural Network
## 3 Model Building
### BPNN Training Model
#### 3.1.2 Selecting Model Parameters  
In the original data, the initial quality of the track (\(MTQI_{\textit{if}}\)), the measurement method before tamping, the model of the tamping machine, the tamping mode, whether it had a stabilizer, and the frequency of stabilizing operation were processed as the input layer. The number of nodes in the input layer of the network was six (\(n=6\)). The track quality after tamping (\(MTQI_{\textit{if}}\)) or the IR was used as the output layer. The number of nodes in the output layer of the network was one (\(m=1\)).  
A network, with bias and at least one sigmoid hidden layer plus a linear output layer, is capable of approximating any rational function. Increasing the number of layers can further reduce the error and improve the accuracy; however, it also complicates the network. The parameter configuration of the neural network requires multiple attempts to adjust different parameters to determine the activation function of the hidden layer and the number of neurons in the hidden layer. By evaluating the network indicators with the correlation coefficient \(R\), the fitting slope \(k\) and the value of MSE, a relatively good combination method can meet the principal factor analysis of the PMPT model was selected. The relatively optimal combination is shown as in Tables 1 and 2.  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Output Layer** & **Hidden Layer** & \multicolumn{2}{c}{**The Number of Neurons in**} & \multicolumn{1}{c}{**R**} & \multicolumn{1}{c}{**\(k\)**} & \multicolumn{1}{c}{**MSE**} \\  & & \multicolumn{2}{c}{**Hidden Layer**} & & & \\ \hline \multirow{6}{*}{purelin} & \multirow{3}{*}{sigmoid} & 10 & 0.80841 & 0.655 & 1.38917 \\  & & 20 & 0.81167 & 0.665 & 1.36820 \\  & & 30 & 0.81265 & 0.667 & 1.36610 \\  & & 50 & 0.81387 & 0.669 & 1.35414 \\ \cline{2-6}  & & 10 & 0.79767 & 0.636 & 1.45859 \\  & & 20 & 0.80408 & 0.646 & 1.41714 \\  & & 30 & 0.80706 & 0.649 & 1.40782 \\  & & 50 & 0.81117 & 0.662 & 1.37169 \\ \cline{2-6}  & & 10 & 0.74900 & 0.561 & 1.76048 \\  & & 20 & 0.74897 & 0.555 & 1.76073 \\  & & 30 & 0.74902 & 0.557 & 1.76050 \\  & & 50 & 0.74906 & 0.560 & 1.75990 \\ \hline \hline \end{tabular}
\end{table}
Table 1: Both input and output normalized fitting results.  
Step 1: Calculate the output value \(H\) of the hidden layer according to the influencing factors of the input layer \(X\), calculate the connection weight \(\omega_{\bar{y}}\) between the input layer and the hidden layer, and calculate the threshold \(\alpha\) of the hidden layer.  
\[H_{j}=f\left(\sum_{i=1}^{n}\omega_{ij}x_{i}-\alpha_{j}\right)\quad j=1,2,\cdots,l \tag{7}\]  
where \(l\) is the number of hidden layers at 30; and \(f\) is the activation function tansig of the hidden layer.  
Step 2: According to the output value \(H\) of the hidden layer, the connection weight \(\omega_{\bar{y}}\) and threshold \(b\) between the hidden layer and the output layer, calculate the \(O\) of the BPNN to predict the output of the \(MTQl_{\mathit{df}}\) or \(IR\).  
\[O_{k}=\sum_{j=1}^{l}H_{j}\omega_{jk}-b_{k}\quad k=1,2,\cdots,m \tag{8}\]  
Step 3: Calculate the network prediction error e according to the network prediction output \(O\) and the expected output value \(Y\).  
\[e_{k}=o_{k}-y_{k}\quad k=1,2,\cdots,m \tag{9}\]  
Step 4: According to the network prediction error \(e\), update the weights \(\omega_{\bar{y}}\) and \(\omega_{jk}\) between the layers of the network, as well as the new network node thresholds \(\alpha\) and \(b\).  
\[\omega_{ij}=\omega_{\bar{y}}+\eta H_{j}\big{(}1-H_{j}\big{)}x(i)\sum_{k=1}^{m }\omega_{jk}e_{k}\quad i=1,2,\cdots,n;j=1,2,\cdots,l \tag{10}\]  
\[\omega_{\bar{y}}=\omega_{\bar{y}k}+\eta H_{j}e_{k}\quad j=1,2,\cdots,l;k=1,2, \cdots,m \tag{11}\]  
Step 5: Determine whether the iteration of the model algorithm has reached its end; if not, go back to Step 1.