# Generalized Spoof Detection and Incremental Algorithm Recognition for Voice Spoofing
## 3 Voice Spoof Detection and Algorithm Recognition System
### Incremental Spoof Algorithms Recognition
#### 3.2.1 Prototype Learning  
The purpose of voice spoof algorithm recognition is to extract the feature representation of the voice. In turn, the spoof algorithm used for the voice is determined. The objective of this task is expressed as follows:  
\[\text{y}=\text{f}(\text{x},\theta) \tag{5}\]  
where \(\theta\) is the model parameter, and \(\text{y}\ \in\ \{1,2,\ \dots,\) C} denotes the spoof algorithm class label. Unlike the traditional ResNet, which uses softmax layers to perform linear classification on the learned features, we learn multiple prototypes of the features of each class by maintaining them. The classification was performed using prototype matching, as shown in Figure 4. The prototypes are represented as \(m_{i,j}\), where \(i\ \in\ \{1,2,\dots,C\}\) denotes the index of the class, and \(j\ \in\ \{1,2,\dots,K\}\) denotes the index of the prototype in each class. Here, we assume that each class contains the same number of \(K\) prototypes. The ResNet feature extractor \(f(x,\theta)\) and prototypes \(\{m_{i,j}\}\) are jointly trained from the data. In the classification phase, we classify the objects by prototype matching, i.e., we find the nearest prototype based on Euclidean distance. The prototype class is assigned to a specific object. It is expressed as  
\[\begin{array}{c}C\\ x\in y\arg max\ g_{i}(x)\\ i=1\end{array} \tag{6}\]  
where \(g_{i}(x)\) is the discriminant function for class \(i\):  
\[\begin{array}{c}K\\ g_{i}(x)=-\ min\ \ \|\ f(x;\theta)-m_{i,j}\|_{2}^{2}\\ j=1\end{array} \tag{7}\]  
Figure 3: Schematic of OC-Softmax embedding vector distribution. The red and blue dots indicate the two classes of sample features. The dashed line indicates the classification decision boundary. The arrow indicates the optimization direction of the target class embedding vector.  
For this purpose, the probability of a sample assigned to each category by using the distance of the sample from the prototype is expressed as  
\[p\big{(}x\in m_{i,j}\big{|}x\big{)}=\frac{e^{-d(f(x),m_{i,j})}}{\sum_{k=1}^{C} \sum_{i=1}^{K}e^{-d(f(x),m_{k,j})}} \tag{8}\]  
where \(d\big{(}f(x),m_{i,j}\big{)}=\parallel f(x;\theta)-m_{i,j}\parallel_{2}^{2}\). Then, the objective function can be expressed as  
\[loss_{1}=-\log(\sum_{j=1}^{K}p\big{(}x\in m_{i,j}\big{|}x\big{)}) \tag{9}\]  
Direct minimization of the classification loss may lead to overfitting. To avoid this, prototype loss is added as a regularization to improve the model's generalization ability. The so-called prototype loss--that is, the loss centered on the centroid of the subclasses--is used to determine the class to which the input \(x\) belongs to. Then, its decision boundary is the location where the distances to the centers of the subclasses of two adjacent classes are equal. It can be expressed as  
\[loss_{2}((x,y);\theta,M)=\parallel f(x)-m_{y,j}\parallel_{2}^{2} \tag{10}\]  
where \(m_{y,j}\) is the prototype closest to \(f(x)\) in the corresponding class \(y\). A relatively sparse feature space was obtained, which later facilitated incremental learning.