I would like to use a CNN in order to classify signal data consisting of min. 500 data points into 3 categories. What kind of architecture and design considerations do I need to take into account and how would an architecture look like. Also, what approach could be used to deal with differently sized input?
-
$\begingroup$ Why not try the standard recipe of modules: Filters (say, 1x3, 1x5 in size) , Batch Norm, Pooling? For variable input size, consider looking into Ragged Tensors if using Tensorflow (or fixing a large input size, with zeros in place of no input). $\endgroup$– Alex R.Commented Feb 3, 2021 at 23:36
-
$\begingroup$ I am implementing in Matlab. For a sequence input Matlab requires a folding layer. I am not really familiar with the purpose and functionality of that layer $\endgroup$– user19440Commented Feb 4, 2021 at 20:35
-
1$\begingroup$ It sounds like your issue is related to Matlab then, which is out of scope for this forum. Surely there are online resources that can guide you on how to do this in Matlab? $\endgroup$– Alex R.Commented Feb 4, 2021 at 21:15
1 Answer
It reads as if you want to produce a single classification for each variable-length sequence. This is similar to classifying images of variable size, just in 1D instead of 2D. You can feed the signal through a 1D convolutional deep neural network that will use adaptive pooling (PyTorch/TensorFlow docs) to compress time to a fixed-length representation just before the fully-connected layers/readout layer. This is how Torchvision's CNN implementations deal with variable size image inputs.
An alternative, somewhat more complicated approach is to feed your signal piece by piece to a recurrent neural network (e.g., an LSTM). If you read the output only at the last timepoint, you will get a single classification per sequence, regardless of the sequence's length (a Matlab example).
-
$\begingroup$ That is very helpful, thanks. The first solution looks more like what i had mine. As I would like to use a CNN in matlab i encountered the problem of feeding the sequence input into the convolution. This doesn't seem to be possible without a sequence folding layer. What exactly is the function of such a "sequence folding layer"? $\endgroup$ Commented Feb 7, 2021 at 12:54