# Animal Sound Classification Using Dissimilarity Spaces
## 3 Siamese Neural Network (SNN)
### The Two Identical Twin Subnetworks  
In this study, four twin CNN subnetworks are utilized. CNNs are constructed by assembling specialized layers composed of neurons. Some of the more common layers found in CNN architectures include convolutional, activation (ReLU), pooling, and fully connected (FC) layers. The specific CNN architecture for the four twin subnetworks are outlined in Table 1.  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline \multicolumn{5}{c}{**Siamese Network 1**} \\ \hline
**Layers** & **Activations** & **Learnable** & **Filter Size** & **Num. of Filters** \\ \hline Input Layer & \(224\times 224\) & & & \\
2D Convolution & \(215\times 215\times 64\) & \(6464\) & \(10\times 10\) & \(64\) \\ ReLU & \(215\times 215\times 64\) & \(0\) & & \\ Max Pooling & \(107\times 107\times 64\) & \(0\) & \(2\times 2\) & \\
2D Convolution & \(101\times 101\times 128\) & \(401,536\) & \(7\times 7\) & \(128\) \\ ReLU & \(101\times 101\times 128\) & \(0\) & \(2\times 2\) & \\ Max Pooling & \(50\times 50\times 128\) & \(0\) & \(2\times 2\) & \\
2D Convolution & \(47\times 47\times 128\) & \(262,272\) & \(4\times 4\) & \(128\) \\ ReLU & \(47\times 47\times 128\) & \(0\) & & \\ Max Pooling & \(23\times 23\times 128\) & \(0\) & \(2\times 2\) & \\
2D Convolution & \(19\times 19\times 64\) & \(204,864\) & \(5\times 5\) & \(64\) \\ ReLU & \(19\times 19\times 64\) & \(0\) & & \\ Fully Connected & \(4096\) & \(94,638,080\) & & \\ \hline \hline \multicolumn{5}{c}{**Siamese Network 2**} \\ \hline
**Layers** & **Activations** & **Learnable** & **Filter Size** & **Num. of Filters** \\ \hline Input Layer & \(224\times 224\) & \(0\) & & \\
2D Convolution & \(220\times 220\times 64\) & \(1664\) & \(5\times 5\) & \(64\) \\ LeakyReLU & \(220\times 220\times 64\) & \(0\) & & \\
2D Convolution & \(216\times 216\times 64\) & \(102,464\) & \(5\times 5\) & \(64\) \\ LeakyReLU & \(216\times 216\times 64\) & \(0\) & & \\ Max Pooling & \(108\times 108\times 64\) & \(0\) & \(2\times 2\) & \\
2D Convolution & \(106\times 106\times 128\) & \(73,856\) & \(3\times 3\) & \(128\) \\ LeakyReLU & \(106\times 106\times 128\) & \(0\) & & \\
2D Convolution & \(104\times 104\times 128\) & \(147,584\) & \(3\times 3\) & \(128\) \\ LeakyReLU & \(104\times 104\times 128\) & \(0\) & & \\ Max Pooling & \(52\times 52\times 128\) & \(0\) & \(2\times 2\) & \\
2D Convolution & \(49\times 49\times 128\) & \(262,272\) & \(4\times 4\) & \(128\) \\ LeakyReLU & \(49\times 49\times 128\) & \(0\) & \(2\times 2\) & \\ Max Pooling & \(24\times 24\times 128\) & \(0\) & \(2\times 2\) & \\
2D Convolution & \(20\times 20\times 64\) & \(204,864\) & \(5\times 5\) & \(64\) \\ LeakyReLU & \(20\times 20\times 64\) & \(0\) & \(5\times 5\) & \\ Fully Connected & \(2048\) & \(52,430,848\) & & \\ \hline \hline \end{tabular}
\end{table}
Table 1: Convolutional neural network (CNN) Siamese networks (1–4) layers.  
Figure 2: Siamese neural network architecture.  
Two activation functions are explored here: the ReLU activation function [52] and the Leaky ReLU [53]. The well-known ReLU activation function for the points \((x_{i},~{}y_{i})\) is defined as:  
\[y_{i}=~{}f(x_{i})=\left\{\begin{array}{ll}0,&x_{i}<0\\ x_{i},&x_{i}\geq 0\end{array}\right.. \tag{6}\]  
The Leaky ReLU variation of ReLU is defined as  
\[y_{i}=~{}f(x_{i})=\left\{\begin{array}{ll}ax_{i},&x_{i}<0\\ x_{i},&x_{i}\geq 0\end{array}\right.. \tag{7}\]  
The subnetworks of the Siamese CNNs 1-4 each learn the features that best represent the information in the spectrograms that are the input patterns to the two input nodes (\(X1\) and \(X2\)) and return either a 2048 or a 4096-dimensional feature vector (\(F1\) and \(F2\)). The subnetworks share the same parameters and training weights.