# Unsupervised Learning-Based Spectrum Sensing Algorithm with Defending Adversarial Attacks
## 1 Introduction  
The exponential growth of wireless services leads to an increasing shortage of spectrum resources. Cognitive radio (CR) [1] allows secondary users (SU) to use idle authorized spectrum, alleviating the distress situation of a short supply of spectrum resources. Spectrum sensing (SS) [2] plays a crucial role in CR, and extensive research has been conducted in this area. Classical spectrum sensing algorithms use detection statistics designed according to the difference between signal and noise statistical features to determine whether the authorized spectrum is occupied, but the detection performance depends on artificial feature parameters designed and prior information about primary user (PU). With the powerful feature extraction capability of neural networks, deep learning [3] can automatically extract the features of signal samples received in complex communication scenarios without any prior information. The detection performance of the trained spectrum sensing networks are better than that of the classical spectrum sensing algorithms. At present, the spectrum sensing algorithms based on deep learning have achieved remarkable results [4; 5; 6; 7]. In [4],the residual network was used to extract the sample features of the primary user signal and noise, and the obtained sensing model has good generalization performance for the static primary user signal. The residual network and attention mechanism network were used to extract sample features and realize the spectrum sensing of dynamic primary users [5]. However, supervised training was adopted in [4; 5], which relied too much on labeled samples. To overcome the dependence of model training on sample labels, a semi-supervised algorithm was used to label samples with false labels and expanded the original data set to train the spectrum sensing model [6]. To reduce the dependence of spectrum sensing model training on labeled samples, a comparative learning framework was also proposed and the residual network was designed to extract rich features from unlabeled samples [7]. Although the spectrum sensing algorithms based on deep learning have presented a series of achievements in different scenarios, the performance of the spectrum sensing models are susceptible to malicious attacks [8; 9; 10; 11]. Enhancing the defense capability of the spectrum sensing model against attacks and improving the robustness and security of the models have become important issues to be solved urgently. As a result, the issue of spectrum sensing security has attracted the attention of researchers. Primary user emulation attack (\(PUEA\)) and spectrum sensing data falsification (\(SSDF\)) are two classic attack modes that attack traditional spectrum sensing algorithms, and the defense algorithms against these two attacks have been widely studied. However, there are few researches on the defense of primary user adversarial attack (\(PUAA\)), which attacks spectrum sensing algorithms based on deep learning. Therefore, the unsupervised learning-based spectrum sensing algorithm with defending adversarial attacks (USDAA) that defends white box \(PUAA\) is proposed in this paper. The contributions of this paper are as follows:  
* An unsupervised learning spectrum sensing algorithm is proposed to effectively defend the fast gradient sign method (FGSM) and the projected gradient descent (PGD) attacks. The unsupervised adversarial pre-training is carried out by using clean samples and adversarial samples with different perturbation values. The defense model is fine-tuned by a small number of adversarial samples. * In the adversarial pre-training stage, the encoders extract the features of clean samples and adversarial samples, respectively; the decoders reconstruct clean samples and adversarial samples according to the feature latent representations, and the contrast loss and reconstruction loss are used to optimize the network parameters of the model. It reduces the dependence of model training on labeled samples and improves the robustness of the model to attack perturbations.