Is it possible to call a pre-trained neural network as a function in another script?

Hi,
I am trying to read the EEG signals in real-time in C++ and then send the data to MATLAB for processing. I have prepared a neural network using neural network toolbox in MATLAB to classify the EEG signals into three categories. Now, my question is how can I use this pre-trained neural network for a new set of dataset automatically without requiring the user to do something manually (import the new data set to network)? So let me clarify, my only question here is when I receive the new EEG signals and process them (add filters and calculate some features as an input for the network) how can I import these feature to the pre-trained network automatically? Can I call the pre-trained network as a function in my script and if yes, what steps do I need to take? (I have saved the network as a Mat file).
Thank you in advance for your response.

2 commentaires

Hi, we are also having a project regarding classification of eeg signals into three categories. We would like to know how you utilize the generated file from ANN in classifying the categories.
Also, we would like to ask on the commands that you utilize in calling the mfile. Thank you

Connectez-vous pour commenter.

 Réponse acceptée

Yes you can save your trained network as for example "net.mat" and later import that network and use "sim" function to get the result for a new signal:
y=sim(net,x) % net is your trained network
% x is the vector of features for new signal
Please read the documentation of sim function for details:
doc network/sim

6 commentaires

Hamoon,
Thank you for your response. Yes, I know that I can use the trained network for a new dataset. But my question is how can I use it automatically in another script?
Thanks.
Suppose that you trained a network, and name of that network is "net", then you saved your network using:
filename='c:\net.mat'; % the full path you what to save your network there
save(filename,'net')
In another script you can write:
filename='c:\net.mat';
load(filename) % this load net into the workspace
y=sim(net,x); % x is the vector of features for new signal
% net is your trained network, you trained it before in
% another script
I'm actually repeating what I said before. Isn't that what you want?
Actually I found a solution myself. But anyway thank you for your help.
If it's not the solution of your problem you should not accept this answer. It also will be a good idea if you comment your solution here, because it might be someone else's problem too, and that helps them to tackle their problem.
Hi, we are also having a project regarding classification of eeg signals into three categories. We would like to know how you utilize the generated file from ANN in classifying the categories.may you please post your codes on how to call or utilize the generated mfile from trained neural net. Thank you

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Deep Learning Toolbox dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by