My data and responses have the same sequence length although the error says otherwise.

My data is a 360x1 cell filled with 3x769 arrays
and my response data is a cell array of categorical sequences that are 1x769
I am able to make this data go through the sample sequence-sequence network that Matlab has in the deep network designer
Although using my network it provides this error
Error using trainNetwork (line 184)
Invalid training data. Sequence responses must have the same sequence length as the corresponding predictors.

5 commentaires

Hi,
It would be nice, if you can share code or your network for reproduction of issue at our end.
Hi Anshika,
Here is our code for our CNN
lgraph = layerGraph();
tempLayers = [
sequenceInputLayer([3 769 1],"Name","sequence")
sequenceFoldingLayer("Name","seqfold")];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
convolution2dLayer([1 65],10,"Name","conv_9","Padding","same","Stride",[1 3])
eluLayer(1,"Name","elu_9")
convolution2dLayer([3 1],10,"Name","conv_10","Padding","same","Stride",[4 1])
eluLayer(1,"Name","elu_10")
maxPooling2dLayer([1 6],"Name","maxpool_7","Padding","same","Stride",[1 6])
flattenLayer("Name","flatten_7")];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
convolution2dLayer([1 45],10,"Name","conv_5","Padding","same","Stride",[1 3])
eluLayer(1,"Name","elu_5")
convolution2dLayer([3 1],10,"Name","conv_8","Padding","same","Stride",[4 1])
eluLayer(1,"Name","elu_8")
maxPooling2dLayer([1 6],"Name","maxpool_6","Padding","same","Stride",[1 6])
flattenLayer("Name","flatten_6")];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
convolution2dLayer([1 85],10,"Name","conv_1","Padding","same","Stride",[1 3])
eluLayer(1,"Name","elu_1")
convolution2dLayer([3 1],10,"Name","conv_4","Padding","same","Stride",[4 1])
eluLayer(1,"Name","elu_4")
maxPooling2dLayer([1 6],"Name","maxpool_3","Padding","same","Stride",[1 6])
flattenLayer("Name","flatten_3")];
lgraph = addLayers(lgraph,tempLayers);
tempLayers = concatenationLayer(1,3,"Name","concat");
lgraph = addLayers(lgraph,tempLayers);
tempLayers = [
sequenceUnfoldingLayer("Name","sequnfold")
dropoutLayer(0.5,"Name","dropout")
fullyConnectedLayer(5,"Name","fc")
softmaxLayer("Name","softmax")
classificationLayer("Name","classoutput")];
lgraph = addLayers(lgraph,tempLayers);
% clean up helper variable
clear tempLayers;
lgraph = connectLayers(lgraph,"seqfold/out","conv_9");
lgraph = connectLayers(lgraph,"seqfold/out","conv_5");
lgraph = connectLayers(lgraph,"seqfold/out","conv_1");
lgraph = connectLayers(lgraph,"seqfold/miniBatchSize","sequnfold/miniBatchSize");
lgraph = connectLayers(lgraph,"flatten_7","concat/in2");
lgraph = connectLayers(lgraph,"flatten_6","concat/in1");
lgraph = connectLayers(lgraph,"flatten_3","concat/in3");
lgraph = connectLayers(lgraph,"concat","sequnfold/in");
options = trainingOptions('sgdm',...
'L2Regularization',0.01,...
'InitialLearnRate',0.1,...
'Momentum',0.9,...
'MaxEpochs',400);
net = trainNetwork(P01D,P01C,lgraph,options);
Here is a visual of our network
Would you also like a copy of our dataset?
When you write "sequenceInputLayer([3 769 1],"Name","sequence")", this means that at every time step of the sequence, you have an image of dimension 3x769x1. However, if I understand correctly, your data is a sequence of 769 time steps with 3 features for each time step. You're trying to process an image at every time step when in fact you only have a vector with 3 values.
Hi Sahil,
I'm still confused on how to fix this error since the error it gives out is about the sequence length of the response array when it has the same length as the predictor array. When testing it out on other networks like the sample sequence to sequence LSTM Matlab has in the DeepNetworkDesigner toolbox, my data works and the training procedure starts. How would I be able to run my data through my CNN?
From my understanding, the issue is that for every 3x769 input, your network should output a 5x769 array. However, your network's output is a vector of length 5. This is because you are passing the entire 3x769 sequence as one image. The reason your data works with the sample sequence-to-sequence LSTM is because in that network, you are passing only a vector of length 3 to the network for every time step and therefore, it is able to generate an output vector of length 5 for all 769 time steps. Have a look at the difference between the parameters of the "sequenceInputLayer" in the sample network and your network.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Deep Learning Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by