0
votes

I am doing a classification problem with ECG data. I built a LSTM model but the accuracy of the model is not quiet good. Hence, I am thinking to implement it with CNN. I am planning to pass the data from CNN, then passing the output from CNN to LSTM. Howver, I have noticed that CNN is mostly used in Image classifications. I have sequential data with 4000 time steps. Could you please help me to define the parameters of the CNN model.

Conv2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode='zeros', device=None, dtype=None)

Can someone explain me what would be the in_channels, out_channels, kernel_size and stride for a sequence data having 4000 time steps?

1

1 Answers

0
votes

Well, that's yours to define, it's the actual architectural decision your need to take to construct your model. The following is not a solution to your question, however, this might give you some ideas.

  • You could pass each timestep through the CNN and retrieve a sequence of feature vectors corresponding to the CNN's outputs at consecutive time steps. Your CNN input would be shaped as (batch_size, channel, height, width) and output something like (batch_size, feature_length). Stacking the timesteps results would give you (batch_size, sequence_length, feature_length).

  • You could use a 3D convolutional layer, in that case, you can work straight away with shape (batch_size, sequence_length, channel, height, width). This is much more computation-intensive, since you are already planning on using an LSTM, it might be a little over-complex.

The number of channels, kernel sizes, number of filters in each convolutional layer isn't really an obvious question. You need to decide on that based on your setup: how large is your dataset, how many classes you have, how complex is the task (if not a classification problem).

My best advice is you start by using a well-known CNN architecture such as VGG or ResNet and work from there. Better yet, look at the literature and see if some else has ever faced that problem, you will most likely find interesting ideas that will help shape your project.