How can I compile a pre-trained neural network into a standalone application using the MATLAB Compiler 4.10 (R2009a)?

16 views (last 30 days)
The MATLAB Compiler 4.10 (R2009a) support for MATLAB and Toolboxes at the following web-link suggests that I can compile a pre-trained neural network:

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 22 Jan 2010
The following script sets up the creation of a pre-trained network and stores it in a MAT-file ('pre_trained_net.mat').
clear all
close all
P = [1 2 3 4 5];
T = [1 2 3 4 3];
net = newff(P,T,5);
net.trainParam.epochs = 50;
net = train(net,P,T);
save pre_trained_net net
The following function utilizing the pre-trained network can be compiled into a stand-alone application:
function compiled_network(input)
% Include Neural Network Toolbox dependencies.
% web([docroot '/toolbox/compiler/function.html'])
%#function network
% Load data.
load pre_trained_net
if ischar(input)
output = sim(net,input)
The following command may be used to compile the above function into a stand-alone application:
mcc -m compiled_network
The compiled application may be called from the system command line as follows to generate output for new input:
For your convenience, find attached 'pre_trained_net.mat' and 'compiled_network.exe'. The executable was compiled using MATLAB Compiler 4.10 (R2009a) on Windows XP. These files can always be created as described earlier.

More Answers (1)

Kishor Mahanti
Kishor Mahanti on 2 Dec 2017
Please explain above procedure in R2016a. How to create stand alone application of neural network created nftool.





Community Treasure Hunt

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

Start Hunting!