Shallow Neural Networks does not work with MATLAB APP after compilation

조회 수: 2 (최근 30일)
Francesco Pelella
Francesco Pelella 2023년 9월 28일
편집: Aniket 2024년 10월 4일
Dear all,
I am trying to implement a trained Shallow Neural Network inside a designed Matlab APP. The ANN has 2 hidden layers and has been calibrated through a code with the function train, and then saved in the workspace, as follows:
[net,tr] = train(net,x,t);
save("namefile.mat",'net')
At this point, for using the ANN inside an .mlapp file, I am loading it with the function "load", and the using it recalling the name of the net itself, as follows:
load("namefile")
output=net(input);
As long as I am using this approach, before the APP compilation, everything works fine with the execution of the .mlapp file. However, after the creation of the standalone application through the "Application Compiler", the prevision line gives the following error:
"Index exceeds the number of array elements. Index must not exceed 1."
I am trying to solve the problem also by using the "sim" function, but it didn't work, since it seems a compatibility issue between the .mlapp and the .exe file.
How can I solve this problem?
Thank you and regards
  댓글 수: 1
Gowtham
Gowtham 2023년 10월 10일
Hi Francesco
To better understand the issue you're facing, it would be helpful if you could provide the relevant code snippets. Please share the code where you train the neural network, save it to a file, and load it in your MATLAB app.

댓글을 달려면 로그인하십시오.

답변 (1개)

Aniket
Aniket 2024년 10월 4일
편집: Aniket 2024년 10월 4일
I was able to reproduce the issue you are facing. The app worked fine in AppDesigner but error comes when using a standalone app.
Adding the following line of code in your callback function resolves this issue.
%#function network
The above line of code is equivalent to a function declaration, which explicitly attaches the 'network' class object to the CTF archive during the compilation process.
Also, I did not face this issue using R2024b. So you may also upgrade to latest version of MATLAB if possible.
You may refer to this link to know more about MATLAB Compiler limitations:
Hope this resolves the issue.

카테고리

Help CenterFile Exchange에서 Sequence and Numeric Feature Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by