# Polyp Generalization via Diversifying Style at Feature-Level Space
## 3 Methodology
### Style Conversion and Generation Module (SCGM)
#### 3.2.3 Novel Style Synthesis Module (NSSM)  
An overview of the NSSM is shown in Figure 3d. The problem with the SCM and SGM is that they cannot produce diverse yet plausible style features in the iterations during the training, as they only utilize a single statistic or a mere combination of two style feature statistics from the batch. Therefore, we propose seeking a novel style that should not deviate too much from the source styles and looks realistic. To achieve this, we first make a queue of style features, which is generated by combining the style statistics of two images within the batch size applying the best possible combinations (see Figure 4). We employ a technique similar to the SGM but within each pair of batches. We compute the mean and the standard deviations and mix the feature statistics following Equations (6) and (7). Then, a subset of the images that are distinct in the queue are chosen, and the maximum mean discrepancy (MMD) between the chosen styles and the other remaining target style features is computed. Given a batch of images \(\{x_{1},x_{2},x_{3},x_{4}....x_{s1},x_{s2}...x_{sn}\}\) from both the training and target style images, we randomly select one image as a base image and perform style mixing individually with each target style image by applying Equations (6) and (7). Next, we concatenate the mean and the standard deviation values of each by mixing statistics and store them in queue S. We then compare the discrepancy of each computed distribution with the base \(x_{1}\) feature statistics. Let us assume S1 represents the style feature distribution of \(x_{1}\) and S2 represents the style queue. We adopt the square maximum mean discrepancy (MMD) between the two distributions (S1 and S2) using a radial basis function (RBF) kernel \(k\) as follows:\[MMD_{k}^{2}(S1,S2)=\frac{1}{|S|^{2}}\sum_{s_{i}\
eq j\in S1}k(s_{i},s_{j}) \tag{9}\] \[-\frac{2}{|S1||S2|}\sum_{s_{i}\in S1,S2_{i}\in S1}k(S1_{i},S2_{j})+ \frac{1}{|S2|^{2}}\sum_{P_{i},P_{j}\in S1}k(S2_{i},S2_{j})\]  
Note that we apply Equation (9) for all of the combinations and compare each original style feature with the mixed one, taking those that have the minimum discrepancy. We then normalize the feature maps following Equation (1) and inject the novel dynamic styles, which were chosen by applying the MMD for the mixed features. The plausible style injection can be formulated by:  
\[NSSM(x)=\gamma(Ns)\frac{x-\mu(x)}{\sigma(x)}+\beta(Ns) \tag{10}\]  
We adopted a combination of the Dice loss \(L_{dice}\) and the cross-entropy loss function to train the network parameters. The Dice loss was proposed by [36] and defined as follows:  
\[L_{dice}=1-Dice(Y,Y^{\prime}) \tag{11}\]  
where Dice is indicated by Dice coefficient score, which represents the spatial overlap regions between the ground truth (\(\gamma\)) and the predicted mask (\(Y^{\prime}\)). It can be calculated as follows:  
\[Dice=Mean(\frac{\sum Y^{\prime}*Y+e}{\sum Y^{\prime}+\sum Y+e}) \tag{12}\]  
In the above Equation (12), \(*\) indicates element-wise multiplication and e is a very small parameter in case of unfavorable conditions. The combination of the binary cross-entropy loss and Dice loss have been proven efficient in handling the gradient problem [37]. We can formulate the binary cross-entropy loss as follows:  
\[L_{ce}=-\sum(Y*ln(Y^{\prime})+(1-Y)ln(1-Y^{\prime}) \tag{13}\]  
Finally, we combine the two loss functions as follows:  
\[TotalLoss=w_{1}L_{dice}+w_{2}L_{ce} \tag{14}\]  
where \(w_{1}\) and \(w_{2}\) are the weights for the Dice loss and the binary-cross entropy loss, respectively. Figure 4: Overall framework of the NSSM. The network processes all target images to extract style features, which are symbolically represented by different colors. These features are then transformed into the RKHS, where a style with minimal deviation is selected. At last, we apply both the original features and the augmented stylized features to train the network using cross-entropy and the Dice loss function aforementioned in Equation (14).