Encountered an error while implementing deep learning regression model in MATLAB.
1 view (last 30 days)
Show older comments
Following is the code and the error generated while implementing regression model in MATLAB. input vector(traindata(:,1)) is of size 300 and output vector(traindata(:,2)) size is also 300, still I am getting error of size not same. traindata is a cell of size 769x2 each element of length 1x300 double. what am I doing wrong?
load('traindata.mat')
load('testdata.mat')
layers1 = [
sequenceInputLayer(1,MinLength = 300)
convolution1dLayer(4,3,Padding="same",Stride=1)
convolution1dLayer(64,8,Padding="same",Stride=8)
batchNormalizationLayer()
tanhLayer
maxPooling1dLayer(2,Padding="same")
convolution1dLayer(32,8,Padding="same",Stride=4)
batchNormalizationLayer
tanhLayer
maxPooling1dLayer(2,Padding="same")
transposedConv1dLayer(32,8,Cropping="same",Stride=4)
tanhLayer
transposedConv1dLayer(64,8,Cropping="same",Stride=8)
tanhLayer
bilstmLayer(8)
fullyConnectedLayer(8)
dropoutLayer(0.2)
fullyConnectedLayer(4)
dropoutLayer(0.2)
fullyConnectedLayer(1)
regressionLayer];
options = trainingOptions("adam",...
MaxEpochs=600,...
MiniBatchSize=600,...
InitialLearnRate=0.001,...
ValidationData={valdata(:,1),valdata(:,2)},...
ValidationFrequency=100,...
VerboseFrequency=100,...
Verbose=1, ...
Shuffle="every-epoch",...
Plots="none", ...
DispatchInBackground=true);
[net1,info1] = trainNetwork(traindata(:,1),traindata(:,2),layers1,options);
1 Comment
Accepted Answer
Sanjana
on 30 Mar 2023
Hi,
I understand that you are facing an issue with incompatible input and output sequence lengths,
The above error, is not related to the data as , the input and output data shapes are correct, But if you execute the “analyzeNetwork(layers1)”, from here we can understand the output from the “regressionLayer” has a sequence length of 32 and input layer has a sequence length of 1,this is because of the network architecture you defined. So,I suggest you to try to make changes to the architecture according to your task.
Please refer to the below link for further information,
Hope this helps!
0 Comments
More Answers (0)
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!