MATLAB Answers

Using nerual network without the toolbox

2 views (last 30 days)
Brendan Carter
Brendan Carter on 24 Dec 2020
Edited: Brendan Carter on 13 Jan 2021
I'd like to distribute a neural network trained using the Deep Learning Toolbox and I'm wondering whether users will need the Deep Learning Toolbox to apply the trained network (i.e., I'm hoping the toolbox is only needed to create and train networks).
If the Toolbox is needed, then could I use the genFunction command to create functions facimilies of the networks that would not need the Toolbox?
Here's a paraphrased version of the code I'm using (though it might might not be important for the question)...
% Create
Structure=% insert whatever
net = feedforwardnet(Structure);
% Train
[NetName,tr] = train(net,TrainingPredictors,TrainingData);
% Use
Thank you for your time.

Answers (1)

Nitin Kapgate
Nitin Kapgate on 13 Jan 2021
The "genFunction" function generates a MATLAB function for simulating a shallow neural network."genFunction" does not support deep learning networks such as convolutional or LSTM networks.
So if yours is a shallow neural network, you can use "genFunction" to generate a complete stand-alone MATLAB function for simulating a neural network including all settings, weight and bias values, module functions, and calculations in one file.
The result is a standalone MATLAB function file. You can also use this function with MATLAB Compiler and MATLAB Coder tools, hence the requirement of having Deep Learning Toolbox on the user's computer is eliminated.
If you are required to deploy Deep Learning Networks, see Deep Learning Code Generation for more information on code generation for deep learning.
  1 Comment
Brendan Carter
Brendan Carter on 13 Jan 2021
Thank you for the reply!
Yes, through some testing with a colleague I learned that the neural net class did need the Deep Learning toolbox, or some other toolbox that I had and my colleague did not. However, as you said, the genFunction utility allowed me to quickly and easily generate functions to simulate my (shallow) neural networks' behavior to within machine precision. I haven't tested the functions with my colleague, but I suspect they will work.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!