Error in running one-dimensional CNN regression model

2 次查看(过去 30 天)
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.

回答(1 个)

Prasannavenkatesh
Prasannavenkatesh 2023-6-18
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.

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by