Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Using weights of a trained neural network
Replies: 4   Last Post: Dec 18, 2013 9:07 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Greg Heath

Posts: 5,919
Registered: 12/7/04
Re: Using weights of a trained neural network
Posted: Mar 21, 2013 4:09 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Vito" wrote in message <kieq7u$svk$1@newscl01ah.mathworks.com>...
> "Greg Heath" <heath@alumni.brown.edu> wrote in message <kie99m$ega$1@newscl01ah.mathworks.com>...
> > "Vito" wrote in message <kicqhr$spo$1@newscl01ah.mathworks.com>...
> > > I trained a neural network using the MATLAB Neural Network Toolbox, and in particular using the command nprtool. After that, I exported a structure (called 'net') containing the informations about the NN generated.
> > >
> > > In this way, I created a working neural network, that I can use as classifier.
> > > This network has 200 inputs, 20 neurons in the first hidden layer, and 2 neurons in the last layer that provide a bidimensional output.
> > >
> > > What I want to do is to use the weights in order to obtain the same results that I get using sim() function.
> > >
> > > In order to solve this problem, I try to use the following code:
> > >
> > > y1 = tansig(net.IW{1} * input + net.b{1});
> > > Results = tansig(net.LW{2} * y1 + net.b{2});
> > >
> > > Assuming that input is a monodimensional array of 200 elements, the previous code would work if net.IW{1} is a 20x200 matrix (20 neurons, 200 weights).
> > >
> > > The problem is that I noticed that size(net.IW{1}) returns unexpected values:
> > >

> > > >> size(net.IW{1})
> > >
> > > ans =
> > >
> > > 20 199
> > >
> > > I got the same problem with a network with 10000 input. In this case, the result wasn't 20x10000, but something like 20x9384 (I don't remember the exact value).
> > >
> > > So, the question is: how can I make work the above code?

> >
> > You need to find the dimension bugs. Post your code and we may be able to help.
> >
> > As far as replicating the net function, don't forget that IW is acting on normalized inputs.
> >
> > Hope this helps.
> >
> > Greg

>
>
> I've solved removing the preprocessing and postprocessing functions.
>
> You can see the solution here:
> http://stackoverflow.com/questions/15526112/porting-a-neural-network-trained-with-matlab-in-other-programming-languages/15537848#15537848


It is always satisfying to find a solution to a nagging problem.

However, doesn't it nag you that you don't know exactly what caused the problem in the first place?

Greg



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.