# EEG Signals Based Internet Addiction Diagnosis Using Convolutional Neural Networks
## 2 Materials and Methods
### Proposed CNN Architecture  
The total CNN framework consists of input and output layers as well as multiple hidden layers. The hidden layers are convolutional layers, pooling layers, and fully connected layers. The input signal is convoluted by a trainable filter and an output map is formed through the output function \(f\). The convolution operation is shown in Figure 2 and Equation (1). \[y_{k}=\sum_{n=0}^{N-1}x_{n}h_{k-n} \tag{1}\]  
where \(y\) is the output vector in which \(n\) means _n_th element, \(x\) is the input signal from the previous layer, \(h\) is the filter, and \(N\) means the number of elements in \(x\). The _k_th feature map at a given layer is obtained as Equation (2):  
\[h_{n}^{k}=f(a)=f(\left(W^{k}\times x\right)_{n}+b_{k}) \tag{2}\]  
where \(W^{k}\) is the weight matrix for filter \(k\), and \(b_{k}\) is the bias value. During the training of the CNN model, the loss function is determined by the output and propagated back to change the interconnection of the network, which is updated based on the reduction of the loss function \(H(p,q)\), which is defined in Equation (3). \[H(p,q)=-\sum_{m}\left(p(n)\log q(n)\right) \tag{3}\]  
where \(p(n)\) is the label value marked in advance, and \(q(n)\) is the predicted value obtained by the model operation. The pooling operations translate the output of the neuron clusters into one single neuron of the next layer, which can reduce the feature map resolution. For each feature map \(a_{i,j}^{n}\), the output of the pooling layer is determined by Equation (4). \[y_{i,j}^{n+1}=pool(a_{i,j}^{n+1}),\forall(m,n)R_{i,j} \tag{4}\]  
where \(R_{i,j}\) is the local neighbor around the location \((i,j)\). In this model, the max-pooling layer is used and \(y_{i,j}^{n+1}\) is the max number in \(R_{i,j}\). The features obtained from the convolutional layer are applied as input to the fully connected layer, which is converted into a one-dimensional feature vector and used for classification. This step of converting the features into a one-dimensional (1D) vector is called flattening which is described in Equations (5) and (6). \[y_{i}^{(n)}=f(z_{i}^{(n)}) \tag{5}\]  
\[z_{i}^{(n)}=\sum_{i=1}^{m^{(n-1)}}w_{i,j}^{(n)}y_{i}^{(n-1)} \tag{6}\]  
where \(f\) is the nonlinear transfer function, and \(w_{i,j}^{(n)}\) represents the weight coefficients between the neurons of the fully connected layer. In the fully connected layer, all neurons in the previous layer are connected to the neurons in the current layer, the output of the fully connected network is the clustering result, and then the SoftMax function (Equation (7)) is used for classification in the fully connected network. \[\sigma(\mathbf{z})_{i}=\frac{e^{z_{i}}}{\sum_{j=1}^{n}e^{z_{j}}} \tag{7}\]  
where \(\mathbf{z}\) is a vector composed of all elements in the fully connected layer. The proposed CNN model consists of 5 convolutional layers, 5 max-pooling layers, a fully connected layer, and a SoftMax classifier, the model structure is shown in Figure 3.  
Conv and MP stand for the convolutional layer and max-pooling layer, respectively. The sizes of the first three convolution kernels are (1, 5), and the last two are (3, 5). The stride of all these five convolution kernels is (1, 3). After each layer of the convolution kernel, there are the Rectified Liner Units (ReLU) activation function and the max-pooling layer, and the ReLU function is defined by Equation (8). \[f(a)=\text{ReLU}(a)=max\left(0,\ a\right) \tag{8}\]  
Figure 2: Basic concepts of CNN. where \(a\) is defined in Equation (2). Compared with other excitation functions of saturated nonlinear functions (e.g., Sigmoid and Tanh), unsaturated nonlinear functions like ReLU can solve the problems of gradient explosion and gradient disappearance, and accelerate the convergence speed, the function curves are illustrated in \[h_{n}^{k}=f(a)=f(\left(W^{k}\times x\right)_{n}+b_{k}) \tag{2}\]0 The sizes of the five max-pooling layers are all \(2\times 2\), and the stride of these max-pooling layers is 2.