## 2 Proposed Method
### Outlier Classifier for Binary Classification
#### 2.1.1 Attention-Based Audio Classification Network  
[PERSON] et al. [15] adopts this network in anomalous sound detection by changing the filters sizes slightly and outperforms the most methods across all machine types and IDs. In this paper, we add Convolutional Block Attention Module (CBAM) [21] which contains of Channel-attention module (CAM) and Spatial-attention module (SAM), the specific structure of CBAM is shown in Figure 3, they are concerned about \"_what_\" and \"_where_\" the audio events happen respectively. CAM can be regarded as a process of selecting relevant semantic features based on context semantics. When the network wants to predict the \"_fan_\" audio, CAM will assign larger weight to the feature map containing the \"_fan_\" spectrum structure. The SAM will locate the segments of \"_fan_\" on the feature map, thereby filtering out background noise. So attention module is helpful for accurately expressing the characteristics of normal sounds.  
Figure 3: The Convolutional Block Attention Module (CBAM) contains of Channel-attention module (CAM) and Spatial-attention module (SAM).  
Figure 2: (**a**) The Outlier classifier distinguishs the outliers which are considered as anomalies from the normal, and it directly outputs the anomaly scores of unseen sounds. (**b**) The ID classifier identifies different machine IDs. For the ID classifier, we use two methods for anomaly detection as shown in Figure 2b, the first is to calculate the similarity between unseen sounds and normal sounds using embeddings extracted from the hidden layer, another method uses the confidence of classification.  
The feature map \(\mathbf{X}\) (\(C\times H\times W\)) passes through CAM and then SAM. CAM calculates the weight (\(C\times 1\times 1\)) of each channel, and multiplies the weight with the original feature map to obtain a weighted feature map. In order to obtain the weight of the channel dimension, this module calculates the average value and maximum value of each channel respectively with _avgpool_ and _maxpool_, and feeds them to a common multi-layer perceptron, and then the two outputs are added together and normalized by the sigmoid function to get the final weight. CAM is defined as:  
\[\begin{split}\mathbf{W}_{C}&=\sigma(\mathbf{W}_{2} (\delta(\mathbf{W}_{1}\cdot avgpool(\mathbf{X})))\\ &\quad+\mathbf{W}_{2}(\delta(\mathbf{W}_{1}\cdot maxpool( \mathbf{X}))))\end{split} \tag{1}\]  
where \(\mathbf{W}_{1}\in\mathbb{R}^{C\times\frac{C}{r}}\), \(\mathbf{W}_{2}\in\mathbb{R}^{\frac{C}{r}\times C}\) represent FC layers, \(\delta(\cdot)\), \(\sigma(\cdot)\) represent ReLU and sigmoid function respectively, \(r\) denotes the scaling ratio.  
SAM calculates the average and maximum values of different channels on the same point to obtain weights (\(1\times H\times W\)) with \(avgpool^{\prime}\) and \(maxpool^{\prime}\), concatenates them along the channel dimensions, and then the weights passes a convolutional layer and sigmoid function to get the final weights. The weights is multiplied by each channel on the time-frequency domain to obtain a weighted feature map. SAM is defined as:  
\[\mathbf{W}_{S}=\sigma\big{(}\mathbf{W}\big{[}avgpool^{\prime}(\mathbf{X}); maxpool^{\prime}(\mathbf{X})\big{]}\big{)} \tag{2}\]  
where \(\mathbf{W}\) denotes a convolutional layer. CAM and SAM are connected in a sequential manner, the order of operations is as follows:  
\[\begin{split}\mathbf{Y}&=\mathbf{W}_{C}(\mathbf{X}) \otimes\mathbf{X}\\ \mathbf{Z}&=\mathbf{W}_{S}(\mathbf{Y})\otimes\mathbf{ Y}\end{split} \tag{3}\]  
where \(\otimes\) represents element-wise multiplication.