A class-weighted supervised contrastive learning long-tailed bearing
  fault diagnosis approach using quadratic neural network
Deep learning has achieved remarkable success in bearing fault diagnosis.
However, its performance oftentimes deteriorates when dealing with highly
imbalanced or long-tailed data, while such cases are prevalent in industrial
settings because fault is a rare event that occurs with an extremely low
probability. Conventional data augmentation methods face fundamental
limitations due to the scarcity of samples pertaining to the minority class. In
this paper, we propose a supervised contrastive learning approach with a
class-aware loss function to enhance the feature extraction capability of
neural networks for fault diagnosis. The developed class-weighted contrastive
learning quadratic network (CCQNet) consists of a quadratic convolutional
residual network backbone, a contrastive learning branch utilizing a
class-weighted contrastive loss, and a classifier branch employing
logit-adjusted cross-entropy loss. By utilizing class-weighted contrastive loss
and logit-adjusted cross-entropy loss, our approach encourages equidistant
representation of class features, thereby inducing equal attention on all the
classes. We further analyze the superior feature extraction ability of
quadratic network by establishing the connection between quadratic neurons and
autocorrelation in signal processing. Experimental results on public and
proprietary datasets are used to validate the effectiveness of CCQNet, and
computational results reveal that CCQNet outperforms SOTA methods in handling
extremely imbalanced data substantially.
Wei-En Yu, Jinwei Sun, Shiping Zhang, Xiaoge Zhang, Jing-Xiao Liao
A class-weighted supervised contrastive learning long-tailed bearing fault diagnosis approach using quadratic neural network

###### Abstract

Deep learning has achieved remarkable success in bearing fault diagnosis. However, its performance oftentimes deteriorates when dealing with highly imbalanced or long-tailed data, while such cases are prevalent in industrial settings because fault is a rare event that occurs with an extremely low probability. Conventional data augmentation methods face fundamental limitations due to the scarcity of samples pertaining to the minority class. In this paper, we propose a supervised contrastive learning approach with a class-aware loss function to enhance the feature extraction capability of neural networks for fault diagnosis. The developed class-weighted contrastive learning quadratic network (CCQNet) consists of a quadratic convolutional residual network backbone, a contrastive learning branch utilizing a class-weighted contrastive loss, and a classifier branch employing logit-adjusted cross-entropy loss. By utilizing class-weighted contrastive loss and logit-adjusted cross-entropy loss, our approach encourages equidistant representation of class features, thereby inducing equal attention on all the classes. We further analyze the superior feature extraction ability of quadratic network by establishing the connection between quadratic neurons and autocorrelation in signal processing. Experimental results on public and proprietary datasets are used to validate the effectiveness of CCQNet, and computational results reveal that CCQNet outperforms SOTA methods in handling extremely imbalanced data substantially.

Bearing fault diagnosis, Supervised contrastive learning, Long-tailed distribution, Class-weighted loss function, Quadratic neural network.

## 1 Introduction

The health of bearings is critical to ensure the sound performance of rotation equipment commonly used in a broad spectrum of industrial applications [1, 2]. The failure and malfunction of bearings, which accounts for 40%-70% of engine failures, results in serious economic loss and even lead to casualties [3, 4]. Hence, it is of paramount importance to maintain bearings in a serviceable condition. Towards this goal, accurate and timely bearing fault diagnosis is an essential measure to reduce the downtime, diminish repair costs, extend bearing life, and improve the reliability as well as operational safety of rotating machinery [5]. A variety of studies in the literature find that bearing failures oftentimes get manifested as vibration signals on the surface, and exhibit specific fault frequencies corresponding to different fault modes [6, 7]. Considering the valuable information embodied in the vibration signals, a series of approaches have exploited it for condition monitoring and fault diagnosis of bearings, and the physical mechanism between vibration signals with corresponding fault types has been revealed by a variety of analytical tools, such as envelope analysis [8, 9], time-frequency analysis [10, 11, 12], and cyclostationarity analysis [13].

In general, bearing fault diagnosis can be classified into two categories: signal processing-based methods and data-driven methods. Signal processing-based methods utilize signal processing techniques, such as wavelet transform [14], short-time Fourier transform [15], blind deconvolution, and adaptive mode decomposition [16], to manually extract relevant characteristics from the raw vibration signal to facilitate the determination of the specific fault type. Although these methods have a sound mathematical foundation, they require to tailor the usage of signal processing techniques and the tuning of model parameters for each specific scenario. Data-driven methods have the potential to overcome these shortcomings. Among data-driven methods, one representative approach is deep learning, particularly convolutional neural network (CNN), it can learn feature representations from the raw data to support fault diagnosis in an end-to-end fashion [17, 18]. Additionally, CNNs possess the ability to handle large-scale data in high dimensional space, and it thus emerges as a prevailing choice for many applications. As a result, CNNs have also been extensively utilized in bearing fault diagnosis. For example, Zhang et al. [19] proposed a Deep Convolutional Neural Networks with Wide First-layer Kernels (WDCNN) to process 1D vibration signal in an end-to-end fashion for bearing fault diagnosis. Other improvements have been made to the CNN-based diagnosis model, such as Deep Residual Shrinkage Networks (DRSN) [20], Dislocated Time Series CNN (DTS-CNN) [21], and probabilistic spiking response model (PSRM) [22]. These refinements lead to a superior performance of CNN for fault diagnosis in different contexts, such as heavy noise, varying rotation speed, and cross-domain characteristics.

Despite the aforementioned achievements in CNN-based bearing fault diagnosis, most CNN-based methods rely on a balanced data to develop a good-performing model. However, in practical operating conditions, machines usually operate in a normal or healthy state for the majority of time while various types of failures only occur with quite
a low probability [23, 24]. Take nuclear power plants as an example, regular maintenance is conducted on bearings of rotation equipment, such as seawater booster pumps, to ensure their stability and prevent breakdowns. These maintenance activities significantly improve the reliability of nuclear power plants, the probability of abnormal events thus drops down to a low level [25, 26]. Statistically, the data for fault diagnosis commonly exhibits a long-tailed distribution, where the number of samples in healthy states significantly outnumbers those in the fault states. In the machine learning community, the healthy class is considered as the majority (head) class, while the fault classes are considered as the minority (tail) classes. Under such circumstances, the long-tailed dataset poses a significant challenge to the training of CNN. If the long tail feature existing in the data is neglected, the trained CNN model typically exhibits a poor performance manifested in the form of high bias and prone to overfitting. These factors, individually and collectively, eventually get translated as a considerable increase in the misclassification rate [27].

To combat class imbalance, a typical strategy is to balance the distribution of data through resampling to augment the minority class. Resampling methods, such as oversampling [28] and undersampling [29], are commonly employed to remediate the class imbalance. In addition, data generation methods, like GAN [30] and VAE [31] have been developed to generate synthetic samples to enrich the minority class. However, these methods face fundamental limitations when dealing with extremely imbalanced data. Some studies indicated that these conventional methods experienced significant performance degradation (roughly 60% accuracy) when the imbalanced rate exceeded 20:1 [32, 33, 34]. In practical scenarios, it is common to encounter such extreme class imbalance with thousands of healthy data but only a few dozen instances of fault data. Specifically, resampling methods might discard a substantial number of samples in the majority class and potentially result in the loss of valuable information retained in these discarded samples. Furthermore, the high repeatability of 1D signals makes it hard to acquire effective samples for training [24]. On the other hand, synthetic data generation methods face challenges as it is unable to guarantee the quality of synthetically generated samples particularly when the training data is scarce. As reported in Ref. [32], synthetic data generation risks distorting the distribution of the actual data and causing overfitting problems.

To overcome these challenges, contrastive learning offers a new perspective as it targets to optimize a contrastive loss function to increase the separability between positive and negative samples, thus learning a more discriminative feature space [35]. Contrastive learning has been proven to be highly effective for fault diagnosis, especially in the cases with a limited number of training samples [36, 37]. However, existing contrastive learning approaches are not yet tailored to address the long-tailed issue, and their effectiveness is unavoidably influenced by the class imbalance. As such, some studies combined contrastive learning with undersampling techniques to fight against the imbalanced dataset. For instance, Zhang et al. [32] combined contrastive learning with undersampling to achieve a balanced data distribution and trained a machine learning model using contrastive learning to achieve satisfactory outcomes in the long-tailed bearing fault diagnosis. Nevertheless, undersampling unavoidably causes the repetition of a small amount of samples in the tail and gives rise to limited representativeness in the generated samples and poor model robustness.

In this paper, we are motivated to tackle these issues by refining the contrastive learning approach from two perspectives. In the first place, we propose to adopt a polynomial neural network, and more specifically, the quadratic network, to enhance feature extraction capability in CNN. In essence, the quadratic network replaces the linear neurons with nonlinear quadratic neurons in the neural network, and such a replacement injects a heightened expressive power compared to the conventional first-order neural network according to approximation theory [38]. In addition, previous study has demonstrated the efficacy and interpretability of the quadratic network in bearing fault diagnosis when faced with strong noise [39]. Despite these encouraging findings, the central issue _why quadratic network outperforms the conventional network when processing vibration signals_ remains a mystery. In this paper, we also answer this question through a rigorous mathematical deduction and conclude that quadratic neurons are able to achieve local autocorrelation, thereby facilitating the extraction of fault-related features. Such finding is crucial for a thorough understanding of the decision-making mechanism in the quadratic network for fault diagnosis.

Secondly, supervised contrastive learning has been shown to guide the model to collapse to the vertices of a regular simplex on a hypersphere when dealing with balanced datasets [40]. However, imbalanced datasets have an explicit impact on the distribution of vertices when the model collapses, subsequently influencing the separability of features on the hypersphere. Considering the effectiveness of reweighting techniques in dealing with imbalanced data, such as focal loss [41] and cross-entropy loss [42], we argue that they can be applied to contrastive learning, particularly supervised contrastive learning, to address the long-tailed problem in the distribution. Compared to the state-of-the-art literature, the contributions of this paper are summarized as below:

1. We propose a class-weighted contrastive learning quadratic network (CCQNet) for long-tailed bearing faults diagnosis. We employ a quadratic network as a feature extraction backbone and combine it with class-weighted contrastive loss and logit-adjusted cross-entropy loss functions. Our method achieves an improvement in the model's ability to handle imbalanced data via a powerful feature extractor and a re-balanced loss function.
2. Mathematically, we demystify the superior signal feature representation ability of quadratic networks by
deducing and establishing the connection between autocorrelation and quadratic neurons. To the best of our knowledge, this is the first theory to explain quadratic networks from the perspective of signal processing.
3. We conduct comprehensive experiments using the public dataset and our own dataset. Experimental results suggest that CCQNet outperforms other state-of-the-art methods, especially in extremely imbalanced data.

The rest of the paper is structured as follows. Section 2 gives a brief review on supervised contrastive learning. Next, the proposed CCQNet and its main operators are explained in Section 3. In Section 4, several experiments are performed to verify the effectiveness of the proposed method. Finally, we conclude this paper in Section 5.

## 2 Supervised contrastive learning

The key idea of contrastive learning is to bring samples of the same label (positive samples) closer together and push samples of different labels (negative samples) to fall apart. The primary difference between self-supervised contrastive learning and fully supervised contrastive learning lies in how to select positive and negative samples. As shown in Figure 1, the fully-supervised contrastive learning regards all the samples from the same class as positive samples and treats samples from all the other classes as negative samples to fully take advantage of labeling information [35]. In general, supervised contrastive learning consists of three steps:

(1) **Data augmentation**: Given an input dataset \(S=\{\mathbf{X}\in\mathbb{R}^{N\times n};\mathbf{Y}\in\mathbb{R}^{N}\}\) consisting of sample/label pair \(\{\mathbf{x}_{i},\mathbf{y}_{i}\}_{i=1}^{N}\), two data augmentation methods, i.e., adding Gaussian noise, random scaling, are performed such that, each \(\mathbf{x}_{i}\) is extended to two additional samples \(\tilde{\mathbf{x}}_{i1},\tilde{\mathbf{x}}_{i2}\), then raw samples are augmented as \(\left\{\tilde{\mathbf{x}}_{i}\right\}_{i=1}^{2N}\), with \(i\in\mathbf{I}\equiv\{1,2,\cdots,2N\}\).

(2) **CNN construction**. The augmented samples are then passed through a backbone convolutional neural network CNN(\(\cdot\)), followed by a projection head, such as a multi-layer perceptron MLP(\(\cdot\)), and normalized to the vector \(\mathbf{z}_{i}\):

\[\begin{split}\mathbf{u}_{i}&=\text{MLP}(\text{CNN}( \tilde{\mathbf{x}}_{i})),\\ \mathbf{z}_{i}&=\frac{\mathbf{u}_{i}}{||\mathbf{u}_{i}||}.\end{split} \tag{1}\]

where \(||\cdot||\) denotes the \(L_{2}\) norm.

(3) **Building contrastive loss function**. Assuming the mini-batch size is \(B\), and the mapping network \(\phi\) projects augmented data to their latent embeddings with \(\phi:\tilde{\mathbf{X}}=\left\{\tilde{\mathbf{x}}_{i}\right\}_{i=1}^{B}\rightarrow\bm {Z}=\left\{\mathbf{z}_{i}\right\}_{i=1}^{B}\). The supervised contrastive loss (SCL) function sums up the loss of each element of the mini-batch in \(\mathbf{Z}\):

\[\mathcal{L}^{sup}=\sum_{i=1}^{B}\mathcal{L}^{sup}_{i}. \tag{2}\]

In a mini-batch, suppose the positive output \(\mathbf{z}_{p}\in\mathbf{Z}\) as the same category of \(\mathbf{z}_{i}\) that does not contain \(\mathbf{z}_{i}\), and the negative output \(\mathbf{z}_{a}\in\mathbf{Z}\) as the arbitrary output except \(\mathbf{z}_{i}\). The SCL function of each \(\mathbf{z}_{i}\) is:

\[\mathcal{L}^{sup}_{i}=\frac{-1}{|\mathbf{P}_{i}|}\sum_{\mathbf{p}\in\mathbf{P}_{i}}\log \frac{\exp\left(\mathbf{z}_{i}\cdot\mathbf{z}_{p}/\tau\right)}{\sum_{a\in\mathbf{A}_{i}} \exp\left(\mathbf{z}_{i}\cdot\mathbf{z}_{a}/\tau\right)}, \tag{3}\]

where \(\mathbf{A}_{i}\equiv\{\{1,2,\cdots,\mathbf{B}\}\setminus\{i\}\}\) is the indices of all mini-batch samples that do not contain \(i\), \(\mathbf{P}_{i}\equiv\left\{p\in\mathbf{A}_{i}:\tilde{y}_{p}=\tilde{y}_{i}\right\}\) is the indices of all mini-batch samples that have the same class as index \(i\), \(|\mathbf{P}_{i}|\) is the number of samples in \(\mathbf{P}_{i}\), - denotes inner product, and \(\tau\in\mathbb{R}^{+}\) is the temperature parameter. Therefore, \(\frac{1}{|\mathbf{P}_{i}|}\) is used to calculate the average of the logarithmic term. Note that in supervised contrastive learning, the SCL function only uses the augmented samples to update network parameters.

For any sample, all positives (augmented data with the same label) in a mini-batch contribute to the numerator. Thus, the goal of supervised contrastive learning is to minimize the SCL function, which increases the value of the numerator. This encourages the network to closely align representations to all instances from the same category, as updated parameters of the network make \(\mathbf{z}_{i}\cdot\mathbf{z}_{p}\) become larger [35, 43].

As a type of representation learning, supervised contrastive learning also requires a classifier to achieve classification tasks. Two typical strategies include two-stage and one-stage training. Regarding the former, the first stage learns features by using the SCL function and the second stage updates classifiers using the cross-entropy loss function [35]. As for the latter, the SCL function and the cross-entropy function are placed in two branches and trained simultaneously [44]. The one-stage strategy showed efficiency and effectiveness in handling small data [33, 45], and we adopt this strategy for our framework.

However, supervised contrastive learning also faces difficulties in handling the imbalanced data [32]. In this case, the number of healthy samples is substantially larger than the

Figure 1: The framework of supervised contrastive learning.
faulty samples. In a mini-batch, healthy samples make up of the majority and other fault categories are only a minority or even non-existent. As a result, supervised contrastive learning struggles to increase the distance between minority classes, limiting its effectiveness in addressing the class imbalance. To overcome this issue, we consider enhancing the network's feature extraction capability and balancing the contrastive loss function within each class, thereby adapting it to handle long-tailed datasets.

## 3 Proposed Methodology

An overview of our proposed method is given in Figure 2, and the developed approach consists of four steps: data augmentation, quadratic network construction, classifier learning, and contrastive learning. The first step aims to generate extra data for contrastive learning by leveraging data augmentation techniques. The second step employs a quadratic convolutional residual network as the backbone of the model to extract informative features from the raw signal. In the third and fourth step, two MLPs are employed as projection networks: the classifier branch employs a logit-adjusted cross-entropy (CE) loss function to complete the classification task, while the contrastive learning branch utilizes a class-weighted loss function to capture the latent representation of long-tailed data.

### Data augmentation

The proposed method starts by randomly sampling the long-tailed data, and each selected raw sample \(\mathbf{x}\) is passed through the data augmentation module to generate a pair of positive samples \(\bar{\mathbf{x}}_{1},\bar{\mathbf{x}}_{2}\) for supervised contrastive learning. There are four data augmentation methods commonly used in signal processing:

1. **Adding Gaussian noise**: Gaussian noise \(\mathbf{n}\) is added to each sample \(\mathbf{x}\). Here, we set \(\mathbf{n}\) follows a Gaussian distribution \(N(0,0.01)\). Note that all data augmentation parameters we used refer to Ref. [46]. \[\bar{\mathbf{x}}=\mathbf{x}+\mathbf{n}.\] (4)
2. **Random scaling**: A random variable \(\mathbf{s}\) with value sampling from a Gaussian distribution \(N(0,0.01)\) is multiplied with each sample \(\mathbf{x}\). \[\bar{\mathbf{x}}=\mathbf{x}\cdot\mathbf{s}.\] (5)
3. **Random stretching**: The sample \(\mathbf{x}\) is stretched along the time axis. The degree of stretching is specified by a scaling factor denoted by \(\mathbf{r}\). The value of \(\mathbf{r}\) is randomly sampled from a uniform distribution U(0, 1) for each augmentation. If the scaling factor is set to \(\mathbf{r}\), the resulting length of the stretched signal is \(\mathbf{r}\) times the length of the original signal \(\mathbf{n}\).

Figure 2: An overview of the proposed framework
Specifically, the stretched signal denoted \(\mathbf{x}_{\text{stretched}}[j]\), is obtained by performing a linear interpolation of \(\mathbf{x}\) at the positions \(rj\), where \(j\) is the index of the sample in the original signal. The final stretched signal is obtained by truncating the interpolated signal to the length of the original signal. \[\begin{split}&\mathbf{x}_{\text{stretched}}[j]=\mathbf{x}[rj],\\ &\tilde{\mathbf{x}}=\mathbf{x}_{\text{stretched}}[0:n].\end{split}\] (6)
4. **Random cropping**: a random interval of the sample is set to zero. We set the interval length to 30 and replace it with a random position \(j\) in a sample. \[\tilde{\mathbf{x}}=\{\mathbf{x}[0:j],\underbrace{[0,0,\cdots,0]}_{30},\mathbf{x}[j+30: \text{end}]\}.\] (7)

Two augmented sample pairs \(\tilde{\mathbf{x}}_{1},\tilde{\mathbf{x}}_{2}\) are produced by randomly selecting two augmentation methods, where each technique has an equal probability of 0.5 to be selected as the argumentation method. For example, \(P(\tilde{\mathbf{x}}=\mathbf{x}+\mathbf{n})=0.5\). In doing this, we ensure the diversity in the generated contrastive samples, thus enhancing the model's generalizability.

### Quadratic residual network

In this paper, we employ a quadratic convolutional network as the backbone of the neural network because a quadratic network exhibits a superior feature extraction ability compared with conventional neural networks [47, 48]. Specifically, the effectiveness of the quadratic network has been verified in bearing faults diagnosis [39].

A quadratic network replaces conventional neurons with quadratic neurons composed of an inner product and a power term of the input vector. Mathematically, given an input sample \(\mathbf{x}\in\mathbb{R}^{1\times n}\), \(\mathbf{x}=\left[x_{1},x_{2},\cdots,x_{n}\right]\), a quadratic convolutional operation can be expressed as:

\[\begin{split} Q(\mathbf{x})=\sigma((\mathbf{x}*\mathbf{w}^{\prime}+b^{\prime })\mathcal{O}(\mathbf{x}*\mathbf{w}^{\mathbf{x}}+b^{\mathbf{x}})+(\mathbf{x}\odot\mathbf{x})*\mathbf{w}^{ \mathbf{b}}+c),\end{split} \tag{8}\]

where \(*\) denotes the convolutional operation, \(\mathcal{O}\) denotes Hadamard product, \(\mathbf{w}^{\prime}\in\mathbb{R}^{\{\mathcal{O}\times 1\}}\), \(\mathbf{w}^{\mathbf{x}}\in\mathbb{R}^{\{\mathcal{O}\times 1\}}\) and \(\mathbf{w}^{\mathbf{b}}\in\mathbb{R}^{\{\mathcal{O}\times 1}}\) denote the weights of three different convolution kernels, \(\sigma(\cdot)\) is the activation function (e.g., ReLU), \(b^{\prime}\), \(b^{\mathbf{s}}\) and \(c\) denote biases corresponding to these convolution kernels.

Mathematically, studies have shown that quadratic neurons exhibit a superior ability to approximate radial functions with polynomial-level neurons, whereas conventional neurons require exponential-level neurons [48, 49]. Additionally, quadratic networks can achieve polynomial approximation, but conventional neural networks can only achieve piece-wise approximation through non-linear activation functions. These characteristics have the potential to enhance the generalization and expressiveness of neural networks, as real-world data distributions are usually non-linear.

The advantage of quadratic neurons is that they can flexibly and directly enhance the performance of conventional networks, as networks are constructed by simply replacing conventional neurons. However, quadratic networks introduce more non-linear operations and parameters, leading to increased model complexity. It presents a challenge for achieving convergence during training.

To address the aforementioned issue, two strategies are implemented. First, quadratic networks are trained using an algorithm called ReLinear [48]. The parameters of quadratic neurons are factorized into two groups: the first-order group \(\{\mathbf{w}^{\prime},b^{\prime}\}\) and the quadratic group \(\{\mathbf{w}^{\mathbf{s}},b^{\mathbf{s}},\mathbf{w}^{\mathbf{b}},c\}\). During the initialization stage, the first group undergoes normal initialization using Kaiming initialization [50], whereas the second group is set as \(\{b^{\mathbf{s}}=1;\mathbf{w}^{\mathbf{s}},\mathbf{w}^{\mathbf{b}},c=0\}\). During the training stage, different learning rates, \(\gamma_{r}\) and \(\gamma_{g,b}\), are assigned to these two groups, with \(\gamma_{r}=\alpha_{g,b}\), where \(0<\alpha<1\). ReLinear initiates the training of quadratic network starting from the first-order terms and gradually trains the quadratic terms' parameters, enabling the neural network to prevent gradient explosion.

Second, we construct a cross-layer connection strategy for the neural network to improve its stability. As depicted in Figure 3, we employ two residual blocks, referred to as QResBlocks, each composed of two Qlayers. Each Qlayer contains the mainline \(\mathbf{Q}(\mathbf{x})\) and a shortcut connection. To ensure compatibility with the channel dimension of the output variable, an additional "quadratic convolution-batch normalization" structure is introduced in Qlayer1 of QResBlock2, as illustrated in Figure 3 (b). Overall, the structural parameters of the quadratic residual network backbone are presented in Table 1.

### Class-weighted contrastive learning

The two generated sample pairs are subsequently sent to the contrastive learning branch after passing through the backbone. In this branch, the features are transformed by an MLP and then mapped to a hypersphere using \(L_{2}\) normalization (Eq. (1)). The key idea of the class-weighted

Figure 3: The structure of quadratic ResNet backbone.
contrastive learning is to design the contrastive loss function to induce neural network to pay equal attention to each class.

In the case of a long-tailed dataset, the main impact of \(\mathcal{L}^{sup}\) is attributed to the term \(\sum\limits_{a\in\mathbf{A}(t)}\exp\left(\mathbf{z}_{i}\cdot\mathbf{z}_{a}/\tau\right)\), where \(\mathbf{z}_{a}\) represents the output of each generated sample except for \(\mathbf{z}_{i}\)[51]. When confronted with imbalanced datasets, tail classes pose a challenge for the network to effectively distinguish them from each other. This is because tail classes only occupy a small proportion of \(\mathbf{z}_{a}\), even missing a certain tail category in some mini-batches. Consequently, the network's ability to accurately classify the tail classes is hindered by this imbalance in contribution between the head and tail classes.

Inspired by the reweighting technique, we design a class-aware weight to force the network to pay more attention to tail classes. That is,

\[W_{a}=\frac{1}{|\mathbf{P}_{a}|}, \tag{9}\]

where \(|\mathbf{P}_{a}|\) indicates the number of samples belonging to class \(a\). A tail class \(a\) has a much lower \(|\mathbf{P}_{a}|\) and results in a larger \(W_{a}\). By doing this, each class has its own class weight, which makes the proportion of each class in the contrastive loss function balanced. As a result, the learned representation from contrastive learning remains unaffected by class imbalance.

Next, we integrate this weight into the SCL loss function formulated in Eq. ((3)), and we thus have the class-weighted contrastive loss (CRCL) as:

\[\begin{split}&\mathcal{L}^{CRCL}=\sum\limits_{i=1}^{B}\mathcal{L }_{i}^{CRCL}\\ &=\sum\limits_{i=1}^{B}-\frac{1}{|\mathbf{P}_{i}|}\sum\limits_{p\in \mathbf{P}_{i}}\log\frac{\exp\left(\mathbf{z}_{i}\cdot\mathbf{z}_{p}\right)}{\sum_{a\in \mathbf{A}_{i}}W_{a}\exp\left(\mathbf{z}_{i}\cdot\mathbf{z}_{a}\right)}.\end{split} \tag{10}\]

Compared to the original SCL loss function, for each \(z_{a}\), we assign a weight \(W_{a}\) for class \(a\). Note that the temperature parameter \(\tau\) is eliminated to reduce the number of hyperparameters that needs to be fine-tuned.

**Remark 1.** It has been proved that the SCL guides models collapsing to the vertices of a regular simplex lying on a hypersphere with balanced datasets, and empirical evidence indicates that a regular simplex configuration is beneficial to better performance [40]. We argue that class-weighted loss function encourages features corresponding to samples in the same class learned by the network has the equidistant from each other. This makes the feature center nearly located on the vertices of a regular simplex. As shown in Figure 4, we map the imbalanced features acquired through SCL and CRCL onto a two-dimensional circle. It is evident that CRCL remarkably amplifies the separation between distinct classes. This attribute explains the ability of CRCL to handle imbalanced data.

### Classifier learning

Similar to contrastive learning, the raw signal is fed to the classifier branch after the backbone network. Here, we use the logit adjusted cross-entropy loss function \(\mathcal{L}^{LC}\) to drive the training of the classifier [52]. This function is also a class-weighted as shown below:

\[\mathcal{L}^{LC}=\sum\limits_{j\in\mathcal{I}}\mathcal{L}_{j}^{LC}=\sum\limits _{j\in\mathcal{J}}-\log\frac{\exp\left(f_{y_{j}}(\mathbf{x}_{j})+\tau\log\pi_{y_{ j}}\right)}{\sum_{y^{\prime}\in[L]}\exp\left(f_{y^{\prime}}(\mathbf{x}_{j})+\tau \log\pi_{y^{\prime}}\right)}. \tag{11}\]

where \(j\in\mathcal{J}\equiv\{1,2,\cdots,n\}\) are the indices of the raw data \(\mathbf{x}_{1},\mathbf{x}_{2},\cdots,\mathbf{x}_{N}\), \(f(\mathbf{x}_{j})\) denotes the output of the classifier, i.e. logit. \(f_{y_{j}}(\mathbf{x}_{j})\) denotes the value of the element in the logit vector classified as label \(y_{j}\). Let \([L]\) be a collection of labels \(y^{\prime}\) and \(y^{\prime}\in[L]\equiv\{1,2,\cdots,L\}\), \(\pi_{y_{j}}\) denotes the prior probability of the label \(y_{j}\), and \(\tau\) indicates temperature coefficient which is set to \(\tau=1\) in the developed approach.

Finally, we combine the \(\mathcal{L}^{CRCL}\) and \(\mathcal{L}^{LC}\) together to form the composite loss function \(\mathcal{L}\):

\[\mathcal{L}=\mathcal{L}^{CRCL}+\mathcal{L}^{LC}. \tag{12}\]

### The superiority of quadratic networks

Although some shreds of evidence suggest that the quadratic network is superior to its conventional counterpart in terms of feature extraction ability [38], while the key issue on _why the quadratic network works better than conventional neural network when dealing with vibration signals_ remains a mystery. In this subsection, we analyze the learning power of quadratic network and establish its connection with signal autocorrelation.

\begin{table}
\begin{tabular}{c c c c c c} \hline \hline Number & Type & Kernel & Channel & Stride & Padding & Output \\ \hline
0 & Input & - & - & - & 1\(\times\)2048 \\  & QConv & 1\(\times\)7 & 16 & 2 & 3 & 16\(\times\)1024 \\  & BN & - & - & - & - & 16\(\times\)1024 \\  & ReLU & - & - & - & - & 16\(\times\)1024 \\  & Max-Pool & 1\(\times\)3 & 16 & 2 & 1 & 16\(\times\)512 \\
2 & QResNet(2QConv) & 1\(\times\)3 & 16 & 1 & 1 & 16\(\times\)512 \\
3 & QResNet(2QConv) & 1\(\times\)3 & 32 & 1 & 1 & 32\(\times\)256 \\
4 & QResNet(2QConv) & 1\(\times\)3 & 64 & 1 & 1 & 64\(\times\)128 \\
5 & QResNet(2QConv) & 1\(\times\)3 & 128 & 1 & 1 & 128\(\times\)64 \\
6 & AugPool & - & - & - & - & 128\(\times\)1 \\
7 & Flatten & - & - & - & - & 128 \\ \hline \hline \end{tabular}
\end{table}
Table 1: The structural parameters of quadratic ResNet backbone.

Figure 4: Features learned by SCL and CRCL on the CWRU dataset at IB rate=10:1. Where BA, IR, and OR denote ball defect, inner race defect, and outer race defect respectively.
#### 3.5.1 Autocorrelation

Autocorrelation, also known as serial correlation in the discrete time case, measures the correlation of the signal using a delayed copy of itself. Essentially, it quantifies the similarity between two observations of a signal as a function of the time delay between them. It is used to find the periodic signal submerged by noise or identify the missing feature frequency in a signal1. Mathematically, the convolutional expression of autocorrelation \(r(\mathbf{x}):\mathbb{R}^{1\times n}\rightarrow\mathbb{R}^{1\times n}\) is as follows,

Footnote 1: [https://en.wikipedia.org/wiki/Autocorrelation](https://en.wikipedia.org/wiki/Autocorrelation)

\[\begin{split} R(\mathbf{x})&=\mathbf{x}*\mathbf{x}\\ &=\left[\sum_{i=1}^{n}x_{i}^{2},\sum_{i=1}^{n-1}x_{i}x_{i+1}, \cdots,\sum_{i=1}^{2}x_{i}x_{i+n-2},x_{1}x_{n}\right]\\ &=[r_{1},r_{2},\cdots,r_{n}].\end{split} \tag{13}\]

**Remark 2.** The convolution operation in signal processing contains both flip and translation operations, which is why autocorrelation has a negative sign ( \(\mathbf{y}=-\mathbf{x}*\mathbf{x}\)), but it only has the translation operation in deep learning. For the sake of formal uniformity, the convolution operation form of deep learning is used here. The advantage of autocorrelation is that it has excellent noise suppression. Suppose a noisy signal \(\mathbf{y}\) consists of two parts:

\[\mathbf{y}=\mathbf{x}+\mathbf{s}, \tag{14}\]

where \(\mathbf{x}\) denotes the raw signal, \(\mathbf{s}\) denotes the noise.

An autocorrelation function calculates the noisy signal and its delay as:

\[\begin{split} r_{yy,\tau}&=\sum_{i=1}^{n-\tau}(x_{ i}+s_{i})(x_{i+\tau}+s_{i+\tau})\\ &=\sum_{i=1}^{n-\tau}(x_{i}x_{i+\tau}+2s_{i}x_{i+\tau}+s_{i}s_{i+ \tau})\\ &=r_{xx,\tau}+2r_{xs,\tau}+r_{ss,\tau},\end{split} \tag{15}\]

where \(r_{ab,\tau}\) denotes the value of the autocorrelation function of the signal \(\mathbf{a}\) and \(\mathbf{b}\) when the delay is \(\tau\). As \(\mathbf{s}\) is a random noise, it does not correlate with \(\mathbf{x}\), so \(r_{xs,\tau}=0\). If \(\mathbf{s}\) itself is uncorrelated, then \(r_{ss,\tau}=0\) except \(\tau=0\). The following equation holds:

\[\left\{\begin{split} r_{yy,\tau}=r_{xx,\tau}+r_{ss,\tau},\ \tau=0\\ r_{yy,\tau}=r_{xx,\tau},\ \tau\neq 0.\end{split}\right. \tag{16}\]

The above equations indicate that the autocorrelation function can extract the feature of the signal from the noise.

#### 3.5.2 Learnable autocorrelation and quadratic neuron

We define learnable autocorrelation as multiplying a set of weight parameters \(\mathcal{W}=\{\mathbf{W}_{0},\mathbf{W}_{1},\cdots,\mathbf{W}_{n}\}\) to autocorrelation. These parameters can be updated by backpropagation in a convolutional neural network:

\[\begin{split}& R^{\mathcal{W}}(\mathbf{x})\\ &=\mathbf{W}(\mathbf{x}*\mathbf{x})\\ &=\left[\sum_{i=1}^{n}w_{i}^{1}x_{i}^{2},\sum_{i=1}^{n-1}w_{i}^{2}x _{i}x_{i+1},\cdots,\sum_{i=1}^{2}w_{i}^{n-1}x_{i}x_{i+n-2},w_{1}^{n}x_{1}x_{n} \right]\\ &=[r_{0}^{\mathbf{W}_{0}},r_{1}^{\mathbf{W}_{1}},\cdots,r_{n}^{\mathbf{W}_{n} }].\end{split} \tag{17}\]

When \(\mathcal{W}\equiv\mathbf{1}\), the learnable autocorrelation degenerates to the conventional autocorrelation.

On the other hand, the output of a quadratic convolutional layer can be factorized as:

\[\begin{split} Q(\mathbf{x})=[q_{1},q_{2},\cdots,q_{n}],\end{split} \tag{18}\]

where

\[\begin{split} q_{j}&=\left(\sum_{i=1}^{k}w_{i}^{ \prime}x_{i+j-1}+b^{\prime}\right)\left(\sum_{i=1}^{k}w_{i}^{g}x_{i+j-1}+b^{g} \right)\\ &+\sum_{i=1}^{k}w_{i}^{k}x_{i+j-1}^{2}+c\\ &=\sum_{i=1}^{k}\left(w_{i}^{\prime}w_{i}^{g}+w_{i}^{b}\right)x_{ i+j-1}^{2}+\sum_{i=1}^{k-1}w_{i}^{\prime}w_{i+1}^{g}x_{i+j-1}x_{i+j}\\ &+\sum_{i=1}^{k-2}w_{i}^{\prime}w_{i+2}^{g}x_{i+j-1}x_{i+j+1}+ \cdots+w_{1}^{\prime}w_{k}^{g}x_{j}x_{k+j-1}\\ &+b^{\prime}\sum_{i=1}^{k}w_{i}^{g}x_{i+j}+b^{g}\sum_{i=1}^{k}w_{ i}^{\prime}x_{i+j}+C.\end{split} \tag{19}\]

It is obvious that the calculation of a quadratic convolutional neuron contains the learnable autocorrelation operation. Combining Eq. (17) and Eq. (19), we have

\[\begin{split} q_{j}&=\underbrace{\mathbf{W}_{0}^{\mathbf{W}_{0 }}+r_{1}^{\mathbf{W}_{1}}+\cdots+r_{k}^{\mathbf{W}_{k}}}_{\text{Learable Autocorrelation}}\\ &+\underbrace{b^{\prime}\sum_{i=1}^{k}w_{i}^{g}x_{i+j}+b^{g}\sum_ {i=1}^{k}w_{i}^{\prime}x_{i+j}+C}_{\text{{\it Covolutional Operation}}}.\end{split} \tag{20}\]

The quadratic convolutional operation can be decomposed into two parts: the sum of learnable autocorrelation and the conventional convolutional operation. As shown in Figure 5, the first part is using the learnable autocorrelation for each subsequence adding to the final results. The second part is using learnable filters to convolute the input signal,
which is the same as a conventional convolution neural network.

With the above deduction, a quadratic network offers advantages over conventional neural networks when processing signals. The autocorrelation operation within a quadratic neuron aids in extracting valuable signals with random noise, while such capability is missing in conventional neural networks. By leveraging this feature, our methodology is able to enhance the power of feature extraction from the input data, and thus leads to an improved performance in bearing fault diagnosis.

## 4 Computational experiments

In this section, we consider two bearing datasets: the Case Western Reserve University (CWRU) rolling bearing dataset2 and our own bearing dataset, to validate the performance of the proposed method. The two datasets consist of ten categories with nine faulty bearings and one healthy bearing. In the computational experiments, we first compare CCQNet with other state-of-the-art methods under a long-tailed distribution. Next, we analyze the feature extraction ability of the proposed model through visualization of interpretable feature maps and learnable autocorrelation. Finally, we conduct several ablation studies to verify the properties of our method.

Footnote 2: [https://engineering.case.edu/bearing64tacenter/download-data-fil](https://engineering.case.edu/bearing64tacenter/download-data-fil)

### Dataset description

#### Case Western Reserve University bearing faults dataset (CWRU)

This extensively utilized dataset is collected by the Bearing Data Center at Case Western Reserve University (CWRU). The dataset is generated by applying electro-discharge machining (EDM) to motor deep groove ball bearings to artificially induce faults. Specifically, faults with diameters of 0.007 inches, 0.014 inches, and 0.021 inches are introduced into the inner race, outer race, and ball of the bearings, respectively. Subsequently, the faulty bearings are reinstalled in the test motors, and vibration data is recorded at both the drive-end (DE) and fan-end (FE). Throughout the experiments, the motor loads range from 0 to 3 HP (horsepower), while the motor speeds exhibit slight variations within the range of 1797 to 1720 RPM. The vibration signals are acquired at two sampling rates: 12 kHz and 48 kHz. In the experiments, we consider the vibration data collected at the drive-end (DE) with a 0 HP load and a sampling rate of 12 kHz.

#### Our bearing dataset

In addition to CWRU, we also collect our dataset employing angular contact ball bearings (HC7003), which are specifically designed for high-speed rotational machinery. This experiment is conducted at MIIT Key Laboratory of Aerospace Bearing Technology and Equipment, Harbin Institute of Technology. As depicted in Figure 6, the acceleration meter is directly attached to the bearings to capture the vibration signals generated by the bearings. Consistent with the CWRU dataset, we induced faults at the outer race (OR), inner race (IR), and ball (BA), encompassing three levels of severity: slight, moderate, and severe. Table 2 provides an overview of the fault types and the corresponding size in our dataset. During the test, the vibration signals were acquired at a constant motor speed of 1800 r/min using an NI USB-6002 device with a sampling rate of 12 kHz. We collected 47 seconds of bearing vibration data totaling 561,152 data points per fault category. Unlike the CWRU dataset, the bearing faults in our dataset consist of cracks with uniform sizes but varying depths. As a result, the vibration signals exhibit greater similarity among different fault types, thereby increasing the difficulty of accurately classifying the diagnostic model.

\begin{table}
\begin{tabular}{l l c} Class & Fault mode & Fault size (mm) \\ \hline C1 & Healthy Bearing & 0\(\times\)0\(\times\)0 \\ C2 & Ball cracking(Minor) & 1\(\times\)0.3\(\times\)0.1 \\ C3 & Ball cracking(Moderate) & 1\(\times\)0.3\(\times\)0.2 \\ C4 & Ball cracking(Severe) & 1\(\times\)0.3\(\times\)0.3 \\ C5 & IR cracking(Minor) & 2\(\times\)0.3\(\times\)0.1 \\ C6 & IR cracking(Moderate) & 2\(\times\)0.3\(\times\)0.2 \\ C7 & IR cracking(Severe) & 2\(\times\)0.3\(\times\)0.3 \\ C8 & OR cracking(Minor) & 2\(\times\)0.3\(\times\)0.1 \\ C9 & OR cracking(Moderate) & 2\(\times\)0.3\(\times\)0.2 \\ C10 & OR cracking(Severe) & 2\(\times\)0.3\(\times\)0.3 \\ \hline \end{tabular}
\end{table}
Table 2: Ten classes in our dataset. OR and IR denote that the faults appear in the outer race and inner race, respectively. Fault size denotes length\(\times\)width\(\times\)depth.

Figure 5: The operation of the quadratic neuron.
### Experimental setup

We conduct bearing faults diagnosis experiments by constructing long-tailed datasets. Here, we consider different imbalance rates (IB Rate) to investigate the variation of different models to the different levels of imbalance of the dataset. The IB Rate is defined as follows:

\[\text{IB Rate}=\frac{N_{normal}}{N_{fault}}, \tag{21}\]

where \(N_{normal}\) and \(N_{fault}\) represent the number of normal samples and the number of faulty samples in each class, respectively.

Next, due to each class of measured signals consisting of only one long sequence, we randomly extract a subsequence comprised of 2048 data points as one input \(\mathbf{x}_{i}\). Afterwards, the entire dataset is divided into three parts: training set, validation set, and testing set. Specifically, in the training set, the number of normal data is set to 500, while the number of other fault categories is selected by the IB Rate (5:1, 10:1, 20:1, 50:1), which is set to 100, 50, 25, and 10, respectively. For all categories in the validation and test sets, we extracted 250 samples with balanced classes. Identical standardization is applied to all the samples.

#### 4.2.1 Baseline methods

We compare the developed method 3 with several well-known convolutional neural networks commonly used in the field of bearing fault diagnosis, including conventional CNN, contrastive learning-based methods, and resampling-based methods. The descriptions of baseline methods are given as follows:

Footnote 3: Our code is available at [https://github.com/yuueien120/CCQNet](https://github.com/yuueien120/CCQNet) for readers’ verification.

1. **WDCNN** is a widely used method for bearing fault diagnosis. It utilizes a wide convolutional kernel in the first convolutional layer to extract features and suppress noise [19].
2. **SupCon** is a supervised contrastive learning method. It leverages the concept of contrastive learning to enhance the discriminative power of the learned representations [46].
3. **SelfCon** is a self-supervised contrastive learning method. It applies contrastive learning in a self-supervised manner to learn effective representations [53].
4. **DNCNN** is a convolutional neural network that incorporates normalization techniques for both convolutional layers and neuron weights. This normalization helps improve the stability and generalization of the model [54].
5. **CA-SupCon** combines oversampling techniques (class-aware sampler) with supervised contrastive learning. This method aims to address class imbalance issues in the dataset and enhance the discriminative ability of the learned representations [32].
6. **Oversample+reweight** is a method that combines oversampling techniques with neuronal normalization for classifiers. It also adopts a reweighted loss function to tackle class imbalance problems in bearing fault diagnosis [41].

#### 4.2.2 Training strategies

We employ the stochastic gradient descent (SGD) optimizer to optimize all networks. The batch size is set to 64, and the training epoch is set to 200 for our method. Hyperparameters of other methods are set according to the values reported in the corresponding articles. In addition, we train CCQNet using the ReLinear algorithm [48], which facilitates the fast convergence of quadratic networks. At the initial stage, the parameters in a quadratic neuron are initialized as \(\mathbf{w}_{g}=0,\mathbf{w}_{b}=0,c=0\) and \(b_{g}=1\), while \(\mathbf{w}_{r}\) and \(b_{r}\) follow the random initialization. At the training stage, the linear terms and quadratic terms are trained with different learning rates with \(\gamma_{l}\) and \(\gamma_{q}\) respectively. We set a scale factor \(\alpha\) to control the two learning rates, that is

\[\gamma_{q}=\alpha\cdot\gamma_{l},\ \ 0<\alpha<1. \tag{22}\]

At last, the learning rate is adjusted using the cosine annealing strategy.

#### 4.2.3 Evaluation metrics

The classification performance of the model is assessed using accuracy (ACC), F1 score, and MCC (Matthews Correlation Coefficient). These metrics are chosen as they are

Figure 6: Our bearing faults test rig and bearing failure of inner race and outer race.
insensitive to category imbalance. The definitions of these metrics are as follows:

\[\text{ACC}=\frac{1}{C}\sum_{i=1}^{C}\frac{\text{TP}_{i}}{\text{TP}_{i}+\text{FP} _{i}}, \tag{23}\]

\[\text{F1}=\frac{1}{C}\sum_{i=1}^{C}\frac{2\text{TP}_{i}}{2\text{TP}_{i}+\text{ FP}_{i}+\text{FN}_{i}}, \tag{24}\]

\[\text{MCC}=\frac{c\cdot s-\sum_{i=1}^{C}p_{i}\cdot t_{i}}{\sqrt{\left(s^{2}- \sum_{i=1}^{C}p_{i}^{2}\right)\left(s^{2}-\sum_{i=1}^{C}t_{i}^{2}\right)}}. \tag{25}\]

where \(\text{TP}_{i}\), \(\text{FP}_{i}\), and \(\text{FN}_{i}\) denote the true positive rate, false positive rate, and false negative rate for class \(i\), respectively; C denotes the number of classes, \(t_{i}\), \(p_{i}\), \(c\) and \(s\) are the number of times class \(i\) truly occurred, the number of times class \(i\) is predicted, the total number of samples correctly predicted, and the total number of samples for \(C\) classes respectively.

### Long-tail fault diagnosis results

Tables 3 and 4 report the performance of the considered models on CWRU dataset and our bearing dataset. Firstly, it is clear that when the IB rate rises, both ACC, F1, and MCC drop down. Even so, our method still outperforms other SOTA methods across all the metrics. Secondly, when the IB rate is small (5:1, 10:1), the advantage of our method is not obvious, i.e., WDCNN and CCQNet all reach 100% in F1 and MCC. As the IB Rate rises, performance of all baseline methods drop significantly or even fail to classify. For instance, when IB rate = 50:1, oversample+reweight only has 19% F1 on the CWRU dataset. However, CCQNet remains over 76% F1 and MCC on two datasets at the 50:1 IB rate, while the second-best method WDCNN only achieves 67.18% and 6.40% in F1 on the two datasets, respectively. The results indicate that our proposed method excels at handling extremely imbalanced data.

Next, we focus on evaluating the performance of the top 4 best-performing methods at an imbalance rate of 50:1. To this end, we conduct a detailed analysis of their classification capability for each fault mode by examining the confusion matrix. As shown in Figure 7, all the methods possess basic fault detection capabilities while their ability to accurately classify the different fault modes is affected by the imbalance level. It is noteworthy that all methods achieve high accuracy when classifying the healthy category, which can be attributed to the sufficient number of healthy samples available to train the model. However, in the CWRU dataset and our own bearing dataset, the three baseline methods exhibit poor performance in classifying ball faults (BA1, BA2, BA3) and inner race faults (IR2, IR3), respectively. In contrast, our proposed CCQNet demonstrates a much better classification accuracy for these fault modes. Additionally, CCQNet exhibits superior performance in the overall fault classification performance compared to the other three methods. These observations suggest that CCQNet is better equipped to handle extreme class imbalance conditions.

### Classification visualization

#### 4.4.1 Visualization by t-SNE

We use t-distributed stochastic neighbor embedding (t-SNE) to visualize the learned feature representation in a 2D space. For the sake of comparison, we only select the first four best methods for comparison. Figure 8 shows 2D feature maps on each test set at 100:1 IB Rate. Firstly, regarding the CWRU dataset, the ball faults (BA1, BA2, BA3) of the three compared methods are separated insufficiently, which can lead to misdiagnosing. Secondly, in our dataset, the same phenomenon appears in some clusters, the clusters of the three compared methods all show an overlap. However, it can be seen that the clusters of different classes are more evenly distributed in CCQNet, and it is possible to better separate the inter-class samples and better aggregate the intra-class samples. The results also suggest that CCQNet has better feature extraction ability under extreme class imbalance conditions.

#### 4.4.2 Feature map visualization

Here, we provide insights into the superior feature extraction capabilities of quadratic networks compared to their conventional counterparts. Figure 9 show cases the feature maps at each layer of our quadratic residual network and a corresponding ResNet backbone with the same structure. Firstly, it is evident that the input signal exhibits distinct local features of high amplitude, resulting from fault-induced vibrations. Notably, both the conventional and quadratic networks preserve these local features at each layer. However, as the network layers become deeper, the quadratic network progressively places more emphasis on the local features with high amplitude values in the raw signal, surpassing the conventional network. Particularly, from the second to the fifth layer of visualized features, the quadratic network gives heightened attention to local features associated with fault-related signals. This finding strongly indicates that quadratic networks have superior feature representation to support accurate fault diagnosis.

#### 4.4.3 Learnable autocorrelation

Consistent with our earlier analysis, the effectiveness of quadratic networks lies in their ability to perform learnable autocorrelation, and enables extraction of significant signal features from noise. To investigate the practical anti-noise robustness of quadratic networks, we conduct experiments by introducing Gaussian noise with a variance of 10 to the signals. Specifically, we visualized the autocorrelation operation term that weights set as 1 and the learnable autocorrelation term (Eq. (20)) in the first layer of a quadratic network. The results as shown in Figure 10 indicate that while the autocorrelation operation can effectively extract fault-related signals from the noise, it also amplifies certain parts of extraneous noise. This limitation arises because autocorrelation is primarily designed to enhance transient impulses in the signal. In contrast, the learnable autocorrelation term demonstrates a remarkable ability to extract fault-related signals. The weights learned by the neural network
act as adaptive filters, which further enhances the feature extraction capability. These findings emphasize the crucial role of learnable autocorrelation terms in empowering quadratic networks for effective signal feature extraction.

### Analysis experiments

#### 4.5.1 Hyperparameter sensitivity

It is crucial to consider the hyperparameters of the quadratic network, particularly the scale factor \(\alpha\). In this study, we investigated the effects of \(\alpha\) on the model's performance and conducted experiments to evaluate its sensitivity. The results are reported in Table 5. When the IB rate is set to 50:1, we observed that using an \(\alpha\) value below \(10^{-3}\) led to improved results. However, when \(\alpha\) exceeded \(10^{-3}\), the model parameters were unable to converge fully, resulting in a decrease in performance. Therefore, for our dataset, the optimal \(\alpha\) value is determined to be 0.00001, which achieved an accuracy (ACC) of 75.25%. For the CWRU dataset, the optimal \(\alpha\) value is set to be 0.00005, resulting in an ACC of 80.12%. Note that the exact value of \(\alpha\) may vary depending on the datasets. Therefore, we recommend

\begin{table}
\begin{tabular}{l c c c c c c} \hline \hline IB rate & \multicolumn{2}{c}{5:1} & \multicolumn{4}{c}{10:1} \\ \hline  & ACC & F1 & MCC & ACC & F1 & MCC \\ \hline WDCNN & 87.74\(\pm\)0.34 & 87.46\(\pm\)0.31 & 86.58\(\pm\)0.37 & 66.31\(\pm\)3.39 & 65.02\(\pm\)3.32 & 63.23\(\pm\)3.63 \\ SupCon & 93.36\(\pm\)0.35 & 92.84\(\pm\)0.40 & 92.83\(\pm\)0.39 & 83.05\(\pm\)3.45 & 82.00\(\pm\)3.71 & 81.69\(\pm\)3.69 \\ SelfCon & 93.84\(\pm\)0.32 & 93.66\(\pm\)0.34 & 93.25\(\pm\)0.34 & 57.81\(\pm\)1.59 & 50.74\(\pm\)2.33 & 55.55\(\pm\)1.62 \\ DNCNN & 85.80\(\pm\)0.56 & 85.34\(\pm\)0.58 & 84.37\(\pm\)0.61 & 78.18\(\pm\)0.48 & 77.13\(\pm\)0.58 & 76.05\(\pm\)0.52 \\ CA-Supcon & 93.04\(\pm\)0.32 & 92.67\(\pm\)0.37 & 92.44\(\pm\)0.35 & 88.81\(\pm\)0.73 & 88.37\(\pm\)0.78 & 87.73\(\pm\)0.79 \\ oversample+reweight & 86.47\(\pm\)0.43 & 84.75\(\pm\)0.48 & 85.73\(\pm\)0.45 & 88.36\(\pm\)1.29 & 87.26\(\pm\)1.44 & 87.38\(\pm\)1.40 \\ CCQNet & **96.69\(\pm\)0.19** & **96.64\(\pm\)0.20** & **96.37\(\pm\)0.21** & **93.27\(\pm\)0.34** & **93.03\(\pm\)0.35** & **92.73\(\pm\)0.37** \\ \hline IB rate & \multicolumn{2}{c}{20:1} & \multicolumn{4}{c}{50:1} \\ \hline WDCNN & 40.96\(\pm\)1.98 & 38.04\(\pm\)2.31 & 36.15\(\pm\)2.25 & 12.65\(\pm\)0.24 & 6.40\(\pm\)0.37 & 4.99\(\pm\)0.40 \\ SupCon & 38.83\(\pm\)2.62 & 32.21\(\pm\)2.64 & 34.64\(\pm\)2.83 & 16.88\(\pm\)0.47 & 10.36\(\pm\)0.31 & 10.45\(\pm\)0.69 \\ SelfCon & 34.94\(\pm\)3.10 & 25.65\(\pm\)2.58 & 31.27\(\pm\)3.87 & 11.00\(\pm\)0.85 & 6.88\(\pm\)0.53 & 1.24\(\pm\)1.06 \\ DNCNN & 41.45\(\pm\)0.82 & 39.65\(\pm\)0.76 & 35.59\(\pm\)0.90 & 14.99\(\pm\)0.87 & 10.76\(\pm\)1.16 & 7.25\(\pm\)1.16 \\ CA-Supcon & 50.33\(\pm\)2.58 & 47.12\(\pm\)2.99 & 45.99\(\pm\)2.80 & 16.04\(\pm\)1.43 & 12.66\(\pm\)2.01 & 7.76\(\pm\)1.70 \\ oversample+reweight & 59.50\(\pm\)1.06 & 54.39\(\pm\)1.66 & 56.94\(\pm\)1.14 & 10.32\(\pm\)0.30 & 3.40\(\pm\)0.37 & 0.41\(\pm\)0.39 \\ CCQNet & **92.39\(\pm\)0.34** & **91.16\(\pm\)0.41** & **91.83\(\pm\)0.33** & **75.25\(\pm\)1.11** & **72.64\(\pm\)1.16** & **73.31\(\pm\)1.22** \\ \hline \hline \end{tabular}
\end{table}
Table 4: Performance comparison (%) on our bearing dataset, where the bold-faced number indicates the best performance.

\begin{table}
\begin{tabular}{l c c c c c} \hline \hline IB rate & \multicolumn{2}{c}{5:1} & \multicolumn{4}{c}{10:1} \\ \hline  & ACC & F1 & MCC & ACC & F1 & MCC \\ \hline WDCNN & **100.00\(\pm\)0.00** & **100.00\(\pm\)0.00** & **100.00\(\pm\)0.00** & 99.85\(\pm\)0.06 & 99.85\(\pm\)0.06 & 99.83\(\pm\)0.07 \\ SupCon & 99.61\(\pm\)0.09 & 95.09\(\pm\)0.09 & 99.57\(\pm\)0.10 & 93.36\(\pm\)0.34 & 92.39\(\pm\)0.47 & 92.95\(\pm\)0.34 \\ SelfCon & 95.24\(\pm\)0.40 & 95.09\(\pm\)0.44 & 94.82\(\pm\)0.43 & 86.30\(\pm\)0.54 & 84.64\(\pm\)0.66 & 85.51\(\pm\)0.56 \\ DNCNN & 94.43\(\pm\)0.52 & 94.26\(\pm\)0.56 & 94.03\(\pm\)0.54 & 81.95\(\pm\)0.73 & 80.59\(\pm\)0.91 & 80.48\(\pm\)0.76 \\ CA-Supcon & 99.82\(\pm\)0.08 & 99.82\(\pm\)0.08 & 99.80\(\pm\)0.09 & 96.42\(\pm\)0.30 & 96.37\(\pm\)0.31 & 96.09\(\pm\)0.32 \\ oversample+reweight & 91.67\(\pm\)0.13 & 89.80\(\pm\)0.22 & 91.41\(\pm\)0.12 & 79.96\(\pm\)0.14 & 73.86\(\pm\)0.22 & 79.25\(\pm\)0.14 \\ CCQNet & **100.00\(\pm\)0.00** & **100.00\(\pm\)0.00** & **100.00\(\pm\)0.00** & **100.00\(\pm\)0.00** & **100.00\(\pm\)0.00** & **100.00\(\pm\)0.00** \\ \hline IB rate & \multicolumn{2}{c}{20:1} & \multicolumn{4}{c}{50:1} \\ \hline WDCNN & 93.66\(\pm\)0.46 & 93.26\(\pm\)0.52 & 93.14\(\pm\)0.49 & 69.3\(\pm\)0.52 & 67.18\(\pm\)0.65 & 66.81\(\pm\)0.55 \\ SupCon & 78.72\(\pm\)0.25 & 72.88\(\pm\)0.19 & 78.03\(\pm\)0.30 & 59.92\(\pm\)0.21 & 50.74\(\pm\)0.30 & 59.78\(\pm\)0.25 \\ SelfCon & 75.23\(\pm\)0.26 & 73.23\(\pm\)0.26 & 73.33\(\pm\)0.27 & 41.63\(\pm\)0.32 & 36.55\(\pm\)0.31 & 37.13\(\pm\)0.37 \\ DNCNN & 71.19\(\pm\)0.41 & 70.85\(\pm\)0.39 & 68.35\(\pm\)0.47 & 61.24\(\pm\)0.83 & 59.61\(\pm\)0.94 & 57.79\(\pm\)0.90 \\ CA-Supcon & 82.21\(\pm\)0.39 & 81.77\(\pm\)0.42 & 80.56\(\pm\)0.42
conducting thorough experiments to determine the optimal \(\alpha\).
of quadratic networks in bearing fault diagnosis. It is evident that QResNet achieves an accuracy of 75.25% on our dataset and 80.12% on the CWRU dataset, compared to 71.15% and 69.33% achieved by ResNet34, respectively. Additionally, the ResNet model with the same structure as QResNet exhibits the worst performance, with an accuracy that is 22.94% lower on our dataset and 13.83% lower on the CWRU dataset compared to QResNet. This further highlights the advantages of using a quadratic network in achieving better classification performance and higher computational efficiency.

**The form of quadratic neurons.** To investigate the contributions of different parts of quadratic neurons, we conduct experiments using two degraded versions of the standard quadratic neuron. As shown in Table 7, we construct two different types of quadratic neurons, which are degraded versions of the standard quadratic neuron. In the first one, we remove the power term, and in the second one, we remove one of its inner-product terms. As shown in Table 7, the computational results clearly suggest that the standard quadratic neuron outperforms the degraded versions. In particular, the accuracy of the standard one is roughly 10% higher than that of its degraded counterparts on our dataset. Secondly, the performance of two degraded neurons exhibits variations across the two datasets. The degraded neuron lacking an inner-product term shows a slight decrease in accuracy (79.39%) on the CWRU dataset but experiences a significant drop on our dataset (62.16%). On the other hand, the degraded neuron without the power term demonstrates a remarkable decrease in performance on both datasets, and achieves an accuracy of 75.30% and 62.38% on the CWRU and our dataset, respectively. The results indicate that the power term of a quadratic neuron plays an important role in the network.

**Quadratic network structures.** We perform experiments at IB Rate = 50:1 to assess the effect of the number of layers and the kernel size of the quadratic network on the model performance. The results are summarized in Tables 8 and 9. With regard to the former, it can be observed that increasing the number of layers in the quadratic network leads to an improved performance. When the number of model layers is 5, the network achieves an accuracy of 75.25% on our dataset and an accuracy of 80.12% on the CWRU dataset. As for the latter, the optimal kernel size is 7, which yields the best performance on both datasets. Based on these results, it can be concluded that a quadratic network

\begin{table}
\begin{tabular}{l|c c c c} \hline Method & \#Params & \#Flops & Our bearing dataset ACC(\%) & CWRU ACC(\%) \\ \hline ResNet & 200K & 22.6M & 52.31 & 66.29 \\ ResNet34 & 7200K & 719M & 71.15 & 69.33 \\ QResNet & **700K** & **66M** & **75.25** & **80.12** \\ \hline \end{tabular}
\end{table}
Table 6: The accuracy (%) of quadratic ResNet and conventional ResNet backbones on the CWRU and our dataset at 50:1 IB rate.

\begin{table}
\begin{tabular}{c|c|c} \hline Quadratic Function & CWRU & Our dataset \\ \hline \((\mathbf{x}*\mathbf{w}^{\prime}+\mathbf{b})\odot(\mathbf{x}*\mathbf{w}^{\prime}+\mathbf{b}^{\prime})\) & 75.30 & 62.38 \\ \((\mathbf{x}*\mathbf{w}^{\prime}+\mathbf{b}^{\prime})+(\mathbf{x}\odot\mathbf{x})*\mathbf{w}^{\prime}+c\) & 79.39 & 62.16 \\ \((\mathbf{x}*\mathbf{w}^{\prime}+\mathbf{b}^{\prime})\odot(\mathbf{x}*\mathbf{w}^{\prime}+\mathbf{b}^{ \prime})+(\mathbf{x}\odot\mathbf{x})*\mathbf{w}^{\prime}+c\) & **80.12** & **75.25** \\ \hline \end{tabular}
\end{table}
Table 7: The accuracy (%) of different quadratic functions on the CWRU and our dataset at 50:1 IB rate.

Figure 10: Comparison of weighted autocorrelation operations with a weight of 1 and learnable autocorrelation operations with training weights in the time and time-frequency domains.

Figure 9: Comparison of the features of each layer of the first-order and quadratic network.
with five layers and a convolutional kernel size of 7 is the optimal structure for fault diagnosis.

## 5 Conclusion

In this paper, we have introduced a novel framework called CCQNet, based on quadratic networks, for addressing long-tailed distribution scenarios in bearing fault diagnosis. CCQNet incorporates a quadratic residual network (QResNet) as its backbone for effective feature extraction and employs two branches with class-weighted contrastive loss and logit-adjusted cross-entropy loss to ensure equal attention to all categories. We have also provided insights into quadratic networks, highlighting their ability to focus on local fault signal features through autocorrelation operations. Experimental results have demonstrated the outstanding performance of CCQNet in highly imbalanced data scenarios. Our work promotes the application of contrastive learning for long-tailed distribution-based bearing fault diagnosis and encourages further exploration of quadratic neural networks. As CCQNet serves as a versatile framework for long-tailed data classification, future research should explore its potential in a broader range of application scenarios. For instance, extending it to few-shot or zero-shot learning, which are also highly desirable issues in fault diagnosis.

## Acknowledgement

We would like to express our sincere gratitude to Prof. Xiaoli Zhao and Mr Hongyuan Zhang from the MIT Key Laboratory of Aerospace Bearing Technology and Equipment, Harbin Institute of Technology for their selfless support and valuable assistance in conducting the bearing experiments for this research. Their contributions have been invaluable and greatly appreciated.
