Error generating code for network net0_0. Index exceeds the number of array elements. Index must not exceed 0.

2 ビュー (過去 30 日間)
Trying to generate code for trained mobilenetV2 for arm target.
But its failing with error. Could not find more description what can cause this error. Need pointers to debug.
cfg = coder.config('lib');
cfg.TargetLang = 'C++';
cfg.GenCodeOnly=true;
dlcfg = coder.DeepLearningConfig('arm-compute');
dlcfg.ArmArchitecture = 'armv7';
dlcfg.ArmComputeVersion = '19.05';
cfg.DeepLearningConfig = dlcfg;
codegen -config cfg Mobilenet_predict -args {ones(320,592,3,'single')} -report
function out = Mobilenet_predict(in)
persistent mynet;
opencv_linkflags = '`pkg-config --cflags --libs opencv`';
coder.updateBuildInfo('addLinkFlags',opencv_linkflags);
if isempty(mynet)
mynet = coder.loadDeepLearningNetwork('Mobilenet.mat','net');
end
out = predict(mynet,in);
end
  3 件のコメント
Manish N
Manish N 2022 年 2 月 10 日
編集済み: Manish N 2022 年 2 月 14 日
Thanks for the response @Hariprasad Ravishankar
My starting point was mobilnetv2, but i have trained it for image size of 320,592,3
My network looks like
With the original mobilnetv2 pakage with default image size 224,224,3 codegeneration works.
I face same issue with resnet50 and resnet 18.
For Unet code generation works fine without any issue.
When i run the function for semantic segmentation it works correctly, only code generation fails.
How do you want me to share the file for debugging?
Sayan Saha
Sayan Saha 2022 年 2 月 28 日
Hello @Manish N,
Were you able to resolve this issue? If not, can you attach the trained mobilenetv2 model in this post? You should be able to edit the question and attach the model.
If you do not feel comfortable attaching the model MATFile, please contact MathWorks technical support for furhter assistance.
Thanks,
Sayan

サインインしてコメントする。

回答 (1 件)

Walter Roberson
Walter Roberson 2022 年 2 月 10 日
You might need to use a %#function directive to bring in the class that predict is a method of; https://www.mathworks.com/matlabcentral/answers/568818-predict-function-doesn-t-work-in-standalone-matlab-application
mobilenetV2 appears to be an instance of the class https://www.mathworks.com/help/deeplearning/ref/dagnetwork.html
  1 件のコメント
Manish N
Manish N 2022 年 2 月 10 日
編集済み: Manish N 2022 年 2 月 14 日
Thanks for the response, i added the function directive but i am still getting same error during code generation.
Predict function is working correctly when i run segmentaiton in matlab but only during code generation i am facing issues.
I am using Matlab 2021b.
@Walter Roberson is there anything else i can try?
function out = Mobilenet_predict(in)
%#function DAGNetwork
persistent mynet;
if isempty(mynet)
mynet = coder.loadDeepLearningNetwork('Mat_Mobilenet.mat','mobilenet');
end
out = predict(mynet,in);
end

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDeep Learning Code Generation Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by