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 Center および File ExchangeDeep Learning Toolbox についてさらに検索

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by