Predictors must be a numeric array, a datastore, or a table.
Show older comments
clear all; close all; clc;
load mfcc_S6_8_01.mat;
load mfcc_S6_8_02.mat;
load mfcc_S6_9_01.mat;
load mfcc_S6_9_02.mat;
[s1 s2]=size(sg_S6_8_01);
%YTrain_data=[sg_S6_8_01 sg_S6_8_02 sg_S6_9_01 sg_S6_9_02];
cmb_8_01=[];
for ii=1:s2
cmb_sg_8=sg_S6_8_01{ii};
cmb_8_01=[cmb_8_01; cmb_sg_8];
end
[s1 s2]=size(sg_S6_8_02)
cmb_8_02=[];
for ii=1:s2
cmb_sg_8_2=sg_S6_8_02{ii};
cmb_8_02=[cmb_8_02; cmb_sg_8_2];
end
[s1 s2]=size(sg_S6_9_01)
cmb_9_01=[];
for ii=1:s2
cmb_sg_9_01=sg_S6_9_01{ii};
cmb_9_01=[cmb_9_01; cmb_sg_9_01];
end
[s1 s2]=size(sg_S6_9_02)
cmb_9_02=[];
for ii=1:s2
cmb_sg_9_02=sg_S6_9_02{ii};
cmb_9_02=[cmb_9_02; cmb_sg_9_02];
end
comb_train_data={cmb_8_01;cmb_8_02;cmb_9_01;cmb_9_02;};
index2=1;
files={sg_S6_8_01; sg_S6_8_02;sg_S6_9_01;sg_S6_9_02};
for ii=1:length(files)
chk_files=files{ii};
for jj=1:length(chk_files)
comb_data=chk_files{jj};
all_frames{:,:,index2}=comb_data;
index2=index2+1;
end
end
YTrain_lbl=categorical([8*ones(1,50) 8*ones(1,51) 9*ones(1,47) 9*ones(1,47)]);
%YTrain_lbl=categorical(YTrain1_lbl);
for kk=1:195
if (kk<=1 && kk>=101)
label1{kk}=8;
else
label1{kk}=9;
end
end
YTrain=all_frames;
classWeights = 1./countcats(YTrain_lbl);
classWeights = classWeights'/mean(classWeights);
numClasses = numel(categories(YTrain_lbl));
numHops=129;numBands=7;
timePoolSize = ceil(numHops/8);
dropoutProb = 0.2;
numF = 12;
layers = [
imageInputLayer([numHops numBands])
convolution2dLayer(3,numF,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(3,'Stride',2,'Padding','same')
convolution2dLayer(3,2*numF,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(3,'Stride',2,'Padding','same')
convolution2dLayer(3,4*numF,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(3,'Stride',2,'Padding','same')
convolution2dLayer(3,4*numF,'Padding','same')
batchNormalizationLayer
reluLayer
convolution2dLayer(3,4*numF,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer([timePoolSize,1])
dropoutLayer(dropoutProb)
fullyConnectedLayer(numClasses)
softmaxLayer
weightedClassificationLayer(classWeights)];
miniBatchSize = 128;
%validationFrequency = floor(numel(YTrain)/miniBatchSize);
options = trainingOptions('adam', ...
'InitialLearnRate',3e-4, ...
'MaxEpochs',25, ...
'MiniBatchSize',miniBatchSize, ...
'Shuffle','every-epoch', ...
'Plots','training-progress', ...
'Verbose',false, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropFactor',0.1, ...
'LearnRateDropPeriod',20)
trainedNet = trainNetwork(all_frames,label1',layers,options);
ERROR:
Error using trainNetwork (line 184)
Invalid training data. Predictors must be a numeric array, a datastore, or a table. For networks with
sequence input, predictors can also be a cell array of sequences.
Error in JAN31_2023_EX (line 113)
trainedNet = trainNetwork(all_frames,label1',layers,options);
Sir/ Madam
I have written code for digit recognition. Input is MFCC matrix only for digit 8 & 9 in terms of frames. In this code, digit 8 frames are 101 and digit 9 frames are 94 frames. i have declared label variable according to that. Please guide to resolve above error
Accepted Answer
More Answers (0)
Categories
Find more on Semantic Segmentation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!