Error using trainNetwork (line 184)

26 ビュー (過去 30 日間)
Susan
Susan 2022 年 3 月 18 日
コメント済み: Vinay Kulkarni 2023 年 4 月 5 日
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 日
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 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.

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

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by