## 4 Convolutional Neural Network-Based Cooperative Spectrum Sensing
### Convolutional Neural Network-Based Cooperative Spectrum Sensing
#### 4.2.1 Network Configuration  
The first step in designing a CNN is to define the network layers that specify the structure of the CNN, as depicted in Figure 4. This network consists of the following layers [35].  
* The _input_ layer stores the input sensing data in the form of a gray scale image with size \(1\times K\times 1\), where \(K\) is the number of secondary users.
* The _convolutional_ (_CONV2D_) layer contains \(K\)_neurons_ (filters) that connect to the local subregions of the input image to learn its features by scanning through it. In this work, each region has a size of \(1\times 2\).
* The _rectified linear unit_ (_ReLU_) layer uses the ReLU function to introduce nonlinearity to the CNN by performing a threshold operation on each input element, simply defined as \[f(x)=\begin{cases}x,&x\geq 0,\\ 0,&x<0.\end{cases}\] (9)
* The _fully connected_ layer combines all the local information from the original image (e.g., the results of feature extraction) determined in the previous layers to classify the status of the PU, which is active \((A)\) or inactive \((\bar{A})\). Consequently, the size of the output data is equal to the number of states of the primary user.
* The _softmax_ and _output_ layers follow right after the fully connected layer for the classification problem. The softmax layer uses an output unit activation function, also known as a _normalized exponential_ function, to create a categorical probability distribution for the two input elements (\(A\) and \(\bar{A}\)), as follows: \[P(H_{i})=\frac{\exp(q(H_{i}))}{\sum\limits_{H_{j}\in\left\{A,\bar{A}\right\}} \exp(q(H_{j}))},\ i=1,2,\] (10) where \(P(H_{i})\) is the class prior probability; \(H_{i}\in\left\{A,\bar{A}\right\}\) is an element class; and \(q(H_{i})\) is the output value from previous layer of the sample given class \(H_{i}\). Thereafter, the output (or _classification_) layer takes the values from the softmax function and assigns each input to one of the two classes.  
It should be noted that the original image with size \(1\times K\times 1\) is a vector containing the local decisions from \(K\) SUs; thus, a one-dimensional (1D) convolution layer can be used in the CNN to solve the problem of PU state classification instead of using a two-dimensional (2D) convolution layer. However, using a 2D CNN is more useful than 1D CNN in image classification. Furthermore, it would be easier to further develop the current approach to deal with three-dimensional data without making many changes in the current architecture of the CNN. For this reason, the size of the input image is generalized as \(1\times K\times 1\); thus, if the number of secondary users cooperating in spectrum sensing is large enough, the image size could be changed to \(M\times N\times 1\), where \(M\times N=1\times K\). Moreover, we can enhance the sensing accuracy by placing other information (e.g., the channel SNRs, the distances between the SUs and the PU) in the second and the third layers of the image, and performing some modifications (e.g., permutation, repetition) to the original data structure to provide the CNN with more features.  
Figure 4: The structure of the convolutional neural network (CNN) for spectrum sensing in this paper.