incorrect matrix size while training data

I am training a neural network with input [25x1x1].
I am taking input using imageInputLayer([25 1]).
My training data is sotred in the variable images which is of size [25x1x1x80000].
But when I run the program to train the network I get an error:
I dont know what is causing this error. My input dimensions match with the dimensions of my training data and everything else in the network seems fine.
Please help.

5 件のコメント

KSSV
KSSV 2020 年 6 月 17 日
Try squeezing the training data to 25*80000
Arpan Parikh
Arpan Parikh 2020 年 6 月 17 日
Tried that.
It gives error:
The training images are of size 80000x25x1 but the input layer expects images of size 25x1x1.
Christian
Christian 2020 年 6 月 17 日
Mayge I get your question wrong, but this seems to be a problem of your order of dimensions. I never used it, but you could try to play around with permute().
E.g.:
image = images(1,:,:); % gives size [1x25x1]
image = permute(image, [2,1,3]); % or [2,3,1]
Make sure the image is not mirrored or rotated afterwards.
Arpan Parikh
Arpan Parikh 2020 年 6 月 17 日
Now I am getting the error:
The training images are of size 1x25x1 but the input layer expects images of size 25x1x1.
or
The training images are of size 1x1x25 but the input layer expects images of size 25x1x1.
Arpan Parikh
Arpan Parikh 2020 年 6 月 17 日
It seems that the dimensions are right but matlab is unable to extract training samples for some reason

サインインしてコメントする。

回答 (1 件)

Raynier Suresh
Raynier Suresh 2021 年 2 月 17 日

0 投票

Hi, check whether you have defined the architecture of your network correctly, you can do this by using the command "analyzeNetwork(layers)". For input layer size [25 1] and the training data size [25 1 1 80000] the trainNetwork function should work fine for example you can refer the code below.
layers = [imageInputLayer([25 1])
convolution2dLayer(1,32)
reluLayer
fullyConnectedLayer(4)
softmaxLayer
classificationLayer];
options = trainingOptions('sgdm', ...
'MaxEpochs',1,...
'InitialLearnRate',1e-4, ...
'Verbose',false, ...
'Plots','training-progress');
Xtrain = rand(25,1,1,80000);
Ytrain = categorical(randi(4,80000,1));
net = trainNetwork(Xtrain,Ytrain,layers,options);

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

質問済み:

2020 年 6 月 17 日

回答済み:

2021 年 2 月 17 日

Community Treasure Hunt

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

Start Hunting!

Translated by