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

9 次查看(过去 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);

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Data Workflows 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by