# Deep Learning for Audio Event Detection and Tagging on Low-Resource Datasets
## 2 Task Factorisation
### Audio Event Detection (WHEN)
#### 2.2.2 Multi Instance Learning
The most common ones are: if \(Y_{i}=0\), all instances of bag \(B_{i}\) are negative instances, hence \(y_{ij}=0,\forall j\), while, on the other hand, if \(Y_{i}=1\), at least one instance of bag \(B_{i}\) is equal to one. For all instances of bag \(B_{i}\), this relation between the bag label and instance labels can be simply written as:  
\[Y_{i}=\max_{j}y_{ij}. \tag{1}\]  
The conventional way of training a neural network for strong labelling is providing instance specific (strong) labels for a collection of training instances. Training is performed by updating the network weights to minimize the average divergence between the network output in response to these instances and the desired output, the ground truth of the training instances. In the MIL setting using Equation (1) to define a characteristic of the strong labels, we must modify the manner in which the divergence to be minimized is computed, in order to utilize only weak labels, as proposed in [24]. Let \(o_{ij}\) represent the output of the network for input \(B_{ij}\), the \(j\)-th instance in \(B_{i}\), and the \(i\)-th bag of training instances. We define the bag-level divergence for bag \(B_{i}\) as:  
\[E_{i}=\frac{1}{2}\left(\max_{1\leq j\leq M_{j}}(o_{ij})-Y_{i}\right)^{2}, \tag{2}\]  
where \(Y_{i}\) is the label assigned to bag \(B_{i}\). The overall divergence on the training set is obtained by summing the divergences of all the bags in the set:  
\[E=\sum_{i=1}^{N}E_{i}. \tag{3}\]  
Equation (2) indicates that if at least one instance of a positive bag is perfectly predicted as positive, or all the instances of a negative bag are perfectly predicted as negative, then the error on the concerned bag is zero. Otherwise, the weights will be updated according to the error on the instance whose corresponding actual output is the maximal among all the instances in the bag. Note that such an instance is typically the most easy to be predicted as positive for a positive bag, while it is the most difficult to be predicted as negative for a negative bag. It seems that this sets a low burden on producing a positive output but a strong burden on producing a negative output. As indicated in [25], the value of a bag is fully determined by its instance with the maximal output, regardless of how many real positive or negative instances are in the bag. Therefore, in fact, the burden on producing a positive or negative output is not unbalanced, at least at bag-level. However, on an instance-level, when using max to compute the loss, only one instance per bag contributes to the gradient, which may lead to inefficient training. Additionally, as mentioned earlier, in positive bags, the network only has to accurately predict the label for the easiest positive instance to reach a perfect accuracy, thus not paying as much attention to the rest of the positive instances that might be harder to accurately detect. In order to train our proposed WHEN network, we want all predictions to weigh in on the loss and not just the one with the maximum value, as is the case with MIL using max. In [26], the authors proposed the \"noisy-or\" pooling function to be used instead of max. However, noisy-or has been proven to not perform as well as max for audio event detection [27]. As discussed in [27], a significant problem with noisy-or is that the label of a bag is computed via the product of the instance labels as seen in Equation (4). This calculation relies heavily on the assumed conditional independence of instance labels, an assumption which is highly inaccurate in audio event detection. Furthermore, this can lead the system to believe a bag is positive even though all its instances are negative:\[Y_{i}=1-\prod_{1\leq j\leq M_{j}}(1-y_{ij}). \tag{4}\]  
Using all instances in a bag for computation of the loss and backpropagated gradient is important, since the network ideally should acquire some knowledge from every instance in every epoch. However, it is hard to find an elegant theoretical interpretation of the characteristics of the instances in a bag.