필터 지우기
필터 지우기

Predictors must be a numeric array, a datastore, or a table.

조회 수: 3 (최근 30일)
Shilpa Sonawane
Shilpa Sonawane 2023년 2월 8일
댓글: Shilpa Sonawane 2023년 2월 9일
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

채택된 답변

Walter Roberson
Walter Roberson 2023년 2월 8일
your responses in ylabel1 is a cell array of scalar numbers. cell array with numeric content is supported only for sequence to sequence regression, but your input data is not one of the types that sequences can be coded as. You should probably be using a pure numeric array.
if (kk<=1 && kk>=101)
There is no number that is simultaneously less than or equal to 1 but also greater than or equal to 101. You need to rethink that test.
  댓글 수: 1
Shilpa Sonawane
Shilpa Sonawane 2023년 2월 9일
Sir,
In the code, ylabel1 is cell array with numbers. Could you please guide about decleration of cell array with numeric content.
Thank you sir.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Analytics Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by