how to define sequence input layer and fully connected layer for CNN for multivariate data in matab
1 次查看(过去 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
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 Exchange 中查找有关 Image Data Workflows 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!