フィルターのクリア

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

9 ビュー (過去 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 Center および File ExchangePreprocess Data for Deep Neural Networks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by