1D CNN for time series data

I am writing for creating a 1d CNN model in which the 'X' is input matrix of 123*6 matrix and 'Y' is the output matrix of 123*1. CNN model has 7 layers including 3 convolution layer 2 maxpooling layer and 2 fully connected layer. The first convolution kernel is 6*1 size and stride is 6. ReLu is the activation funtion. Optimizer is adam. and number of iteration (epoochs) is 200. The sequence of cnn model is input layer then first convoultion layer the max pooling layer then second convolution layer then maxpooling layer. Then third convolution layer. Then two fully connected layers then output.
%% Load the data
load('all_features.mat')
d=features;
X=features(:,1:6);
Y=features(:,7);
%%
% Split data into training and validation sets
numObservations = size(X,1);
idx = randperm(numObservations);
numTrain = round(0.8 * numObservations);
idxTrain = idx(1:numTrain);
idxValidation = idx(numTrain+1:end);
XTrain = X(idxTrain,:);
YTrain = Y(idxTrain,:);
XValidation = X(idxValidation,:);
YValidation = Y(idxValidation,:);
% Define model architecture
layers = [ sequenceInputLayer(6,'MinLength',123) convolution1dLayer(6,6) reluLayer maxPooling1dLayer(6,'Stride',6) convolution1dLayer(6,6) reluLayer maxPooling1dLayer(6,'Stride',6) convolution1dLayer(6,6) reluLayer fullyConnectedLayer(6) fullyConnectedLayer(1) regressionLayer];
% Set training options
options = trainingOptions('adam', ...
'MaxEpochs',200, ...
'ValidationData',{XValidation,YValidation}, ...
'Verbose',false, ...
'Plots','training-progress');
% Train model
XTrain = padarray(XTrain,[0 123-size(XTrain,2)],'post');
XValidation = padarray(XValidation,[0 123-size(XValidation,2)],'post');
cnn = trainNetwork(XTrain,YTrain,layers,options);
YPred = predict(cnn,XTest);
kindly help me to debug the issue.

댓글 수: 1

Rahul
Rahul 2023년 1월 5일
What is exactly the issue? Please share any error message or screenshot.
From the understanding of dataset information and the CNN model shared by you, it seems you are trying to solve a problem of time-series regression. You can also go through below documnetation pages for more information.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

질문:

2022년 12월 16일

댓글:

2023년 1월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by