我是深度学习环境中的新手,尤其是在音频领域,我使用Matlab遵循here的每个步骤。我使用自己的立体声音频数据集,这是代码
%% Compute Speech Spectrograms
segmentDuration = 2;
frameDuration = 0.025;
hopDuration = 0.010;
numBands = 40;
epsil = 1e-6;
%XTrain = speechSpectrograms(adsTrain(:), segmentDuration, frameDuration, hopDuration, numBands);
XTrain = speechSpectrograms(adsTrain,segmentDuration,frameDuration,hopDuration,numBands);
XTrain = log10(XTrain + epsil);
XValidation = speechSpectrograms(adsValidation,segmentDuration,frameDuration,hopDuration,numBands);
XValidation = log10(XValidation + epsil);
XTest = speechSpectrograms(adsTest,segmentDuration,frameDuration,hopDuration,numBands);
XTest = log10(XTest + epsil);
YTrain = adsTrain.Labels;
YValidation = adsValidation.Labels;
YTest = adsTest.Labels;
%% Add Data Augmentation
sz = size(XTrain);
specSize = sz(1:2);
imageSize = [specSize 1];
augmenter = imageDataAugmenter( ...
'RandXTranslation',[-10 10], ...
'RandXScale',[0.8 1.2], ...
'FillValue',log10(epsil));
augimdsTrain = augmentedImageDatastore(imageSize,XTrain,YTrain, ...
'DataAugmentation',augmenter);
%% Define Neural Network Architecture
classWeights = 1./countcats(YTrain);
classWeights = classWeights'/mean(classWeights);
numClasses = numel(categories(YTrain));
dropoutProb = 0.2;
numF = 12;
layers = [
imageInputLayer(imageSize)
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([1 13])
dropoutLayer(dropoutProb)
fullyConnectedLayer(numClasses)
softmaxLayer
weightedClassificationLayer(classWeights)];
%% Train Network
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, ...
'ValidationData',{XValidation,YValidation}, ...
'ValidationFrequency',validationFrequency, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropFactor',0.1, ...
'LearnRateDropPeriod',20), ...
doTraining = true;
if doTraining
trainedNet = trainNetwork(augimdsTrain,layers,options);
else
load('commandNet.mat','trainedNet');
end
现在我在trainNetwork上遇到错误,这是错误消息:
Error using trainNetwork (line 150)
Index exceeds the number of array elements (0).
Error in tensorflow (line 193)
trainedNet = trainNetwork(augimdsTrain,layers,options);
Caused by:
Index exceeds the number of array elements (0).
这是trainNetwork上的错误行代码:
narginchk(3,4);
try
[layersOrGraph, opts, X, Y] = iParseInputArguments(varargin{:});
[trainedNet, info] = doTrainNetwork(layersOrGraph, opts, X, Y);
catch e
iThrowCNNException( e );
end
end
我知道错误的含义,但我不知道为什么或在哪里解决该问题。有人可以帮助我吗?预先谢谢你。