# Advancing Taxonomy with Machine Learning: A Hybrid Ensemble for Species and Genus Classification
## 3 Materials and Methods
### Dataset with Simulated Undescribed Species
This is equivalent to dividing the matrix by its maximum singular value. \[\max_{\mathbf{h}:\mathbf{h}\
eq\emptyset}\frac{\|Wh\|_{2}}{\|h\|_{2}} \tag{1}\]

Conditional batch normalization (Equation (3)) differs from regular batch normalization (Equation (2)) by determining the values of the parameters \(\beta\) and \(\gamma\) using a linear layer from the input features instead of learning one value for them. In conditional GANs it allows the model to learn different scaling factors for different classes of samples (e.g., different species or genera). \[\gamma(\frac{x-\mu}{\sigma})+\beta \tag{2}\]

\[\mathrm{MLP}_{\gamma}(x)(\frac{x-\mu}{\sigma})+\mathrm{MLP}_{\beta}(x) \tag{3}\]

where \(\mu\) and \(\sigma\) are the mean and the standard deviation of the values of elements of the batch. It has been proved, by [35], that in ACGAN discriminators the gradients scale with the norm of the sample embedding (the feature extracted by the discriminator). Figure 3: Comparison of \(3\times 3\) convolution with \(5\times 1\) convolution. I represents the input of the convolution, while K is the filter. The symbol \({}^{\star}\) denotes the convolution operator. In each I matrix, the red region highlights the current area where the filter K (shown in blue or green) is applied. Finally, the D2D-CE (data-to-data cross-entropy) loss is used. Normally, ACGANs compute the cross-entropy between the feature extracted by the discriminator (called sample embedding) and the embedding of the class label which is called proxy (in ACGANs, a one-hot encoding of the label can be used instead of an embedding of the class label). In [35] it is showed how normalizing the sample embedding and the label proxy avoids the exploding gradient problem that appears at early training and is one of the causes of early mode collapse. Equations (4) and (5) describe the common cross-entropy and the D2D-CE loss functions, respectively. Both are expressed by considering \(F(\mathbf{x})\), the feature embedding vector extracted from image \(x\) by the penultimate layer of the discriminator, and \(W=[\mathbf{w}_{1},\dots,\mathbf{w}_{c}]\), which is the weight matrix of the last layer of the discriminator. \[\mathcal{L}_{\text{CE}}=-\frac{1}{N}\sum_{i=1}^{N}\log\Big{(}\frac{\exp\left(F (\mathbf{x}_{i})^{\top}\mathbf{w}_{y_{i}}\right)}{\sum_{j=1}^{c}\exp\left(F( \mathbf{x}_{i})^{\top}\mathbf{w}_{y_{j}}\right)}\Big{)}. \tag{4}\]

\[\mathcal{L}_{\text{D2D-CE}}=-\frac{1}{N}\sum_{i=1}^{N}\log\bigg{(}\frac{\exp \left([\mathbf{f}_{i}^{\top}\mathbf{v}_{y_{i}}-m_{p}]_{-}/\tau\right)}{\exp \left([\mathbf{f}_{i}^{\top}\mathbf{v}_{y_{i}}-m_{p}]_{-}/\tau\right)+\sum_{j \in\mathcal{N}(i)}\exp\left([\mathbf{f}_{i}^{\top}\mathbf{f}_{j}-m_{n}]_{+}/ \tau\right)}\bigg{)}, \tag{5}\]

The D2D-CE (Equation (5)) is a modified version of CE (Equation (4)), where \(\mathbf{v}_{y_{i}}=\frac{\mathbf{w}_{y_{i}}}{||\mathbf{w}_{y_{i}}||}\) and \(\mathbf{f}_{i}=\frac{P(F(\mathbf{x}_{i}))}{||P(F(\mathbf{x}_{i}))||}\), \(P\) is a projection carried out by a linear layer, \([\cdot]_{-}=\text{min}(\cdot)0\)\([\cdot]_{+}=\text{max}(\cdot,0)\), \(\mathcal{N}(i)\) is the set of indices of the samples in the minibatch for which the label is different from \(y_{i}\) (it is the real label); the margins \(m_{p}\) and \(m_{n}\) and the temperature \(\tau\) are hyperparameters, and we use the implementation and the values of the hyperparameters suggested in [37]. Also in D2D-CE, the denominator (Equation (5)) of the softmax still computes the similarity between the sample embedding and the proxy (either one-hot or embedding) in order to consider data-to-class similarities, but in the denominator, we split the summation in two: a term equal to the numerator plus a term that computes the similarities between the sample embeddings for images of the batch belonging to different classes (\(j\in\mathcal{N}(i)\)). This second term does not consider data-to-class relationships because it does not involve the weights of the last layer \(\mathbf{v}_{y_{i}}\).