# A Method for Singular Points Detection Based on Faster-RCNN
## 2 Proposed Method
### Loss Definition and Training  
To train the network, we assign a positive label to a grid cell with a singular point, while these grid cells will be labeled by a negative label if its \(3\times 3\) neighborhood does not contain a singular point. Thus, this can ensure that the grid cells without singular points but close to any singular point are not used to train the network. Moreover, we use all positive grid cells and the same number of negative grid cells in the training to keep the sampled positive and negative cells balanced. As described in Sections 2.1 and 2.2, a two-step strategy is chosen to achieve this detection task. In the first step, the network generates a large number of proposals without orientation information. Specifically, a raw fingerprint image is input into the networks and divided into a grid. These labeled grid cells are used for classification and regression tasks to train the network. Then, the network predicts the probability that there is a singular point and calculate coarse location of the singular point so that proposals will be generated according to the probability and the coarse location information. In order to get more accurate locations, the network is trained under a multi-task loss (location classification \(\mathcal{L}_{class}\) and regression \(\mathcal{L}_{loc}\)) to refine the locations of singular points. For the location classification, we chose the categorical cross-entropy loss. It takes the formulation  
\[\mathcal{L}_{class}(y_{i},p_{i})=-\sum_{i=1}^{n}y_{i}\log(p_{i}), \tag{1}\]  
where \(y_{i}\) is the truth label of class \(i\), \(p_{i}\) is the predicted probability that there exists a singular point. \(n\) is the number of subject classes. Because a raw fingerprint image consists of at most four kinds of singular points, Then, the number of classes \(n\) is 5 (the background is regarded as a subject class) in our works. For the location regression \(\mathcal{L}_{loc}\), we used the smooth \(L_{1}\) loss with the Euclidean distance between the ground truth location and the predicted location. The location regression \(\mathcal{L}_{loc}\) is formulated as  
\[\mathcal{L}_{loc}(g_{i},t_{i})=F_{smooth-L_{1}}(||g_{i}+c_{i}-t_{i}||_{2}), \tag{2}\]  
where \(c_{i}\), \(t_{i}\) are the location coordinates of the center of the regions where there might exist singular points and ground-truth singular points, \(g_{i}\) is the output of the network. We regress to the difference between the center coordinates and the singular points coordinates instead of the location of the singular points. \(F_{smooth-L_{1}}\) is the function of the smooth \(L_{1}\) loss and expressed as  
\[F_{smooth-L_{1}}(x)= \begin{cases}\dfrac{1}{2}x^{2}&x\in[-1,1]\\ |x|-0.5&\quad\text{otherwise}\end{cases} , \tag{3}\]  
Then, the loss function \(\mathcal{L}_{1}\) for the first step is a joint loss function combined with the categorical cross-entropy loss (Equation (1)) and the regression loss (Equation (2)) and takes the formulation  
\[\mathcal{L}_{1}=\dfrac{1}{N_{1}}\sum_{i=1}^{N_{1}}\mathcal{L}_{class}(y_{i},p_{ i})+\lambda\dfrac{\sum_{g_{i}\
eq 0}\mathcal{L}_{loc}(g_{i},t_{i})}{\sum_{i=1}^{N_{1}}y_{ i}}, \tag{4}\]  
where \(N_{1}\) is the number of all samples and scalar \(\lambda\) is used as a weight for balancing the two loss functions. Since only regions in which there might exist singular points are used for location regression,Then, mean of \(\sum_{y_{i}\
eq 0}\mathcal{L}_{loc}(g_{i},t_{i})\) is used in \(\mathcal{L}_{1}\), here label \(y_{i}\) is ranged from 0 to 4 and \(y_{i}=0\) means that object belongs to background. In the second step, candidate patches generated by the proposals are chosen to train the network to calculate orientation information of singular points and refine the location. As candidate patches expanded by proposals are different from these proposals, the patches will be reclassified and regressed to refine the location and orientation information. All patch samples that are generated from a candidate proposal have the same label.