Error using trainNetwork (line 184)

Hi All,
I am trying to classify sequence datasets using deep learning by applying
net = trainNetwork(XTraining,YTraining,layers,options);
where
K>> whos XTraining
Name Size Bytes Class Attributes
XTraining 6586x1 63910544 cell
K>> whos YTraining
Name Size Bytes Class Attributes
YTraining 6586x1 9598 categorical
but I am getting the following error
Error using trainNetwork (line 184)
Out of range subscript.
Caused by:
Error using sub2ind (line 43)
Out of range subscript.
I don't get why I get the out of range subscript error since XTraining & YTraining are both 6586x1.
However if I try
net = trainNetwork(XTraining(1:4000),YTraining(1:4000),layers,options);
it works well but not for any ranges above 4000 :|
Can someone please let me know what's going on and how I can solve this issue?

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 3 月 18 日

0 投票

What would happen if one of the layers requested an array larger than the size stored in your cells, XTraining{1} and so on?
In particular if it fails for values above 4000 check that XTraining{4001} is the same size as XTraining{1}

13 件のコメント

Susan
Susan 2022 年 3 月 18 日
Thanks for your reply. I checked that out. All have the same size, i.e.,
size(XTraining{4001}) = size(XTraining{1})= size(XTraining{6586}) = 2x600
Susan
Susan 2022 年 3 月 21 日
編集済み: Susan 2022 年 3 月 21 日
Any other suggestions?
Walter Roberson
Walter Roberson 2022 年 3 月 21 日
Not at the moment. If you post your code and data then I might be able to get further, perhaps.
Susan
Susan 2022 年 3 月 21 日
That would be great! Thanks in advance.
When I'm attaching the data I got the error "XTraining.zip size exceeds 5 MB". I've tried other format compressing the data file in an archive format such as tart. giz but these format are not acceptable. rather chucking data set, is there any other ways?
Walter Roberson
Walter Roberson 2022 年 3 月 21 日
Google Drive ?
Susan
Susan 2022 年 3 月 21 日
Sure thing!
Here is the code. Label data is attached and the traing data can be find here https://drive.google.com/file/d/1mJ4Fu9SkiYos2yOVykLssiABxuMeDlyA/view?usp=sharing
layers = [ ...
sequenceInputLayer(2)
bilstmLayer(100,'OutputMode','last')
fullyConnectedLayer(19)
softmaxLayer
classificationLayer
];
options = trainingOptions('adam', ...
'MaxEpochs',10, ...
'MiniBatchSize', 50, ...
'InitialLearnRate', 0.01, ...
'SequenceLength', 1000, ...
'GradientThreshold', 1, ...
'ExecutionEnvironment',"auto",...
'plots','training-progress', ...
'Verbose',false);
net = trainNetwork(XTraining,YTraining,layers,options);
By the way, when I wan't to use the classification learner app by uploading these data from workspace, the Xtraining data doesn't show up. Any idea how I can apply the app to these data?
Many many thanks in advance!
Susan
Susan 2022 年 3 月 21 日
I figured out what I did wrong! thanks for offering your help though!
Could you please help me with applying the classification learner app? I think the issue is the classification learner APP does not take cell array as input. How to deal with this issue?
Thanks in advance!
Emma Jakobsson
Emma Jakobsson 2022 年 4 月 6 日
編集済み: Emma Jakobsson 2022 年 4 月 6 日
I solved it too
Ratri M
Ratri M 2022 年 4 月 7 日
I am getting same problem too, would you mind telling what was your solution?
Juan Leal
Juan Leal 2022 年 5 月 14 日
Hi, could you please explain how you solved this issue? I am also having the same problem.
Vinay Kulkarni
Vinay Kulkarni 2023 年 4 月 4 日
Facing same issue. Can you please help on how you solved it.
Susan
Susan 2023 年 4 月 4 日
@Vinay Kulkarni In my case, I had forgotten to change the number of layers in fullyConnectedLayer according to the number of classes. And there were some issues with the length of data in each cell, so I got to ensure that all data had the same size and length. Hope it helps.
Vinay Kulkarni
Vinay Kulkarni 2023 年 4 月 5 日
Thanks @Susan.
I too had made mistake in number of classes. Once that corrected the training started.

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

カテゴリ

ヘルプ センター および File ExchangeLanguage Support についてさらに検索

質問済み:

2022 年 3 月 18 日

コメント済み:

2023 年 4 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by