Error using trainNetwork - possible change with Matlab release?

조회 수: 6 (최근 30일)
Jenny Bosten
Jenny Bosten 2024년 2월 28일
댓글: Matt J 2024년 2월 29일
I am attempting to run some code in R2022b which I haven't run for a while. I believe I have updated Matlab since then and I probably last ran it in 2022a. I have a new error (with no changes to the code):
Error using trainNetwork
To assign to or create a variable in a table, the number of rows must match the height of the table.
However, I am not attempting to use tables.
I am attempting to run
net = trainNetwork(XTrain,YTrain,layers,options);
where Xtrain is a 28x28x3x10000 numeric array of (small) RGB images, and YTrain is a 10000x1 numeric array of training values. The task is a regression task so I believe that both inputs can be in numeric form. Perhaps this has changed, though it's not clear from the help?
There is no other information in the error message.
  댓글 수: 2
Jenny Bosten
Jenny Bosten 2024년 2월 28일
Thanks for any insight anyone can give!
Jenny Bosten
Jenny Bosten 2024년 2월 29일
Embarrassingly, the code has now started running as it was originally. The only thing I did differently was to run an even older script before that was very similar but produced a figure to visualise training progress. I cleared all variables before running the script so it wasn't that. I can't explain it but the glitch seems to be over. Not sure if I can delete the post.

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

답변 (1개)

Matt J
Matt J 2024년 2월 29일
편집: Matt J 2024년 2월 29일
Convert the data to cell array form.
XTrain=num2cell(Xtrain,[1,2,3]); XTrain=XTrain(:);
YTrain=num2cell(YTrain); YTrain=YTrain(:);
  댓글 수: 2
Jenny Bosten
Jenny Bosten 2024년 2월 29일
Thanks Matt for your answer. Once the data are in cell array format (using your code) I still get the same error. For some reason it seems to be expecting a table. I am not really familiar with tables, but according to the help other data formats should still be acceptable. Here is the full error message:
Error using trainNetwork
To assign to or create a variable in a table, the number of rows must match the height of the
table.
Error in TrainCNNTaskExptMunsellProbesLoop (line 169)
net = trainNetwork(XTrain,YTrain,layers,options);
Caused by:
Error using .
To assign to or create a variable in a table, the number of rows must match the height of
the table.
Matt J
Matt J 2024년 2월 29일
I suggest attaching the layers and options in a .mat file so that we can all examine it.

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

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by