# Electromyogram in Cigarette Smoking Activity Recognition
## 3 Data Processing and Classifier  
Encouraged by the excellent performance of Convolutional neural networks (CNN) techniques in various areas [40; 41; 42], several deep learning techniques have been utilized for gesture recognition via sEMG [43; 44; 45]. In this study, we formulated the cigarette smoking recognition as an image classification problem using a CNN and Long Short-Term Memory (LSTM) framework. To construct an image with a size of H \(\times\) W \(\times\) D (height \(\times\) width \(\times\) depth), several techniques can be used. In [46; 47; 48], the authors used the recorded high-density EMG channel signals as an image, with the dimension of the image at the same height and width as the EMG channel array. In [43; 44], a sliding time window was used to segment sEMG signals. In that study, the dimension of the image matches the sensor channel number and the length of the window. Another successful approach uses the Short-Time Fourier Transform (STFT) of segmented signals, with the size of the image being equal to frequency \(\times\) time \(\times\) channels [49; 50].  
In this study, the spectrogram approach was utilized, as informed by [27]. The signal stream was segmented by sliding windows with a length of 10 s and a sliding length of 5 s. we have computed the spectrogram of each segment of the EMG channels by using a 512-point FFT with a Hamming type of window that length of 256 with 95% overlap. Therefore, each segment converted to a matrix (image) of \(256\times 112\times\)N (frequency \(\times\) time bins \(\times\) channels). By using this approach, the \(\sim\)25 h time series of EMG signal was converted to more than 18,000 images. The proposed classifier model was composed of two essential neural network groups. The CNN group was responsible for the extraction of features. The duty of the second group was the classify each segmented window as a cigarette smoking activity or not by using an LSTM network. Figure 3 illustrates the simplified structure of the proposed model.  
The first stage of the model composed of three two-dimensional convolutional layers, followed by a fully connected layer that has 32 outputs. After each convolutional layer, a batch normalization, a linear rectifier layer, and a max-pooling layer, which find the maximum feature map over two neighborhoods, were used. After the fully connected layer, a dropout layer was utilized with a 0.5 dropout rate for reducing the overfitting risk during the training process. The feature map size of each convolution layer was chosen as 128, 64, and 32 with the motivation of the study [51]. For all convolution layers, the dimension of the filters was assigned as the 0.5 of their input image dimension. To reduce the size of the feature map to 32, we utilized a fully connected layer. In the second group of the proposed model, two sequential LSTM layers (by the motivation of the results in [52]) with the cell size of 64 and one output layer were used to classify the temporal dynamics of the extracted 32 features. The proposed model was trained by using Adam [53] optimizer with a mini-batch size of 64, five iterations, and a learning rate of \(10^{-2}\).