# Why CNN is suitable for time-series data?

I am confused by the statements that I came across in two different papers.

The statement from the paper titled as "Detecting Cyber Attacks in Industrial Control Systems Using Convolutional Neural Networks":

While CNNs used in image processing are two-dimensional (2D), 1D CNNs exist, and they can be successfully used for time series processing, because time series have a strong 1D (time) locality which can be extracted by convolutions.

The statement from the paper titled as "Unsupervised Anomaly Detection of Industrial Robots Using Sliding-Window Convolutional Variational Autoencoder":

Although CNN is mostly applied for analyzing images, it is also successfully explored in multivariate time series data. Since multivariate time series have the same 2-dimensional data structures as image, CNN for analyzing images is suitable for handling multivariate time series as well.

I am confused about how the structure of univariate and multivariate time-series data differ, how we can relate them to CNNs.

*Edit: This question centers on time-series. The supposed "duplicate" is about classification; this is not a duplicate and merits an adequate answer.

• I did not know, why someone closed this question. The linked question is not related to 2D - CNN, or multivariate data, and does not clarify my question. Luckily, somebody provided a clear answer beforehand. Nov 3, 2021 at 15:11

The advantage of a convolution is that it takes into account the "spatial" structure of the data. I put "spatial" in scare quotes because although that's the term that is normally used, really we are talking about any continuous coordinate. A time coordinate works just as well as a spatial coordinate, and if you had some more exotic coordinates, they would work too.

What do we mean by "taking into account the coordinate structure"? Consider the time series of measurements: x1, x2, x3, ... xn. We could put them into a fully-connected network, but that is throwing away a lot of information, such as the fact that (x1,x2) and (x2,x3) are both adjacent pairs, and so a difference in x1 and x2 should have a similar interpretation to an equivalent difference in x2 and x3; whereas, a similar difference between x3 and x7 might have a completely different interpretation.

The idea extends naturally into 2D to get the widely-used image convolutions. In these, the convolutional kernel captures not just the distance between the measurements, but also the direction, which is what allows you to have, for example, kernels that capture edges in different orientations. And you can extend it into arbitrarily higher dimensions, though higher dimension datasets are relatively less common than images.

The point is, although convolutional layers are commonly used on images, there is nothing special about 2D data, and convolutional layers can be a very powerful technique for 1D data like time series.

There is one thing, however, in the material you quoted that is simply wrong:

Since multivariate time series have the same 2-dimensional data structures as image, CNN for analyzing images is suitable for handling multivariate time series as well.

This is a mistake commonly made by people who were introduced to convolutions as 2D operations and think that there is something inherently 2D about convolutions. Multivariate 1D data is not analogous to 2D univariate data. This is because the channels for the different variables to not have an inherent ordering like the samples along the time dimension do. Instead, the additional time series variables should be treated similarly to how you treat additional channels in image data, namely, with a stack of 1D kernels, rather than with a 2D kernel.

• +1 for the last paragraph, and identifying the mistake. Nov 3, 2021 at 14:20
• Thanks for the clarification, it is all clear now. I did not suspect the statement might be wrong, which got me really confused. Nov 3, 2021 at 15:09