MATLAB Answers

1D Regression with CNN

84 views (last 30 days)
João M. Lopes
João M. Lopes on 17 Mar 2020
Commented: Hiro Yoshino on 1 Jun 2020 at 0:17
How should I treat my input matrix and target matrix for 1D regression problem with CNN?
Suppose I have EMG signals with 760000 points (samples) and I've collected data from 8 muscles (features). So, I have a matrix 760000-by-8. My target is a matrix 760000-by-1. Imagine that I have 1 trial for each 5 persons. So, I'll have for each person a 760000-by-8 matrix.
In the documentation, it says that CNN treats the input data as an image, so it expects an input like h-by-w-by-c-by-N.
In this case, should I consider my features as the number of channels or the width of my input "image"? And N should be 5?
I.e., should I rearrage my training data as 760000-by-1-by-8-by-5 or 760000-by-8-by-1-by-5? Reading the documentation e some questions about this issue, I do not fully understand how should I give my data to the trainNetwork function.
Another question is about the fully connected layer after the CNN feature extractor layers. After I have my feature maps, as this is a regression problem and my target is a 760000-by-1 signal, the output size of my fully connected layer should be 760000?
I'm always having a size issue, saying that it is required a very long array and matlab would become unresponsive.
Thanks in advance


Sign in to comment.

Accepted Answer

Hiro Yoshino
Hiro Yoshino on 17 Mar 2020
I skimmed through the issue - sorry if I am answering in a different direction.
You should convert the 1D data into image format as follows:
X_train = reshape(X_train', [1, 1, size(X_train,2), size(X_train,1)]);
X_train: 100 x 4 matrix meaning 100 samples x 4 features
Then you should use imageInputLayer as follows:
nFeatures = 4;
nHiddenUnits1 = 3;
nHiddenUnits2 = 3; % num of classes
nClasses = 3;
layers = [
imageInputLayer([1 1, nFeatures],"Name","imageinput") % この指定の仕方も最重要ポイント 2
Hope this helps you out.


João M. Lopes
João M. Lopes on 23 Mar 2020
Thanks for your answer, Hiro.
I realized what I was doing wrong.
aybike pirol
aybike pirol on 31 May 2020 at 10:16
similar problem.
my EMG data 2x174800 (so 2 input or channels) and target 1x174800. I will predict, not classification
The output size of my fully connected layer should be 174800?how will this be?
Hiro Yoshino
Hiro Yoshino on 1 Jun 2020 at 0:17
You may want to set the output number of the fullyconnectedlayer before the regression layer, which should be deployed at the end of the network, as 174800.

Sign in to comment.

More Answers (0)

Sign in to answer this question.