
Why do I get the error "Network input data format string cannot be empty" when using the "Predict" block in Simulink R2023b?
조회 수: 6 (최근 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 with Simulink에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!