Error when using predict DLblock in Simulink - Incorrect input size (#74.155.409)

조회 수: 7 (최근 30일)
Hello, I am experiencing an issue when using the DL block predict in Simulink.
I plan to collect three scalars from sensors to concatenate them in a 1x3 vector to be fed as input in a pretrained feature regression NN, which is loaded from a .mat file. For sake of simplicity, in the simulink model I shared (please see the attached compressed folder), I replaced the sensors with three random number generators. Anyway, I receive the following error:
Error:Incorrect input size. The input data must have 3 columns.
Function 'Predict/MLFB' (#77.155.409), line 5, column 19:
"deep.blocks.internal.deepNetwork({in_1}, {size(in_1)}, {class(in_1)}, coder.cons"
I also tried a test: I collected the input in the workspace (please see the attached figure) to feed it in the NN (via Workspace), and I am able to collect a prediction with the following command:
preds=predict(NN,out.simout1.Data(1,:));
Therefore, I would think that there is something wrong in the size (or the expected size) of the input in my simulink model.
Could you please help me with it?
Many thanks in advance,
Giovanni

채택된 답변

Pavan Sahith
Pavan Sahith 2024년 2월 7일
편집: Pavan Sahith 2024년 2월 7일
Hello Giovanni,
I understand that you are encountering an error related to the DL predict block input size in Simulink. The error indicates that the input data must have three columns.
I can see that you are using the 'Matrix Concatenate' block with 'vector' mode which could be causing this issue. When used in this mode, the output is a one-row or one-column matrix, potentially causing an error when fed into the 'Predict' block.
You can try the following steps to resolve the error:
  • Double-click on the 'Matrix Converter' block to access block parameters.
  • Adjust the number of inputs to 3 for your use case.
  • Change the mode to 'Multidimensional Array.'
  • Specify the concatenate dimension; I assume that it should be 2 in your case.
  • Click on 'Apply' and 'OK' to save the changes.
After making these adjustments, your model should run without encountering the specified error. For your convenience, I have attached an image after making the required changes.
If you want to know more about the Matrix Concatenate and DL Predict block, please refer to the following MathWorks documentation.
Hope this Helps!
  댓글 수: 1
Giovanni
Giovanni 2024년 2월 11일
Hello, Pavan, thank you very much for your answer and help.
I solved this issue by using the transpose block after the concatenation block.
Best regards,
Giovanni

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by