Error generating code for network net0_0. Index exceeds the number of array elements. Index must not exceed 0.
2 views (last 30 days)
Show older comments
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 Comments
Sayan Saha
on 28 Feb 2022
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
Answers (1)
Walter Roberson
on 10 Feb 2022
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
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
