# Intelligent System for Railway Wheelset Press-Fit Inspection Using Deep Learning
## 2 Deep Siamese Neural Networks  
Deep learning has recently become a trendy research topic in the AI field; it solves the core problems in representation learning by expressing simpler representations [19]. However, when there are almost no available data or a relatively small amount of data, these algorithms often fail to predict accurate results. Under this restriction, many researchers proposed various one-shot learning algorithms, which enable us to make the correct  
Figure 1: Some examples of force-displacement (press-fit) curves. Figures (**a**–**c**) are the qualified images of press-fit curves, and Figures (**d**–**f**) are the unqualified examples. In the figures, the \(y\)-axis is the press-mounting force, and the \(x\)-axis is its corresponding displacement. prediction using only one or a few training examples in each class [23; 24; 25]. At present, theoretical studies and technologies based on the Siamese neural networks (SNN) have been mature and were successfully applied in various fields [26], such as audio and speech signal processing [27; 28], remote-sensing scenes [29], biology [30], medicine and health [31; 32; 33], robotics [34], smart surveillance [35], and text mining [36]. In the manufacturing industry fields, [PERSON] et al. developed a visual product tracking system by using the Siamese network method to match the product images at both ends of the tracked process [37]. For tool wear recognition, [PERSON] et al. applied the Siamese network technique to classify the drill wear states based on images of drilled holes. The proposed automated solution can reduce the time required to manually evaluate the drill state [38]. It is necessary to check whether printed outputs or carved wares are missing or etched by comparing the drawings in the printing and carving industries. To reduce the workforce cost and working hours, [PERSON] et al. presented an effective method of character verification to automatically compare the similarities between the drawing characters and scanned physical characters based on the Siamese network [39]. [PERSON] et al. first applied deep learning based on a convolutional neural network to develop SNN for one-shot classification [24]. The general SNN architecture is shown in Figure 2. An SNN consists of twin networks that accept a pair of images as input and share the same weights. The weights guarantee that their respective networks could not map two extremely similar images to very different locations in feature space, because each network computes under the same function [24]. In this deep SNN architecture with \(L\) hidden layers and \(N_{l}\) units, \(\mathbf{h}_{1}^{l}\) represents the hidden vector in layer \(l\) for the first twin, and \(\mathbf{h}_{2}^{l}\) denotes the same for the second twin. The notations \(x_{1,i}\) and \(x_{2,i}\) represent specific vector elements in two input images. In the distance layer, the difference is calculated between the twin feature vectors \(\mathbf{h}_{1}^{l}\) and \(\mathbf{h}_{2}^{L}\) in the last layer of hidden layers by distance formulas, such as Euclidean distance (\(d_{1}=||h_{1,1}^{L}-h_{2,1}^{L}||_{2}\)). After the distance layer, we adopt a fully connected method with a sigmoid activation function to predict the similarity of two input images. Regarding the choice of hidden layer network architecture, this study adopts deep residual networks (ResNets) because they have the advantage of efficiently and easily training substantially deeper networks [40]. Figure 2: An architecture of simple \(L\) hidden layers of Siamese network for binary classification. In the twin networks, the weight matrices are shared at each layer [24]. To evaluate loss function, let \(S\) represent the training set size. Let \(\mathbf{y}\left(x_{i},x_{j}\right)\) be a length-\(S\) vector, which contains the binary labels for the training set, where \(y\left(x_{i},x_{j}\right)=1\) if the samples \(x_{i}\) and \(x_{j}\) are from the same class, and zero otherwise.