Few-shot spectrum sensing method based on temporal prediction and context contrastive learning
Through the small sample spectrum perception method learned by time prediction and context comparison, the self-supervised encoder and Transformer encoder are used to solve the problem of insufficient performance of the existing spectrum perception method for labeled data dependence and small sample scenarios, and achieve efficient spectrum perception effect.
Patent Information
- Application Number
- CN202510653118.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-21
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2045-05-21
AI Technical Summary
Existing spectrum perception methods rely on prior knowledge, supervised learning requires a large amount of label data, and insufficient detection performance in small sample scenarios.
A small sample spectrum perception method based on time prediction and context comparison learning is adopted, and pre-trained through a self-supervised encoder, and the model is fine-tuned using the pre-trained sample set and the fine-tuned sample set. Combined with the Transformer encoder and the fully connected layer, self-supervised comparison learning is realized and the dependence on the annotated data is reduced.
It significantly reduces the dependence on labeled data, improves the detection performance of the model in small sample scenarios, enhances the spectrum perception ability in low signal-to-noise ratio environment, improves data utilization efficiency, and reduces data acquisition and labeling costs.
Smart Images

Figure CN120180241B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication signal processing, and in particular to a small sample spectrum sensing method based on time prediction and context contrast learning. Background Art
[0002] In cognitive radio, spectrum sensing technology, through intelligent spectrum management, not only improves spectrum utilization efficiency but also reduces interference risks, supports dynamic spectrum access, and supports the development of emerging wireless communication technologies. Spectrum sensing plays a crucial role in improving communication quality, ensuring network stability, and promoting wireless resource sharing. It is a foundational technology for implementing next-generation wireless communication systems. However, because traditional spectrum sensing methods rely on prior knowledge of channels or noise distribution, traditional spectrum sensing algorithms suffer from signal-to-noise ratio barriers, limiting their accuracy.
[0003] With the development of deep learning technology, its powerful feature extraction capabilities have improved spectrum sensing performance. Existing deep learning-based spectrum sensing algorithms are mostly based on supervised learning. While they can achieve excellent detection performance with sufficient training data, network training relies on a large number of real labels. In real radio environments, it is feasible to acquire a large number of actual signals using receivers. However, manually labeling these signals is extremely time-consuming and can lead to mislabeling. Currently, research on spectrum sensing with limited labeled samples is still in its infancy, both domestically and internationally. Summary of the Invention
[0004] In view of the above analysis, the embodiments of the present invention aim to provide a small-sample spectrum sensing method based on time prediction and contextual contrastive learning, which solves the technical problems of existing spectrum sensing methods relying on prior knowledge, requiring a large amount of labeled data for supervised learning, and having insufficient detection performance in small-sample scenarios.
[0005] The purpose of the present invention is mainly achieved through the following technical solutions:
[0006] The present invention discloses a small sample spectrum sensing method based on time prediction and context contrast learning, comprising the following steps:
[0007] Preprocessing the acquired original electromagnetic signal including the modulation signal to obtain a pre-training sample set without labels and a fine-tuning sample set with labels; wherein the labels include the presence of the modulation signal and the absence of the modulation signal;
[0008] Using the pre-trained sample set to pre-train a small sample spectrum sensing model for time prediction and context comparison, thereby obtaining a pre-trained small sample spectrum sensing model; wherein the small sample spectrum sensing model includes a self-supervised encoder, and the self-supervised encoder is used to obtain an embedded feature vector of the input sample;
[0009] Adding a flattening layer and a fully connected classification layer after the pre-trained self-supervised encoder to obtain a fine-tuned encoder; fine-tuning the fine-tuned encoder using the fine-tuning sample set to obtain a fine-tuned small sample spectrum perception model;
[0010] The electromagnetic signal to be sensed is pre-processed and then input into the fine-tuned small sample spectrum sensing model to perform spectrum sensing and obtain a spectrum sensing result.
[0011] Furthermore, the preprocessing of the original electromagnetic signal including the modulated signal to obtain a pre-training sample set without labeled labels and a fine-tuning sample set with labeled labels includes:
[0012] Normalizing the electromagnetic signal including the modulation signal to obtain a normalized electromagnetic signal;
[0013] Obtaining signal samples corresponding to the normalized electromagnetic signal, and generating noise samples having the same number as the signal samples;
[0014] Dividing the signal samples and corresponding noise samples into pre-training samples and fine-tuning samples;
[0015] The pre-training samples are subjected to strong enhancement and weak enhancement processing respectively to obtain strong enhancement samples and weak enhancement samples; wherein,
[0016] The strongly enhanced samples and the weakly enhanced samples constitute a pre-training sample set; the fine-tuning samples and labels constitute a fine-tuning training set.
[0017] Furthermore, the small sample spectrum sensing model further includes a Transformer encoder, a first fully connected layer and a second fully connected layer; wherein,
[0018] The self-supervised encoder is used to obtain the embedded feature vectors corresponding to the strongly enhanced samples and the weakly enhanced samples;
[0019] The Transformer encoder is used to obtain a corresponding context vector based on the embedded feature vector through a multi-head self-attention mechanism and a feedforward neural network;
[0020] The first fully connected layer is used to obtain a first positive sample pair and a first negative sample pair based on the context vector;
[0021] The second fully connected layer is used to obtain a second positive sample pair and a second negative sample pair based on the context vector;
[0022] When training a small-sample spectrum sensing model, the prediction contrast loss is used to maximize the similarity of the first positive sample pair and minimize the similarity of the first negative sample pair; and the context contrast loss is used to maximize the similarity of the second positive sample pair and minimize the similarity of the second negative sample pair.
[0023] Furthermore, the self-supervised encoder includes first, second, and third convolution blocks connected in series; obtaining the embedded feature vectors corresponding to the strongly enhanced samples and the weakly enhanced samples includes:
[0024] Strongly enhance the sample and weakly enhanced samples Input the self-supervised encoder, and After passing through the first, second and third convolution blocks in sequence, they are mapped to the embedding space respectively to obtain the corresponding embedded feature vectors and .
[0025] Furthermore, a corresponding context vector is obtained based on the embedded feature vector through a multi-head self-attention mechanism and a feedforward neural network, including:
[0026] Based on a randomly selected time step t, the embedding feature vector and They are divided into current slices and future slices respectively;
[0027] Randomly initialize a context vector with the same dimension as the current slice; add the context vector to the starting position of the current slice to obtain the current slice with the context vector added and ;
[0028] After the current slice with the context vector added passes through the multi-head self-attention layer, the self-attention of each head node is obtained; all head nodes are merged to obtain the feature vector and ;
[0029] based on and After the first residual connection, the first addition and the layer normalization layer, we get and ;
[0030] Will and Obtain feature vectors through the feedforward network layer and ;
[0031] Will and After the second residual connection, the second addition and the layer normalization layer, the feature vector is obtained and ;from and The starting position extraction learns itself and 、 The context vector of the attention relationship of other elements in ; obtain the embedded feature vector and The corresponding context vectors are and .
[0032] Furthermore, the context vector Input the first fully connected layer to predict the predicted value of the future slice corresponding to the weakly enhanced sample ; and the context vector based on the weakly enhanced sample Input the first fully connected layer to predict the predicted value of the future slice corresponding to the strongly enhanced sample ;
[0033] The predicted value and true value of the future slice of the same pre-training sample are the first positive sample pair; the predicted value of the future slice of the pre-training sample and the true value of the future slice of other pre-training samples in the same training batch are the first negative sample pair;
[0034] The second fully connected layer respectively and Projection is a strong enhancement feature and weak enhancement features ; obtained from the same pre-training sample and is the second positive sample pair; the pre-training sample obtained Compared with other pre-training samples in the same training batch is the second negative sample pair.
[0035] Furthermore, pre-training the small sample spectrum sensing model based on the pre-training sample set includes:
[0036] Loading the strong enhancement samples and weak enhancement samples in the pre-training sample set into the self-supervised encoder;
[0037] Pre-training a small-sample spectrum sensing model based on a joint loss function, and continuously adjusting the model parameters through backpropagation and gradient descent optimization algorithms to maximize the similarity between the first and second positive sample pairs, and minimize the similarity between the first and second negative sample pairs;
[0038] Until the joint loss function converges or the pre-training ends at a preset maximum number of iterations, the small sample spectrum sensing model parameters are saved to obtain a pre-trained small sample spectrum sensing model;
[0039] Among them, the joint loss function ,as follows:
[0040] ;
[0041] in, Based on predict Prediction contrast loss of Based on predict Prediction contrast loss of is the context contrast loss; 、 They are respectively predicted contrast loss and contextual contrast loss The weight of .
[0042] Further, based on predict Prediction contrast loss ,as follows:
[0043] ;
[0044] based on predict Prediction contrast loss ,as follows:
[0045] ;
[0046] in, is the number of the first fully connected layer, is the set of other samples in the same batch except the current sample; 、 are respectively the embedded feature vectors of other samples in the same batch except the current sample; Represents the first fully connected layer fully connected layers, ;
[0047] The context contrast loss , using the cosine similarity function and the temperature coefficient to maximize the similarity of the second positive sample pair and minimize the similarity of the second negative sample pair, as follows:
[0048] ;
[0049] in, is the number of samples per batch, 、 Respectively The context vectors corresponding to the strong enhancement samples and the weak enhancement samples and Features after projection by the second fully connected layer; is a weakly enhanced sample of other pre-training samples in the same training batch; is the cosine similarity function; is an exponential function; is the temperature coefficient; is the sum of the similarities of all second negative sample pairs in the same training batch.
[0050] Furthermore, the fine-tuning training includes:
[0051] Load the parameters of the self-supervised encoder in the pre-trained few-shot spectrum sensing model ;
[0052] The flattening layer flattens the embedded feature vector into a one-dimensional vector;
[0053] The fully connected classification layer classifies the one-dimensional vector output by the flattening layer to obtain the predicted probability of the presence or absence of the modulation signal. and ;
[0054] The cross-entropy loss function is used to measure the difference between the predicted probability and the true label until the loss function converges or the preset maximum number of fine-tuning training times is reached, and a fine-tuned small-sample spectrum perception model is obtained.
[0055] Furthermore, the pre-processed real-time acquired electromagnetic signal is input into the fine-tuned small sample spectrum sensing model to perform spectrum sensing, including:
[0056] Loading the fine-tuned small sample spectrum sensing model, and dynamically setting a decision threshold based on a preset false alarm probability;
[0057] The preprocessed electromagnetic signal acquired in real time is input into the fine-tuned small sample spectrum sensing model; when the predicted probability value output by the fine-tuned small sample spectrum sensing model is greater than or equal to the decision threshold, the spectrum sensing result is that a modulated signal exists, otherwise the modulated signal does not exist.
[0058] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0059] 1. The proposed small-sample spectrum sensing algorithm based on temporal prediction and contextual contrastive learning is based on a self-supervised contrastive learning strategy, learning similarities or differences in data through positive and negative sample pairs. Only a small amount of labeled sample data is required during the fine-tuning phase, significantly reducing the reliance on labeled data. This solves the problem of supervised learning in existing technologies requiring large amounts of labeled data.
[0060] 2. The present invention extracts enhanced representation features from electromagnetic signal data through a self-supervised encoder and utilizes cross-sample temporal predictive contrastive learning and contextual contrastive learning to make the representation features more discriminative. This means that positive sample pairs are kept as close as possible in the embedding space, while negative sample pairs are kept as far apart, thereby maintaining a high detection probability with a low false alarm probability.
[0061] 3. Existing traditional spectrum sensing methods rely on prior knowledge such as channel or noise distribution, and suffer from problems such as signal-to-noise ratio barriers. This invention does not require such prior knowledge. Instead, it achieves spectrum sensing by learning the intrinsic information of a large number of unlabeled electromagnetic signal samples, eliminating the reliance on prior knowledge.
[0062] 4. Traditional spectrum sensing algorithms have limited performance in low signal-to-noise ratio environments. This invention uses the Transformer encoder to capture the time series dependencies and dynamic changes of signals. Combined with contextual comparative learning, it enhances the model's ability to learn signal features, thereby overcoming the limitations of the signal-to-noise ratio wall and improving spectrum sensing performance in low signal-to-noise ratio environments.
[0063] 5. The existing technology faces costs and error risks when acquiring a large number of labeled samples. The present invention fully utilizes unlabeled data through data enhancement and contrastive learning, improves data utilization efficiency, and reduces data acquisition and labeling costs.
[0064] In the present invention, the above-mentioned technical solutions can be combined with each other to achieve more preferred combinations. Other features and advantages of the present invention will be described in the following description, and some advantages will become apparent from the description or be learned through practice of the present invention. The objectives and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0065] The accompanying drawings are only used for the purpose of illustrating specific embodiments and are not to be considered as limiting the present invention. Throughout the drawings, the same reference symbols denote the same components.
[0066] Figure 1 This is a flow chart of a small sample spectrum sensing method based on time prediction and context contrast learning in an embodiment of the present invention;
[0067] Figure 2Schematic diagram of pre-training, fine-tuning training and spectrum sensing in an embodiment of the present invention;
[0068] Figure 3 Schematic diagram of the structure of a self-supervised encoder according to an embodiment of the present invention;
[0069] Figure 4 Schematic diagram of the Transformer encoder structure in an embodiment of the present invention;
[0070] Figure 5 Schematic diagram of the self-supervised encoder structure in the fine-tuning training stage in an embodiment of the present invention. DETAILED DESCRIPTION
[0071] The preferred embodiments of the present invention will be described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, and are not used to limit the scope of the present invention.
[0072] The small sample spectrum sensing method in the present invention aims to solve the technical problems of existing spectrum sensing methods, such as reliance on prior knowledge, scarcity of labeled data or difficulty in obtaining samples, and insufficient detection performance in small sample scenarios.
[0073] A specific embodiment of the present invention discloses a small sample spectrum sensing method based on time prediction and context contrast learning, such as Figure 1 and Figure 2 As shown, the following steps are included:
[0074] Step S1: preprocessing the acquired original electromagnetic signal including the modulated signal to obtain a pre-training sample set without labels and a fine-tuning sample set with labels; wherein the labels include the presence of the modulated signal and the absence of the modulated signal;
[0075] Step S2: performing time prediction and context comparison pre-training on the small sample spectrum sensing model using the pre-trained sample set to obtain a pre-trained small sample spectrum sensing model; wherein the small sample spectrum sensing model includes a self-supervised encoder, and the self-supervised encoder is used to obtain an embedded feature vector of the input sample;
[0076] Step S3: adding a flattening layer and a fully connected classification layer after the pre-trained self-supervised encoder to obtain a fine-tuned encoder; fine-tuning the fine-tuned encoder using the fine-tuning sample set to obtain a fine-tuned small sample spectrum perception model;
[0077] Step S4: pre-process the electromagnetic signal to be sensed and input it into the fine-tuned small sample spectrum sensing model to perform spectrum sensing and obtain a spectrum sensing result.
[0078] In this invention, "small sample size" refers to the relatively small number of labeled samples used to train and fine-tune spectrum sensing models. In practical applications, acquiring large amounts of labeled electromagnetic signal data is difficult. Labeling signals requires significant manpower, material resources, and time, and can also lead to labeling errors. This invention aims to achieve efficient spectrum sensing by leveraging the inherent information of a large number of unlabeled electromagnetic signal samples, combined with a small number of labeled samples.
[0079] Specifically, the method of the present invention uses a self-supervised contrastive learning strategy, using a large number of unlabeled pre-training samples in the pre-training phase to learn the characteristic representation of the signal. During the fine-tuning phase, only a small number of labeled fine-tuning samples are used to fine-tune the model, making the small-sample spectrum sensing model adaptable to specific spectrum sensing tasks. This small-sample learning approach significantly reduces the reliance on labeled data and improves the model's detection performance in small-sample scenarios.
[0080] Step S1 includes steps S11-S12.
[0081] Step S11: Acquire an original electromagnetic signal including a modulated signal.
[0082] Collect the original electromagnetic signals (IQ signals) when AM (Amplitude Modulation), ASK (Amplitude Shift Keying), PSK (Phase Shift Keying), or 16QAM (16-Quadrature Amplitude Modulation) modulated signals are present.
[0083] The modulation signals include but are not limited to four modulation signals: AM, ASK, PSK and 16QAM.
[0084] Exemplarily, MATLAB is used to generate electromagnetic IQ signals of four modulation types: AM, ASK, PSK and 16QAM.
[0085] The SNR (Signal-to-Noise Ratio) ranges from -20dB to 4dB, with an interval of 2dB and 13 SNRs; each raw electromagnetic signal sample contains 1024 sampling points.
[0086] Step S12: pre-process the original electromagnetic signal to obtain a pre-training sample set without labeled labels and a fine-tuning sample set with labeled labels.
[0087] The preprocessing of the original electromagnetic signal including the modulated signal to obtain a pre-training sample set without labeled labels and a fine-tuning sample set with labeled labels includes:
[0088] Normalizing the electromagnetic signal including the modulation signal to obtain a normalized electromagnetic signal;
[0089] Obtaining signal samples corresponding to the normalized electromagnetic signal, and generating noise samples having the same number as the signal samples;
[0090] Dividing the signal samples and corresponding noise samples into pre-training samples and fine-tuning samples;
[0091] The pre-training samples are subjected to strong enhancement and weak enhancement processing respectively to obtain strong enhancement samples and weak enhancement samples; wherein,
[0092] The strongly enhanced samples and the weakly enhanced samples constitute a pre-training sample set; the fine-tuning samples and labels constitute a fine-tuning training set.
[0093] All raw electromagnetic signals Before training, they are normalized to obtain normalized electromagnetic signals. Eliminating the dimensionality difference of the signal amplitude makes it easier to learn features, but does not change the intrinsic relationship between the IQ components.
[0094] The IQ signal consists of two orthogonal components:
[0095] I (In-phase): in-phase signal, corresponding to the real part;
[0096] Q (Quadrature-phase): Quadrature signal, corresponding to the imaginary part.
[0097] electromagnetic signals , which is expressed as follows:
[0098] ;
[0099] in, Is an imaginary unit.
[0100] electromagnetic signals It is the complex synthesis result of IQ signals and is directly used for spectrum analysis, modulation and demodulation processing.
[0101] (1) Generate a pre-training sample set without annotated labels.
[0102] At each SNR, 65 signal samples are generated for each modulation type of the electromagnetic signal, totaling:
[0103] 4 modulation signals 13 SNRs 65 samples = 3380 signal samples
[0104] Generate the same number of additive white Gaussian noise samples as the signal samples (mean 0, variance ), 3380 noise samples.
[0105] Samples with modulated signals and a corresponding equal number of noise samples without modulated signals are used as pre-training samples, totaling 6760 unlabeled pre-training samples.
[0106] Data augmentation is performed on a large number of unlabeled pre-training samples to increase their diversity. Based on the characteristics of electromagnetic signals, two augmentation methods, strong augmentation and weak augmentation, are used to improve the robustness and generalization ability of the learned representations.
[0107] Strong enhancement performs a large-scale transformation on the original data to generate samples that are significantly different from the original electromagnetic signal, enabling the model to learn a wider range of features and patterns of the data; relatively speaking, weak enhancement slightly perturbs the original electromagnetic signal, keeping the main features of the electromagnetic signal unchanged, and simulating the slight changes that may occur in the electromagnetic signal in the actual environment.
[0108] The weak enhancement adopts the "dithering" strategy. Add a normal distribution Gaussian noise. Get the electromagnetic signal Corresponding weakly enhanced samples , as shown below:
[0109] ;
[0110] Weak enhancement is used to simulate slight environmental interference and maintain the main structure of the signal.
[0111] For strong enhancement, a "displacement-dithering" strategy is used, including:
[0112] The first step is segmentation, which divides the preprocessed signal into The number of random segments, ;
[0113] For example, The value is 5.
[0114] The second step is permutation, which randomly shuffles the segmented segments to disrupt the temporal relationship;
[0115] The third step is dithering, adding obedience to the replaced signal noise, and obtain a strongly enhanced sample ,as follows:
[0116] ;
[0117] in, The function represents the random order adjustment of the signal segments; To convert the signal sample Split into part.
[0118] For each unlabeled pre-training sample , each sample generates a pair of enhanced samples , used as positive samples for contrastive learning; and and Dimensions are consistent. and The pre-training sample set does not include .
[0119] All pre-training set samples have hidden labels, which are used for self-supervised pre-training in the subsequent step S22. Hidden labels mean that they are without labels.
[0120] (2) Generate a set of fine-tuning samples with annotated labels.
[0121] Similar to the above-mentioned acquisition of pre-training samples, two signal samples are generated for each electromagnetic signal with each signal-to-noise ratio and modulation type, and the same number of Gaussian white noise samples as the electromagnetic signal are also generated. The signal samples and noise samples constitute a fine-tuning sample set.
[0122] At each SNR, each modulation type generates 2 signal samples, totaling:
[0123] 4 types of signals 13 SNRs 2 samples = 104 signal samples
[0124] Generate an equal number of 104 Gaussian white noise samples.
[0125] Samples with modulated signals and an equal number of noise samples without modulated signals, totaling 208 fine-tuning samples. Labels are added to the fine-tuning samples, with signal samples labeled "with modulated signals" and noise samples labeled "without modulated signals." These labels are used for model fine-tuning training in the subsequent step S3.
[0126] The function of step S1 is to process the unlabeled pre-training samples by two data enhancement methods, strong enhancement and weak enhancement, to obtain a pre-training sample set; and to obtain a fine-tuning sample set.
[0127] Step S2 includes steps S21-S22.
[0128] Step S21: Construct a small sample spectrum sensing model, such as Figure 2 shown.
[0129] The small sample spectrum sensing model includes a self-supervised encoder, a Transformer encoder, a first fully connected layer and a second fully connected layer; wherein,
[0130] The self-supervised encoder is used to obtain the embedded feature vectors corresponding to the strongly enhanced samples and the weakly enhanced samples;
[0131] The Transformer encoder is used to obtain a corresponding context vector based on the embedded feature vector through a multi-head self-attention mechanism and a feedforward neural network;
[0132] The first fully connected layer is used to obtain a first positive sample pair and a first negative sample pair based on the context vector;
[0133] The second fully connected layer is used to obtain a second positive sample pair and a second negative sample pair based on the context vector;
[0134] When training a small-sample spectrum sensing model, the prediction contrast loss is used to maximize the similarity of the first positive sample pair and minimize the similarity of the first negative sample pair; and the context contrast loss is used to maximize the similarity of the second positive sample pair and minimize the similarity of the second negative sample pair.
[0135] Self-supervised encoder, Transformer encoder, first and second fully connected layers, as follows:
[0136] (1) Self-supervised encoder
[0137] The self-supervisory encoder includes first, second, and third convolution blocks connected in series; obtaining the embedded feature vectors corresponding to the strongly enhanced samples and the weakly enhanced samples, including:
[0138] Strongly enhance the sample and weakly enhanced samples Input the self-supervised encoder, and After passing through the first, second and third convolution blocks in sequence, they are mapped to the embedding space respectively to obtain the corresponding embedded feature vectors and .
[0139] like Figure 3 Figure 1. Schematic diagram of the self-supervised encoder structure during the pre-training phase. The self-supervised encoder maps a large amount of high-dimensional, unlabeled pre-training sample data into an embedding space, resulting in a low-dimensional, information-rich representation.
[0140] The self-supervised encoder input is two enhanced versions of each unlabeled pre-training sample, the strong enhanced sample or weakly enhanced samples ;
[0141] The output of the self-supervised encoder is represented by a low-dimensional embedded feature vector and , the dimension is ( is the set of real numbers, is the maximum time step, is the characteristic length of each time step).
[0142] like Figure 3 As shown, for any or , through the nonlinear transformation of the first, second and third convolution blocks, any high-dimensional input signal Two enhanced pre-training samples or Mapped to the embedding space respectively, we get their low-dimensional and information-rich representations as follows:
[0143] ;
[0144] ;
[0145] in, is a self-supervised encoder, Encode the results for the self-supervised encoder; is the embedding feature vector Characteristics of each time step; is the embedding feature vector Characteristics of each time step; is the maximum time step, which indicates the length of the time dimension of the embedded feature vector; is the feature length of each time step, which represents the feature dimension length of the embedded feature vector.
[0146] Embedding space maps high-dimensional, complex sample data into a low-dimensional continuous vector space. Vectors in the embedding space (called embedding vectors) capture the essential characteristics of the data, placing similar data closer together in the embedding space, making it easier for models to understand and process.
[0147] The self-supervised encoder enables the learned feature representation to maximize the similarity in the embedding space between two strong and weak enhanced samples generated from the same sample (considered as positive sample pairs), while minimizing the similarity between two strong and weak enhanced samples generated from different samples (considered as negative sample pairs). That is:
[0148] ;
[0149] in, is a distance function that measures the similarity between samples. is significantly greater than; 、 are respectively the strong enhancement sample and weak enhancement sample of the i-th pre-training sample, is a weakly enhanced sample of the jth pre-training sample that is different from the i-th sample.
[0150] The distance function used in the present invention to measure the similarity between samples is the cosine similarity function, as shown below:
[0151] ;
[0152] ;
[0153] Cosine similarity is used to measure the similarity of two vectors in direction. The closer the value is to 1, the more similar they are, and the closer to -1, the less similar they are.
[0154] The self-supervised encoder in the pre-training phase consists of the first, second, and third convolutional blocks. The first convolutional block is ConvBlock-32, the second convolutional block is Conv Block-64, and the third convolutional block is Conv Block-128.
[0155] The first, second, and third convolution blocks have the same structure, but the number of convolution kernels is different.
[0156] For the first convolution block, Conv Block-N, N is 32, 32 convolution kernels, each convolution kernel size is 8x1;
[0157] For the second convolution block, Conv Block-N, N is 64, 64 convolution kernels, each convolution kernel size is 8x1;
[0158] For the third convolution block, Conv Block-N, N is 128, 128 convolution kernels, and each convolution kernel size is 8x1.
[0159] The structure of each convolution block is as follows:
[0160] "8x1Conv, N" represents N convolution kernels of size 8x1. The convolution operation is used to extract local features of the input data. N is 32, 64, or 128.
[0161] Batch Norm stands for batch normalization, which performs batch normalization on the output after the convolution operation. Batch normalization can accelerate the training process and improve the stability of the model.
[0162] ReLU represents the activation function of the neuron, which introduces nonlinearity by setting all negative values to zero and retaining positive values;
[0163] MaxPool represents maximum pooling, which downsamples the features activated by ReLU to reduce the spatial size of the features; the pooling operation reduces computational complexity while retaining important feature information;
[0164] Dropout is a random inactivation operation on neurons, randomly discarding the output of some neurons during training; Dropout is used to prevent overfitting and improve the generalization ability of the model.
[0165] Each unlabeled strong enhancement sample or weakly enhanced samples Input the first convolution block, pass through the second and third convolution blocks, and finally output the embedded feature vector or .
[0166] The self-supervised encoder design provides high-quality embedded feature vector representations for subsequent cross-sample temporal prediction and contextual contrastive learning, a core component of few-shot spectrum sensing. The self-supervised encoder enables the learned representation to maximize the similarity in the embedding space between two strong and weak augmented samples generated from the same sample (considered a positive sample pair), while minimizing the similarity between two strong and weak augmented samples generated from different samples (considered a negative sample pair).
[0167] (2) Transformer Encoder
[0168] The Transformer encoder consists of two sub-layer connection structures, such as Figure 4 shown.
[0169] The first sub-layer connection structure includes a multi-head self-attention layer and the first addition and layer normalization layer, as well as the first residual connection input to the first addition and layer normalization layer;
[0170] The second sub-layer connection structure includes a feed-forward fully connected layer and a second addition and layer normalization layer, and a second residual connection from the feed-forward fully connected layer to the second addition and layer normalization layer.
[0171] Based on the embedded feature vector, a corresponding context vector is obtained through a multi-head self-attention mechanism and a feedforward neural network, including:
[0172] Based on a randomly selected time step t, the embedding feature vector and They are divided into current slices and future slices respectively;
[0173] Randomly initialize a context vector with the same dimension as the current slice; add the context vector to the starting position of the current slice to obtain the current slice with the context vector added and ;
[0174] After the current slice with the context vector added passes through the multi-head self-attention layer, the self-attention of each head node is obtained; all head nodes are merged to obtain the feature vector and ;
[0175] based on and After the first residual connection, the first addition and the layer normalization layer, we get and ;
[0176] Will and Obtain feature vectors through the feedforward network layer and ;
[0177] Will and After the second residual connection, the second addition and the layer normalization layer, the feature vector is obtained and ;from and The starting position extraction learns itself and 、 The context vector of the attention relationship of other elements in ; obtain the embedded feature vector and The corresponding context vectors are and .
[0178] The details are as follows: First, randomly select a time step t and Divide into current slice and future slices ;Will Divide into current slice and future slices .
[0179] Randomly initialize the context vector with the same dimension as the current one , added to the starting position of the current slice, as follows:
[0180] ;
[0181] The number of head nodes in the multi-head self-attention layer is ; For example, is 3; for each head node , ( or ) Generate query matrix through linear transformation , key matrix Sum Matrix :
[0182] ;
[0183] in, , , They are , , The transformation matrix, d is the input vector ( or ) dimension.
[0184] Then use formula (11) to calculate ( or )’s self-attention ( or ):
[0185] ;
[0186] Merge the outputs of all head nodes , and linearly transform it back to the original electromagnetic signal dimension to obtain the eigenvector ( or ):
[0187] ;
[0188] in, ( or ) is the output of the multi-head attention layer, It is a linear mapping used to transform the concatenated vector of multi-head output back to the d-dimensional matrix of the original electromagnetic signal.
[0189] After the first residual connection and the first addition and layer normalization layer, we get ( or ):
[0190] ;
[0191] in, ( or ) is the intermediate feature variable of the network output after passing through the first sub-layer connection structure; For the first residual connection, the input of the multi-head self-attention layer is directly added to its output, and then the result of the first residual connection is layer normalized .
[0192] when ( or ) through the feedforward network layer (Feed-Forward Neural NetworkLayer), we get ( and ):
[0193] ;
[0194] in, 、 are the weight parameters of the feedforward network layer, 、 are constant biases respectively.
[0195] After the second residual connection and the second addition and layer normalization layer, we get ( and ):
[0196] ;
[0197] After training, From the output ( and ) and obtain the embedded feature vector and The corresponding context vectors are and .
[0198] (3) First fully connected layer
[0199] The context vector Input the first fully connected layer to predict the predicted value of the future slice corresponding to the weakly enhanced sample ; and the context vector based on the weakly enhanced sample Input the first fully connected layer to predict the predicted value of the future slice corresponding to the strongly enhanced sample ;
[0200] The predicted value and true value of the future slice of the same pre-training sample are the first positive sample pair; the predicted value of the future slice of the pre-training sample and the true value of the future slice of other pre-training samples in the same training batch are the first negative sample pair;
[0201] and through Parallel FC layers (Fully Connected Layer) predict future slices or ,The above steps are expressed as follows:
[0202] ;
[0203] When performing cross-sample prediction, the context vector of the strongly enhanced sample of the same sample is used Predict future slices of weakly enhanced samples, using the context vector of the weakly enhanced samples Predict future slices of a strongly augmented sample as follows:
[0204] ;
[0205] in, Indicates the FC layers, , 、 are the estimated weakly enhanced future slice and the real weakly enhanced future slice respectively; 、 They are the estimated strong enhanced future slices and the real weak and strong enhanced future slices respectively.
[0206] The predicted value and true value of the future slice of the same sample are regarded as positive sample pairs, and their similarity is maximized. At the same time, the predicted value of the future slice of the sample is compared with the other sample sets in the same batch. The true values of future slices in are considered as negative sample pairs and their similarity is minimized, which is achieved using formulas (19)-(20) during the pre-training process of step S22.
[0207] (4) Second fully connected layer
[0208] The second fully connected layer respectively and Projection is a strong enhancement feature and weak enhancement features ; obtained from the same pre-training sample and is the second positive sample pair; the pre-training sample obtained Compared with other pre-training samples in the same training batch is the second negative sample pair.
[0209] In this paper, a context contrast learning task is designed to capture the context information in the signal, so that the model can understand more complex and abstract relationships in the signal. and Then, through the projection layer Get its and The projection layer is a two-layer fully connected network. The context generated by different enhancement methods of the same sample is regarded as a positive sample pair. , the 2(M-1) contexts generated by the remaining M-1 samples in the same batch are regarded as negative samples.
[0210] Utilizing contextual contrastive loss The similarity between the context features of the strongly enhanced sample and the weakly enhanced sample of the same sample is maximized, while the similarity between the context features of two enhanced samples of different samples is minimized. This is achieved in the pre-training process of step S22 by formula (21).
[0211] Step S22: Pre-training a small sample spectrum sensing model using the pre-training sample set.
[0212] Pre-training a small sample spectrum sensing model based on the pre-training sample set includes:
[0213] Loading the strong enhancement samples and weak enhancement samples in the pre-training sample set into the self-supervised encoder;
[0214] Pre-training a small-sample spectrum sensing model based on a joint loss function, and continuously adjusting the model parameters through backpropagation and gradient descent optimization algorithms to maximize the similarity between the first and second positive sample pairs, and minimize the similarity between the first and second negative sample pairs;
[0215] Until the joint loss function converges or the pre-training ends at a preset maximum number of iterations, the small sample spectrum sensing model parameters are saved to obtain a pre-trained small sample spectrum sensing model;
[0216] Among them, the joint loss function ,as follows:
[0217] ;
[0218] in, Based on predict Prediction contrast loss of Based on predict Prediction contrast loss of is the context contrast loss; 、 They are respectively predicted contrast loss and contextual contrast loss The weight of . .
[0219] Exemplarily, the preset maximum number of iterations epoch is set to 200 times.
[0220] Through contrastive learning, the quality and effect of data enhancement can be further improved, so that the model can better learn more stable and robust features from the enhanced data.
[0221] based on predict Prediction contrast loss ,as follows:
[0222] ;
[0223] based on predict Prediction contrast loss ,as follows:
[0224] ;
[0225] in, is the number of the first fully connected layer, is the set of other samples in the same batch except the current sample; 、 are respectively the embedded feature vectors of other samples in the same batch except the current sample; Represents the first fully connected layer fully connected layers, ;
[0226] All are counters. The index of the current prediction step; Used to find the similarity value between the two; It is an exponential function used to map the similarity value to a positive range and convert the similarity value into a comparable positive number form to facilitate the calculation of probability; The number of slices is the same as the number of acquisition time points for future slices.
[0227] The context contrast loss , using the cosine similarity function and the temperature coefficient to maximize the similarity of the second positive sample pair and minimize the similarity of the second negative sample pair, as follows:
[0228] ;
[0229] in, is the number of samples per batch, 、 Respectively The context vectors corresponding to the strong enhancement samples and the weak enhancement samples and Features after projection by the second fully connected layer; is a weakly enhanced sample of other pre-training samples in the same training batch; is the cosine similarity function; is an exponential function; is the temperature coefficient; is the sum of the similarities of all second negative sample pairs in the same training batch.
[0230] When the training batch size is In the training batch of , since each sample has a weak enhancement and a strong enhancement, and then the current sample is removed, the denominator is .
[0231] Represents a vector and The cosine similarity of . is an indicator function if and only if When the value is 1, the temperature coefficient The smaller it is, the more obvious the similarity difference is.
[0232] The purpose of step S2 is to build and pre-train a small-sample spectrum perception model. Through the collaborative work of the self-supervised encoder, the Transformer encoder, the first and second fully connected layers, and the use of the prediction contrast loss and context contrast loss functions, the small-sample spectrum perception model learns discriminative feature representations, laying the foundation for subsequent fine-tuning training and spectrum perception steps.
[0233] Step S3, specifically.
[0234] The fine-tuning training includes:
[0235] Load the parameters of the self-supervised encoder in the pre-trained few-shot spectrum sensing model ;
[0236] The flattening layer flattens the embedded feature vector into a one-dimensional vector;
[0237] The fully connected classification layer classifies the one-dimensional vector output by the flattening layer to obtain the predicted probability of the presence or absence of the modulation signal. and ;
[0238] The cross-entropy loss function is used to measure the difference between the predicted probability and the true label until the loss function converges or the preset maximum number of fine-tuning training times is reached, and a fine-tuned small-sample spectrum perception model is obtained.
[0239] After the pre-training process of the small sample spectrum sensing model is completed, the self-supervised encoder network parameters obtained in the pre-training phase are loaded, and a small amount of labeled fine-tuning samples are used for fine-tuning training so that the self-supervised encoder model can accurately classify the presence of modulated signals ( ) and the absence of a modulation signal ( ).
[0240] During fine-tuning, load the self-supervised encoder network parameters obtained in the pre-training phase ,These parameters contain features learned from a large amount of unlabeled data. Figure 3 The structure of the self-supervised encoder is adjusted by adding a flatten layer and a fully connected classification layer (FC layer) after the third convolution block for spectrum sensing classification tasks, such as Figure 5 shown.
[0241] Flattening layer: embeds the multi-dimensional features of the output of the third convolutional block (dimension is ) is flattened into a one-dimensional column vector (dimension is 2944) to adapt to the input requirements of the fully connected layer.
[0242] Fully connected classification layer (FC layer): FC(2944,2) means that the input has 2944 neurons and the output has 2 neurons, corresponding to and ;
[0243] : Input sample belong The probability that (modulation signal exists);
[0244] : Input sample belong (no modulation signal exists).
[0245] Then use the fine-tuning sample set , To fine-tune the sample; For fine-tuning sample labels ( express , express ); To fine-tune the number of samples;
[0246] The fine-tuning training set consists of 208 samples (104 signal samples and 104 noise samples).
[0247] Use the cross entropy loss function to measure the difference between the model's predicted probability and the true label; continue to update the self-supervised encoder network parameters ,in, and The self-supervised encoder model discrimination in the fine-tuning training stage is and probability. Indicates the presence of a modulated signal. Indicates that there is no modulation signal, which is the sample label. The cross entropy loss function is as follows:
[0248] ;
[0249] ;
[0250] Fine-tune the optimization objective and use a small number of labeled samples to let the self-supervised encoder learn to label. Minimize , update the self-supervised encoder parameters .
[0251] Fine-tuning training configuration: Use Adam or SGD as the optimizer; set the learning rate to a lower value than in the pre-training phase (e.g., 0.0001). Set the maximum number of fine-tuning training times to 50 (epoch=50).
[0252] Feature reuse in the pre-training stage: The self-supervised encoder has learned the essential characteristics of the signal in the pre-training stage, and fine-tuning training only requires adjusting a small number of parameters to adapt to the classification task.
[0253] Only 208 labeled samples are needed to achieve high classification accuracy, perform efficient annotation, and significantly reduce annotation costs.
[0254] The flattening layer and the fully connected classification layer add minimal computational effort, enabling lightweight deployment and suitable for real-time inference on edge devices.
[0255] The purpose of step S3 is to achieve efficient spectrum sensing classification in small sample scenarios by fine-tuning the pre-trained small sample spectrum sensing model and combining pre-training features with supervised learning; a small number of labeled samples are used to adapt it to specific spectrum sensing classification tasks, thereby improving the classification performance of the model in small sample scenarios.
[0256] Step S4, specifically.
[0257] Inputting the pre-processed real-time acquired electromagnetic signal into the fine-tuned small sample spectrum sensing model to perform spectrum sensing, including:
[0258] Loading the fine-tuned small sample spectrum sensing model, and dynamically setting a decision threshold based on a preset false alarm probability;
[0259] The preprocessed electromagnetic signal acquired in real time is input into the fine-tuned small sample spectrum sensing model; when the predicted probability value output by the fine-tuned small sample spectrum sensing model is greater than or equal to the decision threshold, the spectrum sensing result is that a modulated signal exists, otherwise the modulated signal does not exist.
[0260] The electromagnetic signal acquired in real time after preprocessing , and input it into the fine-tuned small sample spectrum sensing model for spectrum sensing to determine whether there is a modulation signal.
[0261] Use the self-supervised encoder parameters obtained after fine-tuning training Perform spectrum sensing based on a given false alarm probability Dynamically set decision threshold The false alarm probability is the probability of misjudging a modulation signal when there is no modulation signal, that is, the probability of misjudging noise as a modulation signal.
[0262] The detection criteria are as follows:
[0263] ;
[0264] When the output probability value is greater than the set threshold , it is determined that there is a modulation signal, otherwise it is determined that there is no modulation signal.
[0265] For example, the threshold Set to 0.5 and adjust dynamically according to actual scene requirements .
[0266] The final spectrum sensing result is whether a modulation signal exists or not.
[0267] Efficient spectrum sensing, directly outputting the probability through fine-tuning the trained self-supervised coding model, quickly judging the presence of the signal; dynamically setting according to actual needs , balancing the detection probability and false alarm probability; the entire process from input signal to judgment result does not require human intervention, which is suitable for large-scale spectrum monitoring scenarios.
[0268] The function of step S4 is to use the fine-tuned small sample spectrum sensing model to perform spectrum sensing on the electromagnetic signal acquired in real time, determine whether a modulation signal exists, and output the spectrum sensing result.
[0269] In summary, the small sample spectrum sensing method based on time prediction and context contrast learning in the embodiment of the present invention has the following beneficial effects:
[0270] 1. The proposed small-sample spectrum sensing algorithm based on temporal prediction and contextual contrastive learning is based on a self-supervised contrastive learning strategy, learning similarities or differences in data through positive and negative sample pairs. Only a small amount of labeled sample data is required during the fine-tuning phase, significantly reducing the reliance on labeled data. This solves the problem of supervised learning in existing technologies requiring large amounts of labeled data.
[0271] 2. The present invention extracts enhanced representation features from electromagnetic signal data through a self-supervised encoder and utilizes cross-sample temporal predictive contrastive learning and contextual contrastive learning to make the representation features more discriminative. This means that positive sample pairs are kept as close as possible in the embedding space, while negative sample pairs are kept as far apart, thereby maintaining a high detection probability with a low false alarm probability.
[0272] 3. Existing traditional spectrum sensing methods rely on prior knowledge such as channel or noise distribution, and suffer from problems such as signal-to-noise ratio barriers. This invention does not require such prior knowledge. Instead, it achieves spectrum sensing by learning the intrinsic information of a large number of unlabeled electromagnetic signal samples, eliminating the reliance on prior knowledge.
[0273] 4. Traditional spectrum sensing algorithms have limited performance in low signal-to-noise ratio environments. This invention uses the Transformer encoder to capture the time series dependencies and dynamic changes of signals. Combined with contextual comparative learning, it enhances the model's ability to learn signal features, thereby overcoming the limitations of the signal-to-noise ratio wall and improving spectrum sensing performance in low signal-to-noise ratio environments.
[0274] 5. The existing technology faces costs and error risks when acquiring a large number of labeled samples. The present invention fully utilizes unlabeled data through data enhancement and contrastive learning, improves data utilization efficiency, and reduces data acquisition and labeling costs.
[0275] Those skilled in the art will appreciate that all or part of the process steps of the above-described embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, such as a magnetic disk, an optical disk, a read-only memory, or a random access memory.
[0276] The above description is only a preferred specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with this technical field within the technical scope disclosed by the present invention should be covered by the scope of protection of the present invention.
Claims
1. A small sample spectrum sensing method based on time prediction and context contrastive learning, characterized in that: include: Preprocessing the acquired original electromagnetic signal including the modulation signal to obtain a pre-training sample set without labels and a fine-tuning sample set with labels; wherein the labels include the presence of the modulation signal and the absence of the modulation signal; Using the pre-trained sample set to pre-train the small sample spectrum sensing model for time prediction and context comparison, thereby obtaining a pre-trained small sample spectrum sensing model; wherein the small sample spectrum sensing model includes a self-supervised encoder, a Transformer encoder, a first fully connected layer, and a second fully connected layer; The self-supervised encoder is used to obtain embedded feature vectors corresponding to the strongly enhanced samples and the weakly enhanced samples; The Transformer encoder is used to obtain the context vector of the corresponding weakly enhanced sample based on the embedded feature vector through a multi-head self-attention mechanism and a feedforward neural network and the context vector of the strongly enhanced sample ; The first fully connected layer is used to Predict the predicted value of the future slice corresponding to the weakly enhanced sample; based on Predicting the predicted value of the future slice of the corresponding strongly enhanced sample, the true value and predicted value of the future slice of the same weakly enhanced sample or strongly enhanced sample are the first positive sample pair, and the predicted value of the weakly enhanced sample or strongly enhanced sample and the true value of the future slice of other samples in the same training batch are the first negative sample pair; The second fully connected layer is used based on and Projection is a strong enhancement feature and weak enhancement features ; obtained from the same pre-training sample and is the second positive sample pair, the pre-training sample obtained Compared with other pre-training samples in the same training batch is the second negative sample pair and the second negative sample pair; Adding a flattening layer and a fully connected classification layer after the pre-trained self-supervised encoder to obtain a fine-tuned encoder; fine-tuning the fine-tuned encoder using the fine-tuning sample set to obtain a fine-tuned small sample spectrum perception model; Preprocessing the electromagnetic signal to be sensed and inputting it into the fine-tuned small sample spectrum sensing model to perform spectrum sensing to obtain a spectrum sensing result; The original electromagnetic signal including the modulated signal is preprocessed to obtain a pre-training sample set without labeled labels and a fine-tuning sample set with labeled labels, including: Normalizing the electromagnetic signal including the modulation signal to obtain a normalized electromagnetic signal; Obtaining signal samples corresponding to the normalized electromagnetic signal, and generating noise samples having the same number as the signal samples; Dividing the signal samples and corresponding noise samples into pre-training samples and fine-tuning samples; The pre-training samples are subjected to strong enhancement and weak enhancement processing respectively to obtain strong enhancement samples and weak enhancement samples; wherein, The strongly enhanced samples and the weakly enhanced samples constitute a pre-training sample set; the fine-tuning samples and labels constitute a fine-tuning training set; Adding Gaussian noise that obeys normal distribution to the pre-training sample to obtain a weakly enhanced sample; The pre-training samples are divided into The random number of segments is randomly disrupted, and the temporal relationship of each segment is randomly disrupted and Gaussian noise obeying the normal distribution is added to obtain strongly enhanced samples.
2. The small sample spectrum sensing method based on time prediction and context contrastive learning according to claim 1 is characterized in that When training a small-sample spectrum sensing model, the prediction contrast loss is used to maximize the similarity of the first positive sample pair and minimize the similarity of the first negative sample pair; and the context contrast loss is used to maximize the similarity of the second positive sample pair and minimize the similarity of the second negative sample pair.
3. The small sample spectrum sensing method based on time prediction and context contrast learning according to claim 2 is characterized in that The self-supervisory encoder includes first, second, and third convolution blocks connected in series; obtaining the embedded feature vectors corresponding to the strongly enhanced samples and the weakly enhanced samples, including: Strongly enhance the sample and weakly enhanced samples Input the self-supervised encoder, and After passing through the first, second and third convolution blocks in sequence, they are mapped to the embedding space respectively to obtain the corresponding embedded feature vectors and .
4. The small sample spectrum sensing method based on time prediction and context contrastive learning according to claim 3 is characterized in that Based on the embedded feature vector, a corresponding context vector is obtained through a multi-head self-attention mechanism and a feedforward neural network, including: Based on a randomly selected time step t, the embedding feature vector and They are divided into current slices and future slices respectively; Randomly initialize a context vector with the same dimension as the current slice; add the context vector to the starting position of the current slice to obtain the current slice with the context vector added and ; After the current slice with the context vector added passes through the multi-head self-attention layer, the self-attention of each head node is obtained; all head nodes are merged to obtain the feature vector and ; based on and After the first residual connection, the first addition and the layer normalization layer, we get and ; Will and Obtain feature vectors through the feedforward network layer and ; Will and After the second residual connection, the second addition and the layer normalization layer, the feature vector is obtained and ;from and The starting position extraction learns itself and 、 The context vector of the attention relationship of other elements in ; obtain the embedded feature vector and The corresponding context vectors are and .
5. The small sample spectrum sensing method based on time prediction and context contrastive learning according to claim 4 is characterized in that The context vector Input the first fully connected layer to predict the predicted value of the future slice corresponding to the weakly enhanced sample ; And the context vector based on the weakly enhanced sample Input the first fully connected layer to predict the predicted value of the future slice corresponding to the strongly enhanced sample ; The predicted value and true value of future slices of the same pre-training sample are the first positive sample pair; The predicted value of the future slice of the pre-training sample and the true value of the future slice of other pre-training samples in the same training batch are the first negative sample pair; The second fully connected layer respectively and Projection is a strong enhancement feature and weak enhancement features ; obtained from the same pre-training sample and is the second positive sample pair; the pre-training sample obtained Compared with other pre-training samples in the same training batch is the second negative sample pair.
6. The small sample spectrum sensing method based on time prediction and context contrastive learning according to claim 1, characterized in that Pre-training a small sample spectrum sensing model based on the pre-training sample set includes: Loading the strong enhancement samples and weak enhancement samples in the pre-training sample set into the self-supervised encoder; Pre-training a small-sample spectrum sensing model based on a joint loss function, and continuously adjusting the model parameters through backpropagation and gradient descent optimization algorithms to maximize the similarity between the first and second positive sample pairs, and minimize the similarity between the first and second negative sample pairs; Until the joint loss function converges or the pre-training ends at a preset maximum number of iterations, the small sample spectrum sensing model parameters are saved to obtain a pre-trained small sample spectrum sensing model; Among them, the joint loss function ,as follows: ; in, Based on predict Prediction contrast loss of Based on predict Prediction contrast loss of is the context contrast loss; 、 They are respectively predicted contrast loss and contextual contrast loss The weight of .
7. The small sample spectrum sensing method based on time prediction and context contrastive learning according to claim 6, characterized in that: based on predict Prediction contrast loss ,as follows: ; based on predict Prediction contrast loss ,as follows: ; in, is the number of the first fully connected layer, is the set of other samples in the same batch except the current sample; 、 are respectively the embedded feature vectors of other samples in the same batch except the current sample; Represents the first fully connected layer fully connected layers, ; The context contrast loss , using the cosine similarity function and the temperature coefficient to maximize the similarity of the second positive sample pair and minimize the similarity of the second negative sample pair, as follows: ; in, is the number of samples per batch, 、 Respectively The context vectors corresponding to the strong enhancement samples and the weak enhancement samples and Features after projection by the second fully connected layer; is a weakly enhanced sample of other pre-training samples in the same training batch; is the cosine similarity function; is an exponential function; is the temperature coefficient; is the sum of the similarities of all second negative sample pairs in the same training batch.
8. The small sample spectrum sensing method based on time prediction and context contrastive learning according to claim 1, characterized in that: The fine-tuning training includes: Load the parameters of the self-supervised encoder in the pre-trained few-shot spectrum sensing model ; The flattening layer flattens the embedded feature vector into a one-dimensional vector; The fully connected classification layer classifies the one-dimensional vector output by the flattening layer to obtain the predicted probability of the presence or absence of the modulation signal. and ; The cross-entropy loss function is used to measure the difference between the predicted probability and the true label until the loss function converges or the preset maximum number of fine-tuning training times is reached, and a fine-tuned small-sample spectrum perception model is obtained.
9. The small sample spectrum sensing method based on time prediction and context contrast learning according to any one of claims 1 to 8, characterized in that: Inputting the pre-processed real-time acquired electromagnetic signal into the fine-tuned small sample spectrum sensing model to perform spectrum sensing, including: Loading the fine-tuned small sample spectrum sensing model, and dynamically setting a decision threshold based on a preset false alarm probability; The preprocessed electromagnetic signal acquired in real time is input into the fine-tuned small sample spectrum perception model; when the predicted probability value output by the fine-tuned small sample spectrum perception model is greater than or equal to the decision threshold, the perception result of the spectrum is that a modulated signal exists, otherwise the modulated signal does not exist.
Citation Information
Patent Citations
Radar signal feature representation method based on self-supervised contrast learning
CN119416150A