trainNetwork - training data format

7 次查看(过去 30 天)
Hi,
I'm trying to build a concolutional neural network, but I don't get how to prepare training data.
I've got 24 mfcc features as an input and 20 output classes, so as far as I understand I need featureInputLayer and convolution1dLayer.
But when I'm using featureInputLayer I'm getting
"Error using trainNetwork - Invalid network.
(...)
Caused by:
Layer 2: Input data must have one spatial dimension only, one temporal dimension only, or one of each.
Instead, it has 0 spatial dimensions and 0 temporal dimensions."
How to fix this?
my simplified layers:
layers = [ ...
featureInputLayer(numFeatures)
convolution1dLayer(filterSize, numFilters, 'Padding', 'same')
reluLayer
averagePooling1dLayer(2, 'Stride', 2)
fullyConnectedLayer(300)
reluLayer
fullyConnectedLayer(numOutputs)
softmaxLayer
classificationLayer];
My data structure:
trained_net = trainNetwork(XTrain, YTrain, layers, options);
XTrain -> Nx24 double
Ytrain -> Nx1 categorical
To be honest I've tested all combinations of XTrain and YTrain transpositions, but still the same issue .
I've also tried using imageInputLayer as below, but then I've received another error
"Error using trainNetwork - Number of observations in X and Y disagree"
layers = [ ...
imageInputLayer([numFeatures 1])
convolution2dLayer([filterSize 1], numFilters, 'Padding', 'same')
reluLayer
averagePooling2dLayer([2 1], 'Stride', 2)
fullyConnectedLayer(300)
reluLayer
fullyConnectedLayer(numOutputs)
softmaxLayer
classificationLayer];
Please help me finding the right data structure, because the description provided in help is unclear to me.
Thanks,
Zbigniew
PS. versions of Matlab, I'm working on: R2021b, R2023a

回答(1 个)

Matt J
Matt J 2023-9-12
编辑:Matt J 2023-9-12
With your imageInputLayer network, try,
XTrain =reshape(XTrain.', 24,1,1,N);
so that the format of the input is SxSxCxB.

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by