# Neural Network-Enhanced Fault Diagnosis of Robot Joints
## 2 Algorithm Analysis for BP Classification Neural Network  
A neural network, as one of the most popular artificial intelligence algorithms, can be divided into classification and regression neural network according to their function. The basic forward propagation algorithm of these two are the same, as shown in Figure 2.  
As shown in the figure, \(x\) represents the output of the input layer or the previous layer of neurons, and \(w\) represents the weights connecting the two neurons to each other, both of which, when subjected to linear regression as the independent variable of the activation function, are outputted to become the inputs or direct outputs of the next layer of neurons. Activation functions as nonlinear tools are directly responsible for neural networks to handle complex nonlinear model mapping. In the process of network construction, the activation function used in this research is sigmoid, which can map any real number to the interval (0,1), so its output can be interpreted as a probability, which is also the most commonly used activation function in classification problems in machine learning. The essence of neural network training is to find the lowest loss through the gradient descent and in the process of constantly updating the weights [14]. The biggest difference between classification neural networks and regression neural networks is the activation function of the neurons in the output layer, which is shown in Figure 3.  
The former is transformed nonlinearly by SoftMax as the activation function, which is commonly used in multiple classification problems in machine learning and deep learning,  
Figure 3: Structure and characteristics of classification neural networks. Figure 2: Forward propagation algorithm for single neuron. and it serves to transform a set of linear scores into a set of probability distributions. This process can be understood as a normalised exponential function. Specifically, let \(y\) be an \(n\)-dimensional real vector (in neural networks, this is usually the output of the last layer, also called logits or scores), and the SoftMax function is defined as:  
\[\text{softmax}(y)_{i}=\frac{e^{y_{i}}}{\sum_{j=1}^{n}e^{y_{j}}} \tag{1}\]  
Through this transformation, the SoftMax function transforms each output into a real number between 0 and 1, and the sum of all these transformed real numbers is 1, so they can be interpreted as a probability distribution. When performing a multiclassification problem, the SoftMax operation preserves the order between its parameters, so we do not need to compute SoftMax to determine which class has been assigned the highest probability; the class with the highest SoftMax value is usually used as the prediction, and that value is interpreted as the output of the model as a specific class by the Onehot encoding, which is used to represent the class labels. The encoding form is an \(q\)-order unitary matrix, with \(q\) denoting the number of labels (categories) to be classified [15]. In addition to the difference in the output layer activation function, another difference in classification neural networks lies in the loss function. As we mentioned earlier, the SoftMax function is used to convert the output of the neural network into a probability distribution, which can be viewed as the predicted probability of our model for each category. In this case, our goal is to make the model's predicted probability distribution as close as possible to the true label distribution by tuning the model parameters. For a given data point, its true label distribution can be represented by one-hot coding. Thus, our task becomes maximising the model's predictive probability for the true labels, i.e., maximising the likelihood function [16]. \[P(\mathbf{Y}\mid\mathbf{X})=\prod_{i=1}^{n}P\Big{(}\mathbf{y}^{(i)}\mid \mathbf{x}^{(i)}\Big{)} \tag{2}\]  
However,directly maximising the likelihood function can be numerically computationally problematic, e.g., overflow or underflow may be encountered.