Why do I get the error "Network input data format string cannot be empty" when using the "Predict" block in Simulink R2023b?
12 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2024-4-3
回答: MathWorks Support Team
2024-4-16
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
2024-4-3
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!