trainNetwork - training data format

7 visualizzazioni (ultimi 30 giorni)
Zbigniew Brzezicki
Zbigniew Brzezicki il 10 Set 2023
Modificato: Matt J il 12 Set 2023
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

Risposte (1)

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

Categorie

Scopri di più su Deep Learning Toolbox in Help Center e File Exchange

Prodotti


Release

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by