# Yielding Multi-Fold Training Strategy for Image Classification of Imbalanced Weeds
## 4 Methodology  
Given a training set and a DNN model, the conventional training methods first train the whole training model with several epochs. In each epoch, the samples are randomly divided into an equal number of batches and each batch is fed to the model. No sample appears in two different batches. After the model is trained on every epoch, it is validated on the validation set. With this strategy, the model tends to encounter majority species more often than minority species, making the model robust to majority species since it can capture the whole variety of features in the majority samples. Otherwise, the lack of samples of minority species would make the model less focused and cause difficulties learning about the general characteristics of these species. Our proposed strategy (YMufT) solves this problem by dividing the samples in the training set into multiple folds. Minority species are presented to the model more often than majority species. The smaller the number of samples, the more times the related species will be learned. This division strategy reduces the bias of the DNN model towards the majority species. We define the balance error (BE) to measure the imbalance of the dataset (Definition 1). Figure 6: Examples of the 21 species in the Chonnam National University (CNU) weeds dataset. The order of species (left to right, top to bottom) corresponds to the labels (from left to right) in Figure 5.  
Figure 7: Distribution of classes in the large PlantVillage dataset. **Definition 1 (Balance Error). **_A dataset \(\mathcal{D}\) has \(c\) species, and each species \(y_{i}\) has \(n_{i}\) samples. \(n_{max}\) and \(n_{min}\) are the largest and smallest number of samples in a species, respectively. We calculate the Balance Error BE of \(\mathcal{D}\) using Formula (1) below. The lower the value of \(BE_{\mathcal{D}}\), the greater the balance of \(\mathcal{D}\)._  
\[BE_{\mathcal{D}}=\frac{n_{\max}-n_{\min}}{\sum_{i}n_{i}} \tag{1}\]  
Consider the number of samples in a species as a discrete random variable. By this definition, \(BE_{CNU}\) of the CNU Weeds dataset is 0.11316. Only five species have more than the median number of samples (18,974), and the standard deviation around this median is 12,557.854. In the large PlantVillage dataset, \(BE_{IPV}=0.0733\), and 11 classes have more samples than the median (1546.5). The standard deviation is 1135.824. In the small PlantVillage dataset, while \(BE_{SPV}=0.0966>BE_{IPV}\), only 10 classes have more than the median number of samples (1618). The standard deviation around this median is 1254.96. In the PlantSeedlings dataset, \(BE_{PS}=0.0920\), and five species have more than the median number of samples (500.5). The standard deviation is 97.62. Considering the uniform distribution as the standard distribution for a balanced dataset, we can measure the relative entropy from the distribution of a dataset to the uniform distribution. Equation (2) is the formula used to calculate the relative entropy from \(P\) to \(Q\), where \(P\) and \(Q\) are two discrete probability distributions and \(\chi\) is a set of species in a dataset. \[D_{KL}(P\parallel Q)=\sum_{x\in\chi}P(x)\log_{2}\biggl{(}\frac{P(x)}{Q(x)} \biggr{)} \tag{2}\]  
Assume that \(P\) is the probability distribution of a dataset with \(c\) species, and \(Q\) is a uniform distribution. We can rewrite (2) to (3). \[D(P)=\log_{2}(c)+\sum_{x\in\chi}P(x)\log_{2}(P(x)) \tag{3}\]  
Using (3) to calculate the relative entropy of the distribution of a dataset to the uniform distribution, we obtain \(D(P_{CNU})=0.5649,D(P_{IPV})=0.2597,D(P_{SPV})=0.415\), and \(D(P_{PS})=0.0998\) corresponding to the CNU Weeds, large PlantVillage, small PlantVillage, and PlantSeedlings datasets, respectively. This shows that the distribution of the PlantSeedlings dataset is close to uniform, while the CNU Weeds dataset is quite imbalanced. We define a set \(\mathcal{Y}\) consisting of the number of samples of each species. This set has \(c\) elements, in which the \(i^{th}\) element is \(n_{i}\).