{'fraction_non_alphanumeric': 0.02540920640548366, 'fraction_numerical': 0.010104591384506293, 'mean_word_length': 4.990796460176991, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Siamese Capsule Network for End-to-End Speaker Recognition In The Wild

We propose an end-to-end deep model for speaker verification in the wild. Our model uses thin-ResNet for extracting speaker embeddings from utterances and a Siamese capsule network and dynamic routing as the Back-end to calculate a similarity score between the embeddings. We conduct a series of experiments and comparisons on our model to state-of-the-art solutions, showing that our model outperforms all the other models using substantially less amount of training data. We also perform additional experiments to study the impact of different speaker embeddings on the Siamese capsule network. We show that the best performance is achieved by using embeddings obtained directly from the feature aggregation module of the Front-end and passing them to higher capsules using dynamic routing.


INTRODUCTION
Speaker verification models are comprised of two main parts. The Front-end component which encodes an utterance into fixed sized embedding vectors [1], and the Back-end component which measures the similarity of two given vectors in the form of a similarity score [2]. Most commonly in previous studies, the two components of the speaker verification system are two separate processes: the Front-end process of embedding extraction through a Deep Neural Network (DNN) pipeline, and the Back-end conducted via a non-trainable secondary module, typically cosine similarity.
Deep learning has emerged as a successful tool for speaker recognition in the past years. In this context, using DNN as a substitute for different components of conventional techniques such as i-Vector [1,2] has been subject to many studies [3,4,5,6,7]. Replacing the Front-end component of the i-Vector/PLDA with DNN models in order to extract speech representations from utterances is one of the common techniques used in recent literature for both speaker identification and verification [5,6,7]. Architectures such as Time-Delay Neural Networks (TDNN) [3], Recurrent Neural Networks (RNN) [4], and Convolutional Neural Networks (CNN) [5,6,7] are some examples of DNN models used in the recent studies.
The most common technique used for the Back-end component in DNN-based speaker recognition is the cosine distance. Despite the advancement of DNN models in extracting learnt speech representations, a very limited number of studies have used sophisticated DNN models to replace cosine distance in the Back-end component. The neural networks used as the Back-end component have typically consisted of simple Multi-Layer Perceptrons (MLP) [8,9,10], whereas more sophisticated methods, such as Siamese networks, have shown to be useful in other application areas [11]. Siamese networks have been utilized to measure the similarity level between two feature vectors [12]. The network takes the two vectors as inputs and produces an output score indicating the degree of similarity between the two vectors. Different forms of Siamese networks have proven to be successful in many speech-related tasks such as language detection [13], domain adaptation [14], and speech representation learning [15].
While Siamese networks that incorporate MLPs often successfully learn simple input-output transformations, they fail to consider the part-whole relations within the feature vectors. On the other hand, capsule networks along with routing mechanisms, have been designed to detect part-whole relations, and have recently emerged [16] as an upcoming approach in deep learning with impressive results obtained in image recognition [17], speech emotion recognition [18], keyword detection [19], and brain-computer interfaces [20]. The integration of pose matrices inside of capsules enables capsule networks to support different instantiating parameters such as deformation and orientation. Capsules also use different routing mechanisms such as dynamic routing [16] or EM routing [21] to capture the part-whole relationships or whole-part relationships [17] in the input features.
In this paper we propose a speaker recognition model with a Back-end Siamese capsule network for text-independent speaker verification. Our model can be integrated with any Front-end speaker representation learning model, resulting in a thoroughly end-to-end pipeline. Our contributions in this paper can be summarized as follows. (1) We propose a novel Siamese network using capsules for speaker recognition. We integrate our proposed model with a state-of-the-art Front-end DNN to perform speaker verification. (2) We train the end-to-end pipeline with Voxceleb1 to perform speaker recognition in the wild. Our results outperform that of other solutions and set a new state-of-the-art. (3) We show that despite the fact that the dataset used for training our model (Voxceleb1) is much smaller than Voxceleb2 which is used by some other studies, our model still achieves superior results.
The rest of the paper is as follows. In Section 2, some of the related works around Siamese networks, end-to-end speaker recognition, and capsules will be discussed. Section 3 will explain the architecture and the details of our proposed model. In section 4 the conducted experiments and results are presented. And finally Section 5 concludes the paper and presents suggestions for future work.

Siamese Networks for Speaker Recognition
Deep learning approaches for speaker recognition have gained a lot of attention given the advancements in computational capacity and availability of large in-the-wild datasets [22,23]. A large number of studies using DNN models for speaker embedding extraction have been performed in the past few years. Most prominent studies have used various CNN architectures such as ResNet [24,6,7] to achieve effective speaker embeddings from spectral representations of the utterances. Other successful models such as X-Vectors [3] have used TDNN to obtain reliable speaker embeddings using MFCC features.
The majority of DNN models used in speaker recognition take a single utterance as input and provide a fixed-size vector as the speaker embedding for the utterance. Another process is then used to calculate the similarity of the two embeddings obtained from an enrolment utterance and a test utterance for speaker verification. The most commonly used technique among the recent studies for calculating the similarity score is the cosine similarity (as shown in Equation 1). In the few cases where a similarity score is calculated using a DNN model [8,9,10,25], the performance has not been comparable to the state-of-the-art.

Capsule Networks
With the emergence of capsule networks [16], there has been considerable advancements in learning deep representations of data [17,18,19,20]. Taking advantage of routing mechanisms such as dynamic routing has enabled capsules to capture part-whole relations. However, to the best of our knowl-edge, capsule networks have not yet been explored for speaker recognition purposes. On the topic of using capsules within a Siamese network architecture, a number of papers have explored this strategy in areas outside of speaker recognition. For example, a Siamese capsule network was proposed in [11], which used primary capsules to capture the facial parts from CNN embeddings of the input pair of face images. A higher level capsule used routed information from the primary capsules via dynamic routing to construct part-whole relationships. The representations acquired from capsules were then transformed to a secondary latent space and the final similarity score was calculated using a non-linear combination of these representations.
The work done in [26] utilized Siamese capsule networks as a tool for calculating the similarity of two short sequences of text via embeddings obtained from Bidirectional Gated Recurrent Units (BGRU). Employing a similar approach as the Siamese capsule network proposed for face recognition, the embeddings were first passed through primary capsules to identify parts of the text (a representation of words and phrases). The higher capsules then used the information from the primary capsules via a routing mechanism to formulate a representation for the whole text.
As the mentioned studies suggest, the use of capsule networks (either as a stand-alone model or as part of a Siamese network) has shown promising results. However there has been no studies on the use of Siamese capsule networks for speaker recognition. In this work we aim to introduce a novel network based on this type of architecture to perform speaker verification using audio signals.

PROPOSED NETWORK
We propose an architecture based on a Siamese network with a Back-end that utilizes capsules for directly measuring a similarity score for speaker verification. Through the following sub-sections, we describe the different components of our model. An overview of the model is presented in Figure 1.

Front-end
We utilize a model with Resnet-based architecture as the Front-end component of our end-to-end DNN model. In order to better be able to show the impact of the Siamese capsule network, the front-end component as depicted in Figure 1, shares the majority of its architectural details with the model proposed in [24]. The model is a modified version of ResNet34, namely thin-ResNet34, which utilizes 34 convolution layers in the main body of the model. It also uses an effective feature aggregation method, namely GhostVlad [24]. The original model, uses a final fully connected (FC) layer to transform the features into a latent space and the final embedding is scaled down to 512 elemental vectors which are later used for verification via cosine distance. In our pa- per, we opt to remove the FC layer in order to preserve the maximum information possible from the embedding vectors provided by the GhostVlad pooling mechanism.
The thin-ResNet model operates on the enrollment utterance and the test utterance using a identical set of weights. This results in two vectors of size 4096 for each of the utterances. These vectors are then paired together in matrices with a dimension of (4096 × 2) in the way that each index of the embedding vector of enrollment utterance is paired with the same index in the embedding vector of the test utterance. This helps to better compare the embeddings later on in the Back-end component of our network.

Back-end
The Back-end component of the DNN model (see Figure 1) used in this paper consists of only higher capsules as we opt not to use the primary capsules. The operations inside primary capsule layers include a non-linear convolutions and the squashing operation. We aim to compare each index of the enrollment utterance embedding with the same index of the test utterance embedding and the non-linear effect of the convolution layer and the squashing operation inside the primary capsule prevents this correlation. Therefore by skipping the operations of the primary capsule, the embeddings are directly passed to the higher capsules. Each tuple (v 1i , v 2i ), where v 1i is the i th index in the enrollment embedding, and v 2i is the same index in the test embedding, is considered a single part while extracting the part-whole relations using dynamic routing.
We utilize 4 higher capsules in the Back-end model. The number of capsules is found empirically and may differ with respect to the diversity and complexity of the set of speakers. We also use dynamic routing [16] with 3 iterations as the routing mechanism between the embedding tuples and the capsules. In this mechanism, embedding tuples are first normalised using the L2 normalization (see Equation 2). The contribution of each tuple V i in the higher capsule C j is then determined by a secondary coefficient c ij through performing routing softmax (see Equation 3). The value p ij is calculated through multiple iterations using gradients obtained from the final loss function. Lastly, the representations from the higher capsules are then aggregated and passed to a Sigmoid function. The model is trained through binary classification and the final score calculated by the Sigmoid function is presented as the similarity score between the enrollment utterance and the test utterance.

Implementation
Our Siamese capsule network utilizes four higher capsules with a capsule dimension of 128. Each capsule receives information from 4096 tuples through dynamic routing. The number of trainable parameters are approximately 8.3M parameters. The high number of trainable parameters increases the probability of over-fitting. To address this issue, we opt to train the model using random selection of utterances from various speakers. Training of the model is done using a similar approach to that of the triplet loss. For each step of the training, three utterances are selected, two utterances form the same speaker and the other spoken by a different speaker. The same speaker utterances are selected form all the utterances of a speaker using a uniform random distribution without replacement. Then a third utterance is selected from the utterances of a random speaker, reducing the chance of the same triplets being selected again further in training.
We use Adam optimizer for training our Siamese capsule network. The Front-end model remains frozen during training in order to isolate the source of any changes in performance to the impact of the capsule network only. The learning rate is initially set to 0.01, but is changed with cyclical learning rate pattern [30] to ensure optimal convergence. For the hardware, we use a single Titan RTX GPU for training. For batch size, 64 utterance triplets are selected at each step of the training.

Ours
Thin-ResNet34 + Siamese Capsule Binary Cross-entropy VoxCeleb1 3.14 with less number of speakers and utterances compared to Vox-Celeb2, helps with managing the number of combination. Table 1 presents the results of our experiments. In this table the performance of the Siamese capsule network with respect to the benchmark models of thin-ResNet+GhostVlad, ResNet34+SAP, and ResNet34+LDE is presented. The comparison illustrates that our model achieves an EER of 3.14%, outperforming all the benchmark models. We also compare the performance of our model with respect to the amount of data needed for training. While some models [6,24,28] use the VoxCeleb2 dataset which contains more than 1M utterances for training, our model utilizes substantially less amount of data, and yet outperforms these models. This may be due to the random selection of utterance triplets which increases the number of training samples provided by the VoxCeleb1 dataset. We also evaluate the performance of our model using different number of capsules in the architecture. We also test the embeddings from two different layers of the Front-end model and the effect of using primary capsules immediately on the embeddings. Table 2 includes the results of our experiments. As shown in the results, the best performance is achieved using four capsules in the architecture. Also the embeddings obtained directly from the GhostVlad aggregation module lead to a considerably better performance compared to the bottleneck features collected from the fully connected layer. The effect of using primary capsules on the embeddings leads to a lower performance. This is in compliance with the argument made earlier (see Section 3.2) that the non-linear operations performed in primary capsules prevent the model from collecting more decisive information from embeddings.

Performance
In the end, we should point out that while a number of other works have attempted to use CNN-based Siamese architectures for speaker recognition in the past [9,25], they have generally achieved less competitive results compared to the approach of using cosine distance on the obtained embeddings. However, the use of a Siamese capsule network in our model shows improvement over the conventional approach, which can indicate the viability of such architectures for speaker verification in the wild.

CONCLUSION AND FUTURE WORK
In this paper a novel Siamese network using capsules and dynamic routing was proposed for speaker verification in the wild. Our end-to-end pipeline used thin-ResNet as its Frontend component for speech representation learning, while capsules were used in its Back-end to extract part-whole relations of the embeddings later used to calculate the similarity score between two representations. Experiments on the Voxceleb test set illustrated that our model outperforms the other benchmarks by obtaining an EER of 3.14% and sets a new state-of-the-art. Our model can be trained using substantially less amount of training data to reach the desired performance by random selection of utterance triplets. As a possible future route we intend to extend our experiments of the Siamese capsule network on utterances from various domains such as environments and noise levels.