# Is it a good idea to use CNN to classify 1D signal?

I am working on the sleep stage classification. I read some research articles about this topic many of them used SVM or ensemble method. Is it a good idea to use convolutional neural network to classify one-dimensional EEG signal?
I am new to this kind of work. Pardon me if I ask anything wrong?

• A 1D signal can be transformed into a 2D signal by breaking up the signal into frames and taking the FFT of each frame. For audio this is quite uncommon. Commented Apr 18, 2019 at 11:21

I guess that by 1D signal you mean time-series data, where you assume temporal dependence between the values. In such cases convolutional neural networks (CNN) are one of the possible approaches. The most popular neural network approach to such data is to use recurrent neural networks (RNN), but you can alternatively use CNNs, or hybrid approach (quasi-recurrent neural networks, QRNN) as discussed by Bradbury et al (2016), and also illustrated on their figure below. There also other approaches, like using attention alone, as in Transformer network described by Vaswani et al (‎2017), where the information about time is passed via Fourier series features.

With RNN, you would use a cell that takes as input previous hidden state and current input value, to return output and another hidden state, so the information flows via the hidden states. With CNN, you would use sliding window of some width, that would look of certain (learned) patterns in the data, and stack such windows on top of each other, so that higher-level windows would look for patterns within the lower-level patterns. Using such sliding windows may be helpful for finding things such as repeating patterns within the data (e.g. seasonal patterns). QRNN layers mix both approaches. In fact, one of the advantages of CNN and QRNN architectures is that they are faster then RNN.

You can certainly use a CNN to classify a 1D signal. Since you are interested in sleep stage classification see this paper. Its a deep neural network called the DeepSleepNet, and uses a combination of 1D convolutional and LSTM layers to classify EEG signals into sleep stages.

Here is the architecture:

There are two parts to the network:

• Representational learning layers: This consists of two convolutional networks in parallel. The main difference between the two networks is the kernel size and max-pooling window size. The left one uses kernel size = $$F_s/2$$ (where $$F_s$$ is the sampling rate of the signal) whereas the one the right uses kernel size = $$F_s \times 4$$. The intuition behind this is that one network tries to learn "fine" (or high frequency) features, and the other tries to learn "coarse" (or low frequency) features.
• Sequential learning layers: The embeddings (or learnt features) from the convolutional layers are concatenated and fed into the LSTM layers to learn temporal dependencies between the embeddings.

At the end there is a 5-way softmax layer to classify the time series into one-of-five classes corresponding to sleep stages.

FWIW, I'll recommend checking out the Temporal Convolutional Network from this paper (I am not the author). They have a neat idea for using CNN for time-series data, is sensitive to time order and can model arbitrarily long sequences (but doesn't have a memory).

I want to emphasis the use of a stacked hybrid approach (CNN + RNN) for processing long sequences:

• As you may know, 1D CNNs are not sensitive to the order of timesteps (not further than a local scale); of course, by stacking lots of convolution and pooling layers on top of each other, the final layers are able to observe longer sub-sequences of the original input. However, that might not be an effective approach to model long-term dependencies. Although, CNNs are very fast compared to RNNs.

• On the other hand, RNNs are sensitive to the order of timesteps and therefore can model the temporal dependencies very well. However, they are known to be weak at modeling very long-term dependencies, where a timestep may have a temporal dependency with the timesteps very far back in the input. Further, they are very slow when the number of timesteps is high.

So, an effective approach might be to combine CNNs and RNNs in this way: first we use convolution and pooling layers to reduce the dimensionality of the input. This would give us a rather compressed representation of the original input with higher-level features. Then we can feed this shorter 1D sequence to the RNNs for further processing. So we are taking advantage of the speed of the CNNs as well as the representational capabilities of RNNs at the same time. Although, like any other method, you should experiment with this on your specific use case and dataset to find out whether it's effective or not.

Here is a rough illustration of this method:

--------------------------
-                        -
-   long 1D sequence     -
-                        -
--------------------------
|
|
v
==========================
=                        =
=  Conv + Pooling layers =
=                        =
==========================
|
|
v
---------------------------
-                         -
- Shorter representations -
-     (higher-level       -
-      CNN features)      -
-                         -
---------------------------
|
|
v
===========================
=                         =
=  (stack of) RNN layers  =
=                         =
===========================
|
|
v
===============================
=                             =
= classifier, regressor, etc. =
=                             =
===============================