Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Creating standalone application that contains neural network toolbox functions

Subject: Creating standalone application that contains neural network toolbox functions

From: Christine

Date: 27 Mar, 2009 01:39:01

Message: 1 of 9

Hi guys! I have a problem while creating a standalone application that contains functions from the neural network toolbox. The use the simplest code under the callback of a push button:

net = newlin([-1 1],1,[0 1],0.01);
P1 = {0 -1 1 1 0 -1 1 0 0 1};
Y = sim(net,P1)
net = init(net);
T1 = {0 -1 0 2 1 -1 0 1 0 1};
[net,Y,E,Pf] = adapt(net,P1,T1); Y
P2 = {1 0 -1 -1 1 1 1 0 -1};
T2 = {2 1 -1 -2 0 2 2 1 0};
[net,Y,E,Pf] = adapt(net,P2,T2,Pf); Y
P3 = [P1 P2];
T3 = [T1 T2];
net.trainParam.epochs = 200;
net.trainParam.goal = 0.1;
net = train(net,P3,T3);
Y = sim(net,[P1 P2])

and I have tested it, it is free-error.. I use the code below to compile it:

mcc -m gui.m

After compiling it, I tested the .exe file and found that it has error and when I refer to the mccExcludedFiles.log, it reads as below:
--------------------------------------------------------------------------------------------------------
mccExcludedFiles.log
--------------------------------------------------------------------------------------------------------
This file contains the list of various toolbox functions that are not
included in the CTF file. An error will be thrown if any of these functions
 are called at run-time. Some of these functions may be from toolboxes
that you are not using in your application. The reason for this is that
these toolboxes have overloaded some methods that are called by your code.
If you know which toolboxes are being used by your code, you can use the -p
 flag with the -N flag to list these toolboxes explicitly. This will
cause MATLAB Compiler to only look for functions in the specified toolbox
directories in addition to the MATLAB directories. Refer to the MCC
documentation for more information on this.

C:\Program Files\MATLAB\R2008a\toolbox\local\docopt.m
  called by C:\Program Files\MATLAB\R2008a\toolbox\matlab\helptools\web.m
(C:\Program Files\MATLAB\R2008a\toolbox\compiler\depfun.opts, line 6:
exclude if $caller in [$toolbox/matlab, $toolbox/daq] and ...
           $file in $toolbox and ...
           $file not in [$toolbox/matlab, $toolbox/shared, $toolbox/compiler])
C:\Program Files\MATLAB\R2008a\toolbox\nnet\nnet\@network\adapt.m
  called by C:\Users\christinegee\Documents\MATLAB\main_gui\gui_lin.m
(because of toolbox compilability rules)
C:\Program Files\MATLAB\R2008a\toolbox\nnet\nnet\@network\adapt.m
  called by C:\Program Files\MATLAB\R2008a\toolbox\nnet\nnet\nnnetwork\newlin.m
(because of toolbox compilability rules)
C:\Program Files\MATLAB\R2008a\toolbox\nnet\nnet\@network\init.m
  called by C:\Users\christinegee\Documents\MATLAB\main_gui\gui_lin.m
(because of toolbox compilability rules)
C:\Program Files\MATLAB\R2008a\toolbox\nnet\nnet\@network\init.m
  called by C:\Program Files\MATLAB\R2008a\toolbox\nnet\nnet\nnnetwork\newlin.m
(because of toolbox compilability rules)
C:\Program Files\MATLAB\R2008a\toolbox\nnet\nnet\@network\init.m
  called by C:\Program Files\MATLAB\R2008a\toolbox\matlab\scribe\legend.m
(C:\Program Files\MATLAB\R2008a\toolbox\compiler\depfun.opts, line 6:
exclude if $caller in [$toolbox/matlab, $toolbox/daq] and ...
           $file in $toolbox and ...
           $file not in [$toolbox/matlab, $toolbox/shared, $toolbox/compiler])
C:\Program Files\MATLAB\R2008a\toolbox\nnet\nnet\@network\train.m
  called by C:\Users\christinegee\Documents\MATLAB\main_gui\gui_lin.m
(because of toolbox compilability rules)
C:\Program Files\MATLAB\R2008a\toolbox\nnet\nnet\@network\train.m
  called by C:\Program Files\MATLAB\R2008a\toolbox\nnet\nnet\nnnetwork\newlin.m
(because of toolbox compilability rules)
C:\Program Files\MATLAB\R2008a\toolbox\nnet\nnet\@network\gensim.m
  called by C:\Program Files\MATLAB\R2008a\toolbox\nnet\nnet\nnnetwork\newlin.m
(because of toolbox compilability rules)
--------------------------------------------------------------------------------------------------------


so, i add the -N -p flag which

mcc -N -p 'C:\Program Files\MATLAB\R2008a\toolbox\nnet\nnet\@network\' -m gui.m


and my .exe file still running with error when i click the push button.. below is the latest mccExcludedFiles.log:
--------------------------------------------------------------------------------------------------------
mccExcludedFiles.log
--------------------------------------------------------------------------------------------------------
This file contains the list of various toolbox functions that are not
included in the CTF file. An error will be thrown if any of these functions
 are called at run-time. Some of these functions may be from toolboxes
that you are not using in your application. The reason for this is that
these toolboxes have overloaded some methods that are called by your code.
If you know which toolboxes are being used by your code, you can use the -p
 flag with the -N flag to list these toolboxes explicitly. This will
cause MATLAB Compiler to only look for functions in the specified toolbox
directories in addition to the MATLAB directories. Refer to the MCC
documentation for more information on this.

C:\Program Files\MATLAB\R2008a\toolbox\local\docopt.m
  called by C:\Program Files\MATLAB\R2008a\toolbox\matlab\helptools\web.m
(C:\Program Files\MATLAB\R2008a\toolbox\compiler\depfun.opts, line 6:
exclude if $caller in [$toolbox/matlab, $toolbox/daq] and ...
           $file in $toolbox and ...
           $file not in [$toolbox/matlab, $toolbox/shared, $toolbox/compiler])
--------------------------------------------------------------------------------------------------------

Hope someone can solve my problem T.T

Subject: Creating standalone application that contains neural network toolbox functions

From: Christine

Date: 27 Mar, 2009 06:51:04

Message: 2 of 9

i have checked what the MATLAB Compiler 4.10 can and cannot be compiled in the below link:
http://www.mathworks.com/products/compiler/compiler_support.html


I am using the Neural Network Toolbox 6.0.2 in my gui and...

THIS CAN BE COMPILED
Pre-trained network
command line functions


THIS CANNOT BE COMPILED
    * All other command line functionality
    * All GUIs provided with toolbox
    * Simulink blocks
    * gensim



Is that means that there is no way to create a standalone application from GUI that contains neural network toolbox functions?

Subject: Creating standalone application that contains neural network

From: Ashish Uthama

Date: 8 Apr, 2009 20:33:58

Message: 3 of 9

On Fri, 27 Mar 2009 02:51:04 -0400, Christine <christine_gee@hotmail.com>
wrote:

> i have checked what the MATLAB Compiler 4.10 can and cannot be compiled
> in the below link:
> http://www.mathworks.com/products/compiler/compiler_support.html
>
>
> I am using the Neural Network Toolbox 6.0.2 in my gui and...
>
> THIS CAN BE COMPILED
> Pre-trained network
> command line functions
>
>
> THIS CANNOT BE COMPILED
> * All other command line functionality
> * All GUIs provided with toolbox
> * Simulink blocks
> * gensim
>
>
>
> Is that means that there is no way to create a standalone application
> from GUI that contains neural network toolbox functions?


Christine,

You will not be able to compile any function which trains the network
(like ADAPT). Though the link does not explicitly list these funcions
(like ADAPT), they fall under the 'All other command line functionality'.

However, you can deploy a M function code which uses a pre-trained
network. I believe the SIM function will deploy fine.

The workflow I see is:
1. In MATLAB, train you network using test input/output
2. Save the network (mat file?)
3. Create a deployable function which then uses the pretrained network for
new data. The network itself would not change/adapt/train in this function
4. Compile and deploy the above function

Subject: Creating standalone application that contains neural network

From: Stephen Currah

Date: 10 May, 2009 13:29:01

Message: 4 of 9

"Ashish Uthama" <first.last@mathworks.com> wrote in message <op.ur24qwr2a5ziv5@uthamaa.dhcp.mathworks.com>...
> On Fri, 27 Mar 2009 02:51:04 -0400, Christine <christine_gee@hotmail.com>
> wrote:
>
> > i have checked what the MATLAB Compiler 4.10 can and cannot be compiled
> > in the below link:
> > http://www.mathworks.com/products/compiler/compiler_support.html
> >
> >
> > I am using the Neural Network Toolbox 6.0.2 in my gui and...
> >
> > THIS CAN BE COMPILED
> > Pre-trained network
> > command line functions
> >
> >
> > THIS CANNOT BE COMPILED
> > * All other command line functionality
> > * All GUIs provided with toolbox
> > * Simulink blocks
> > * gensim


> Christine,
>
> You will not be able to compile any function which trains the network
> (like ADAPT). Though the link does not explicitly list these funcions
> (like ADAPT), they fall under the 'All other command line functionality'.
>

To all,
It seems to me that the Neural Network Toolbox is very limited in its practical application until the compiler is brought up to date to handle NNs. Application only for academics and students - but just an interesting toy to those wanting to use it for real applications. I hope that the MATLAB team can fix these limitations a.s.a.p. My purchase of MATLAB & the Toolbox has to go on hold now. Does anyone know of an alternative package that's ready to go that I can use to develop real deployable NN applications - maybe using Visual Studio?
Many thanks.

Subject: Creating standalone application that contains neural network

From: Murat

Date: 17 Jun, 2009 06:19:02

Message: 5 of 9

Christine,

I experience a similar situation. I got a similar mccExcludedFiles.log for my .NET deployment. The thing is if I use my 2008a I don't have any problem but I do have problem when I use 2009a. It seems we need to wait until Mathworks updates the compiler for 2009a.

Thanks,
Murat

"Stephen Currah" <stephen.currah@oakwoodstud.co.uk> wrote in message <gu6kqt$d93$1@fred.mathworks.com>...
> "Ashish Uthama" <first.last@mathworks.com> wrote in message <op.ur24qwr2a5ziv5@uthamaa.dhcp.mathworks.com>...
> > On Fri, 27 Mar 2009 02:51:04 -0400, Christine <christine_gee@hotmail.com>
> > wrote:
> >
> > > i have checked what the MATLAB Compiler 4.10 can and cannot be compiled
> > > in the below link:
> > > http://www.mathworks.com/products/compiler/compiler_support.html
> > >
> > >
> > > I am using the Neural Network Toolbox 6.0.2 in my gui and...
> > >
> > > THIS CAN BE COMPILED
> > > Pre-trained network
> > > command line functions
> > >
> > >
> > > THIS CANNOT BE COMPILED
> > > * All other command line functionality
> > > * All GUIs provided with toolbox
> > > * Simulink blocks
> > > * gensim
>
>
> > Christine,
> >
> > You will not be able to compile any function which trains the network
> > (like ADAPT). Though the link does not explicitly list these funcions
> > (like ADAPT), they fall under the 'All other command line functionality'.
> >
>
> To all,
> It seems to me that the Neural Network Toolbox is very limited in its practical application until the compiler is brought up to date to handle NNs. Application only for academics and students - but just an interesting toy to those wanting to use it for real applications. I hope that the MATLAB team can fix these limitations a.s.a.p. My purchase of MATLAB & the Toolbox has to go on hold now. Does anyone know of an alternative package that's ready to go that I can use to develop real deployable NN applications - maybe using Visual Studio?
> Many thanks.

Subject: Creating standalone application that contains neural network

From: Hamid

Date: 11 May, 2011 22:01:04

Message: 6 of 9

"Ashish Uthama" <first.last@mathworks.com> wrote in message <op.ur24qwr2a5ziv5@uthamaa.dhcp.mathworks.com>...
> On Fri, 27 Mar 2009 02:51:04 -0400, Christine <christine_gee@hotmail.com>
> wrote:
>
> > i have checked what the MATLAB Compiler 4.10 can and cannot be compiled
> > in the below link:
> > http://www.mathworks.com/products/compiler/compiler_support.html
> >
> >
> > I am using the Neural Network Toolbox 6.0.2 in my gui and...
> >
> > THIS CAN BE COMPILED
> > Pre-trained network
> > command line functions
> >
> >
> > THIS CANNOT BE COMPILED
> > * All other command line functionality
> > * All GUIs provided with toolbox
> > * Simulink blocks
> > * gensim
> >
> >
> >
> > Is that means that there is no way to create a standalone application
> > from GUI that contains neural network toolbox functions?
>
>
> Christine,
>
> You will not be able to compile any function which trains the network
> (like ADAPT). Though the link does not explicitly list these funcions
> (like ADAPT), they fall under the 'All other command line functionality'.
>
> However, you can deploy a M function code which uses a pre-trained
> network. I believe the SIM function will deploy fine.
>
> The workflow I see is:
> 1. In MATLAB, train you network using test input/output
> 2. Save the network (mat file?)
> 3. Create a deployable function which then uses the pretrained network for
> new data. The network itself would not change/adapt/train in this function
> 4. Compile and deploy the above function


I have the same problem.
I can live with this case that we can't train or change the network.
I have a pre-trained network saved to file. but when I load the network and try to get the output of a test sample I get the following error:
"Subscript indices must either be real positive integers or logicals"

for this line of code ----> testOutput = net(data_inputNN);
I'm using matlab2010b

I added a line in my function to save the network to see how it's handling the network.
after opening the mat file in matlab I noticed that it has saved the network as a "struct" and all the weights and biases are empty.

Please help.

Thank you.

Subject: Creating standalone application that contains neural network

From: Murat Ates

Date: 11 May, 2011 22:41:05

Message: 7 of 9

Hamid, have a look at this link:
http://www.mathworks.com/support/tech-notes/1200/1207.html#19

Thanks,
Murat

"Hamid " <s.hamid.d@gmail.com> wrote in message

> I have the same problem.
> I can live with this case that we can't train or change the network.
> I have a pre-trained network saved to file. but when I load the network and try to get the output of a test sample I get the following error:
> "Subscript indices must either be real positive integers or logicals"
>
> for this line of code ----> testOutput = net(data_inputNN);
> I'm using matlab2010b
>
> I added a line in my function to save the network to see how it's handling the network.
> after opening the mat file in matlab I noticed that it has saved the network as a "struct" and all the weights and biases are empty.
>
> Please help.
>
> Thank you.

Subject: Creating standalone application that contains neural network

From: Hamid

Date: 12 May, 2011 15:30:26

Message: 8 of 9

"Murat Ates" wrote in message <iqf3a1$lj1$1@newscl01ah.mathworks.com>...
> Hamid, have a look at this link:
> http://www.mathworks.com/support/tech-notes/1200/1207.html#19
>
> Thanks,
> Murat
>
> "Hamid " <s.hamid.d@gmail.com> wrote in message
>
> > I have the same problem.
> > I can live with this case that we can't train or change the network.
> > I have a pre-trained network saved to file. but when I load the network and try to get the output of a test sample I get the following error:
> > "Subscript indices must either be real positive integers or logicals"
> >
> > for this line of code ----> testOutput = net(data_inputNN);
> > I'm using matlab2010b
> >
> > I added a line in my function to save the network to see how it's handling the network.
> > after opening the mat file in matlab I noticed that it has saved the network as a "struct" and all the weights and biases are empty.
> >
> > Please help.
> >
> > Thank you.

Murat,

thanks for replying,
I've seen this link before.

but my problem is that my code works totally fine through matlab itself, and it even works great if I use Matlab Engine's com interface from VisualStudio.
But I get this error when I try to use the .Net Assembly from VS.
I saved the data I'm passing into the net() method and by analyzing it, it seems to be fine there is nothing wrong with it.
in fact I used the same data from inside Matlab to test if the net() method works and it works fine.

so my problem is only with the .Net Assembly.

as mentioned above assuming that I can't train or change the network using the .NET assembly how can I just get the output of new inputs with a previously trained network.

Thanks,
Hamid

Subject: Creating standalone application that contains neural network

From: vahid

Date: 23 Jun, 2013 21:51:08

Message: 9 of 9

"Hamid " <s.hamid.d@gmail.com> wrote in message <iqf0v0$fnu$1@newscl01ah.mathworks.com>...
> "Ashish Uthama" <first.last@mathworks.com> wrote in message <op.ur24qwr2a5ziv5@uthamaa.dhcp.mathworks.com>...
> > On Fri, 27 Mar 2009 02:51:04 -0400, Christine <christine_gee@hotmail.com>
> > wrote:
> >
> > > i have checked what the MATLAB Compiler 4.10 can and cannot be compiled
> > > in the below link:
> > > http://www.mathworks.com/products/compiler/compiler_support.html
> > >
> > >
> > > I am using the Neural Network Toolbox 6.0.2 in my gui and...
> > >
> > > THIS CAN BE COMPILED
> > > Pre-trained network
> > > command line functions
> > >
> > >
> > > THIS CANNOT BE COMPILED
> > > * All other command line functionality
> > > * All GUIs provided with toolbox
> > > * Simulink blocks
> > > * gensim
> > >
> > >
> > >
> > > Is that means that there is no way to create a standalone application
> > > from GUI that contains neural network toolbox functions?
> >
> >
> > Christine,
> >
> > You will not be able to compile any function which trains the network
> > (like ADAPT). Though the link does not explicitly list these funcions
> > (like ADAPT), they fall under the 'All other command line functionality'.
> >
> > However, you can deploy a M function code which uses a pre-trained
> > network. I believe the SIM function will deploy fine.
> >
> > The workflow I see is:
> > 1. In MATLAB, train you network using test input/output
> > 2. Save the network (mat file?)
> > 3. Create a deployable function which then uses the pretrained network for
> > new data. The network itself would not change/adapt/train in this function
> > 4. Compile and deploy the above function
>
>
> I have the same problem.
> I can live with this case that we can't train or change the network.
> I have a pre-trained network saved to file. but when I load the network and try to get the output of a test sample I get the following error:
> "Subscript indices must either be real positive integers or logicals"
>
> for this line of code ----> testOutput = net(data_inputNN);
> I'm using matlab2010b
>
> I added a line in my function to save the network to see how it's handling the network.
> after opening the mat file in matlab I noticed that it has saved the network as a "struct" and all the weights and biases are empty.
>
> Please help.
>
> Thank you.
Hamid I have the same problem as yours. If you could solve your problem, plz let me know, how?

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us