- 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.
Error when using predict DLblock in Simulink - Incorrect input size (#74.155.409)
7 views (last 30 days)
Show older comments
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
0 Comments
Accepted Answer
Pavan Sahith
on 7 Feb 2024
Edited: Pavan Sahith
on 7 Feb 2024
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:
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!
More Answers (0)
See Also
Categories
Find more on Get Started with Statistics and Machine Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!