## 3 Proposed Methods
### Taillight Pairing
#### 3.3.3 Pairing Classifier using Neural Network  
An artificial neural network is one of the most popular machine learning models in both scientific and industrial fields. The concept of a neural network was inspired by the way the human brain learns from information: it will identify the relation between the input and the corresponding output from the training dataset. As a result, the neural network can predict an output when receiving new input data. Therefore, the neural network is broadly used to solve problems that are too complicated for directly applying task-specific rules.  
In our study, we wanted to construct pairingClassifier so that when given the feature vector _pairVec_ of the two arbitrary taillights, it can determine whether these taillights belong to the same vehicle. Differently from previous works that compared the feature correlation between the two taillights with some experimental thresholds [12; 13; 14; 15; 16; 17; 18; 19; 26], we suggest applying an artificial neural network that will help to adaptively determine the sufficient threshold from the dataset. Specifically, a three-layer feed-forward neural network [34] was chosen as the architecture for pairingClassifier. The first layer, an input layer, composes of three nodes. Each node represents one feature, as mentioned earlier. The last layer, an output layer, only contains one node to yield a _status_: pair or not pair. These two layers are connected by a hidden layer placed in the middle. The hidden layer comprises six nodes. The visual representation of the neural network architecture for pairingClassifier is shown in Figure 23.  
Figure 23: Neural network architecture for pairing classifier.  
First, the input layer receives a feature vector \(pairVec\). The value \(Z\) in the hidden layer is calculated by the following equation, where \(W\) is a weight, \(b\) is a bias, and (.) denotes the dot product operator:  
\[Z=W.pairVec+b, \tag{32}\]  
As an output layer, given \(Z\) obtained from the first step, an activation function \(\sigma\) then returns a probability \(\widehat{p}\), which indicates whether the two taillights belong to the same vehicle. In this study, the sigmoid function was chosen as the activation function, and therefore, \(\widehat{p}\) was estimated by Equation (33).  
\[\widehat{p}=\sigma(Z)=\frac{1}{1+e^{-Z}}, \tag{33}\]  
Finally, \(\widehat{p}\) can be compared to a certain threshold _thres_ to decide the value of _status_.  
\[status=\begin{cases}\text{Pair}&\text{if }\ \widehat{p}\geq\text{{thres}}\\ \text{Not pair}&\text{otherwise}\end{cases}, \tag{34}\]  
PairingClassifier needs to be trained to determine suitable values for \(W\), \(b\), and _thres_. A training set includes the feature vector \(pairVec\) and the expected status \(status\) of multiple taillight pairs. During training, a backpropagation algorithm [35] is applied to adjust these three parameters until a certain minimal loss is reached. The loss represents the difference between the predicted status and the expected status. In this study, a binary cross-entropy loss function was chosen to calculate the loss value, whereas an Adam algorithm was used as the optimizer function. In conclusion, all relevant parameters for training pairingClassifier were set up as shown in Table 2.