在Excel中将Excel文件用作CNN的数据库

时间:2019-11-19 07:02:07

标签: matlab artificial-intelligence

im试图使用excel文件作为数据库来训练此CNN,并idk如何将其设置为适当的数据库。我也无法设置这些参数来训练我的网络。我的Excel是160x2的两倍。 所以我整理好了并运行了代码,但它向我展示了这一点: net = trainNetwork(trainD,targetD,layers,options);

Caused by:
    Layer 9: Input size mismatch. Size of input to this layer is different
    from the expected input size.
    Inputs to this layer:
        from layer 8 (80×1×16 output)

这是我的损坏代码:

addpath('C:\Users\HP\Desktop\CNN Data');
trainD =xlsread('Recie_1'); %my trainning data saved as Recie_*


targetD= xlsread('Trans_1');


layers = [  imageInputLayer([160 2]) 
    convolution2dLayer(2,16,'Padding','same')
    batchNormalizationLayer
    reluLayer 
    maxPooling2dLayer(2,'Stride',2)
    convolution2dLayer(2,16,'Padding','same')
    batchNormalizationLayer
    reluLayer

    maxPooling2dLayer(2,'Stride',2)
    convolution2dLayer(2,32,'Padding','same')
    batchNormalizationLayer
    reluLayer

    fullyConnectedLayer(100) 
    fullyConnectedLayer(50) 
    fullyConnectedLayer(7) 
    softmaxLayer
    classificationLayer];


options = trainingOptions('adam', ...
    'Shuffle','every-epoch', ...
    'InitialLearnRate',0.01, ....
    'MaxEpochs',550, ...
    'MiniBatchSize',64, ...
     'ValidationFrequency',30, ...
    'Verbose',true, ...
    'Plots','training-progress');

%%Train ConvNet:
net = trainNetwork(trainD,targetD,layers,options);
predictedLabels = classify(net,trainD)';
accuracy = sum(predictedLabels == targetD)/numel(targetD);

0 个答案:

没有答案