how to define sequence input layer and fully connected layer for CNN for multivariate data in matab

12 ビュー (過去 30 日間)
Hi,
I am trying to do CNN with two dimensional data , below is my code for layers , i am getting error .
Error using trainNetwork (line 165)
Invalid training data. Sequence responses must have the same sequence length as the corresponding
predictors.
Error in Multivariate (line 73)
net = trainNetwork(pn,tn,layers,options);
Please help me to understand the mistake:
XTrain is 1x515
YTrain is 1x515
XTest is 1x212
YTest is 1x212
below is my code :
numFeatures = 1;
numResponses = 1;
numHiddenUnits1 = 50;
FiltZise = 5;
layers = [...
sequenceInputLayer([numFeatures 515 1],'Name','input')
sequenceFoldingLayer('Name','fold')
convolution2dLayer(FiltZise,256,'Padding','same','WeightsInitializer','he','Name','conv','DilationFactor',1);
batchNormalizationLayer('Name','bn')
reluLayer('Name','relu')
convolution2dLayer(FiltZise,256,'Padding','same','WeightsInitializer','he','Name','conv1','DilationFactor',2);
reluLayer('Name','relu1')
averagePooling2dLayer(1,'Stride',FiltZise,'Name','pool1')
sequenceUnfoldingLayer('Name','unfold')
flattenLayer('Name','flatten')
fullyConnectedLayer(numResponses,'Name','fc')
regressionLayer('Name','output') ];
layers = layerGraph(layers);
layers= connectLayers(layers,'fold/miniBatchSize','unfold/miniBatchSize');
options = trainingOptions('adam','MaxEpochs',150,'MiniBatchSize',15,'GradientThreshold',1,'InitialLearnRate',0.005,'LearnRateSchedule','piecewise','LearnRateDropPeriod',125,'LearnRateDropFactor',0.2,'Verbose',0, 'Plots','training-progress');
net = trainNetwork(pn,tn,layers,options);
  1 件のコメント
Pratyush Roy
Pratyush Roy 2022 年 1 月 20 日
Hi Neethu,
In order to assist you better with your query, can you please let me know where the variable "numHiddenUnits1" is used while creating the network?

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by