1-D CNN network using data array in Matlab.

clc;
data1= readtable('training.xlsx');
A= table2array(data1);
targetD= categorical(A(:,4));
trainD = (A(:,1:3));
trainDNew = reshape(trainD', [1,3,1,7034]);
layers=[
imageInputLayer([1 3 1], 'Normalization', 'none');
convolution2dLayer([1 200],20,'stride',1);
reluLayer();
maxPooling2dLayer([1 20],'stride',10);
fullyConnectedLayer(4);
softmaxLayer;
classificationLayer];
maxEpochs = 100;
miniBatchSize = 100;
options = trainingOptions('adam', ...
'ExecutionEnvironment','auto', ...
'MaxEpochs',maxEpochs, ...
'MiniBatchSize',miniBatchSize, ...
'GradientThreshold',1, ...
'Verbose',false, ...
'Plots','training-progress');
net = trainNetwork(trainD',targetD,layers,options);
I have a data array for training with 7034 rows and 3 column ( input) and 4th column as output (catagorial). My code is attached. I am receiving the following error:
Eror using trainNetwork (line 170)
Invalid network.
Caused by:
Layer 2: Input size mismatch. Size of input to this layer is different from the expected input size.
Inputs to this layer:
from layer 1 (output size 1×3×1)
Can anyone tell me what is the problem with the input layer. As I have given my input layar like
imageInputLayer([1 3 1]);
I have created a 4D data array using reshape. trainDNew = reshape(trainD', [1,3,1,7034]);
Please help me with this problem.

回答(0 个)

类别

标签

Community Treasure Hunt

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

Start Hunting!

Translated by