Why do I get the error "Network input data format string cannot be empty" when using the "Predict" block in Simulink R2023b?

12 次查看(过去 30 天)

I have a network trained in PyTorch that I am importing into a MAT-file using the following code:

% Import network
net = importNetworkFromPyTorch("traced_net.pt");

% Initialize network
X = dlarray([1; 1; 1], 'CB');
net = initialize(net, X);

% Then, I save "net" into a MAT-file
I use this MAT file to import the network into the Deep Learning Toolbox "Predict" block to predict a certain input value. However, I am getting an error stating that the "Network input data format string cannot be empty", as seen in the image below:

What is the root cause of this error?

采纳的回答

MathWorks Support Team
The issue stems from the “Input data formats” parameter of the “Predict” block. You currently have an empty “Format” field in “Input data formats”, which is causing the error message you see. To resolve it, you must specify the data “Format” as the one you initialized your network with. That is, insert "CB" into the “Format” field, as illustrated in the image below:
Alternatively, this can be done programmatically through the command
set_param('example_net/Predict', 'InputDataFormats', '{ ''aten__linear0'', ''CB'' }')
where "example_net" is the name of the Simulink model, "Predict" is the name of the block, and "aten__linear0" is the name of the first layer.
As of Release 2024a, MATLAB automatically assigns the “Format” field based on the network you are loading. For more information, see the linked release note:
https://www.mathworks.com/help/deeplearning/release-notes.html?rntext=predict&startrelease=R2021a&endrelease=R2024a&groupby=release&sortby=descending&searchHighlight=predict#mw_f6220a94-07e5-4be5-af99-211de6e51efb

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by