trainNetwork - training data format

조회 수: 7 (최근 30일)
Zbigniew Brzezicki
Zbigniew Brzezicki 2023년 9월 10일
편집: Matt J 2023년 9월 12일
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
NAVNEET NAYAN
NAVNEET NAYAN 2023년 9월 12일
what is the size of your feature?

댓글을 달려면 로그인하십시오.

답변 (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