Error in running one-dimensional CNN regression model
2 views (last 30 days)
Show older comments
Hi,
I'm new to training a CNN regression model, and I need to build one to predict temperature time series data using climate proxy data.
I'm not sure what are functions of various layers, so I'm building a simple CNN model first.
For example, I've temperature time series of length 100 (Y_train=100x1 double) and 45 climate proxy data (X_train=45x100 double), so the input feature number is 45.
I've set my CNN model architecture as follows:
function y_pred = cnn(X_train, X_val, Y_train)
layers = [sequenceInputLayer(45,'MinLength',100)
convolution1dLayer(2,10)
reluLayer
maxPooling1dLayer(2,'Stride',2)
reluLayer
fullyConnectedLayer(1)
reluLayer
regressionLayer];
options = trainingOptions('sgdm', ...
MaxEpochs=500, ...
Verbose=false, ...
Plots='none');
net = trainNetwork(X_train, Y_train, layers, options);
y_pred = predict(net, X_val);
end
When I ran the code, it produces this error message:
I'm unsure where I've done wrong.
0 Comments
Answers (1)
Prasannavenkatesh
on 18 Jun 2023
Hi Marvin,
To solve the error of incompatible input and output sequence lengths, you can try replacing the first layer, i.e, the sequence input layer to sequenceInputLayer(45,'MinLength',1). Hope this solves your problem.
0 Comments
See Also
Categories
Find more on Deep Learning Toolbox 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!