Invalid training data. X and Y must have the same number of observations for training a network with MFCC coefficients..
28 次查看(过去 30 天)
显示 更早的评论
My Xtrain is 13854x14 where 14 is feature double and Ytrain(label) is 13854x1 double.Xtrain is mfcc coefficient of an audio file and Ytrain is the corresponding label.How can I train such a network with unequal number of observations.
I would like to use something like this but options are welcome:
layers = [
% input signal chunk - 1000x1
imageInputLayer([1000 1 1])
convolution2dLayer([3,1],1,'Padding','same')
reluLayer
convolution2dLayer([3,1],32,'Padding','same')
reluLayer
convolution2dLayer([3,1],32,'Padding','same')
reluLayer
convolution2dLayer([3,1],32,'Padding','same')
reluLayer
fullyConnectedLayer(1000)
regressionLayer
];
% define training options
miniBatchSize = 128;
validationFrequency = floor(numel(YTrain)/miniBatchSize);
options = trainingOptions('adam', ...
'MiniBatchSize',miniBatchSize, ...
'MaxEpochs',30, ...
'InitialLearnRate',1e-3, ...
'LearnRateSchedule','piecewise', ...
'LearnRateDropFactor',0.1, ...
'LearnRateDropPeriod',20, ...
'Shuffle','every-epoch', ...
'ValidationData',{XValidation,YValidation}, ...
'ValidationFrequency',validationFrequency, ...
'Plots','training-progress', ...
'Verbose',false);
% train and wait
net = trainNetwork(XTrain,YTrain,layers,options);
0 个评论
回答(1 个)
Sourav Bairagya
2019-8-22
To use the “XTrain”and “YTrain” in “trainNetwork” function, you should reshape those properly, otherwise it will throw this type of error.
“XTrain” should be stored as a 4-D vector where the first three dimension describes the dimension of single training sample and fourth dimension will be the number of training samples. For example, say training data contains 50 color images of size 256X256. Then, “XTrain” should be arranged in 256X256X3X50 format.
XTrain=reshape(XTrain, [14,1,1,13854]);
Here, your training data is of size 13854X14 where each sample has 14 features and total number of samples is 13854. Hence, this should be arranged as 14X1X1X13854.
“YTrain” is in correct form. Hence, it need not to be reshaped.
Now, in layers you should specify the dimensions of your input and output corresponding to a single sample. Hence, here, as per your requirement in “imageInputLayer” dimension would be [14 1 1] and in “fullyConnectedLayer” dimension of output will be 1. The code section is as follows:
layers =[
imageInputLayer([14 1 1])
convolution2dLayer([3,1],1,'Padding','same')
reluLayer
convolution2dLayer([3,1],32,'Padding','same')
reluLayer
convolution2dLayer([3,1],32,'Padding','same')
reluLayer
convolution2dLayer([3,1],32,'Padding','same')
reluLayer
fullyConnectedLayer(1)
regressionLayer
];
Similarly, you have to arrange your validation datasets also.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!