Neural Network will not "Learn"

7 visualizzazioni (ultimi 30 giorni)
Gil maor
Gil maor il 8 Mar 2011
Hello All,
As part of a robotic project of main I want to creat a nueral network,
I have started with a simple target function y=2*x but still I cannot get matlab to identify this function.
Any suggestion, Whay am I doing wrong? I'm using matlab 10
net = newff(in,out,[20,10]);
net.trainParam.epochs = 50;
net = train(net,in,out);
Y = sim(net,in);
plot(in,out,'o',in,Y,'x')
Thanks very much
Gil,
  1 Commento
Andreas Goser
Andreas Goser il 8 Mar 2011
I put your code into the question and delete the answer. This way more people will look at the question.
Can you clarify what "MATLAB 10" is? Release 10 or MATLAB 7.10?

Accedi per commentare.

Risposte (2)

Héctor Corte
Héctor Corte il 10 Gen 2012
I have used your code and it works properly. What kind of error are you getting? I used x on interval [-2,10]. Note that with 20 and 10 neurons your net is by far a oversized network for this task. For example 5 and 3 also works fine.

Greg Heath
Greg Heath il 11 Gen 2012
>As part of a robotic project of main I want to creat a nueral network, >I have started with a simple target function y=2*x but still I cannot >get matlab to identify this function.
Replace "identify" with "approximate". The former refers to a different kind of problem.
>Any suggestion, Whay am I doing wrong? I'm using matlab 10
>net = newff(in,out,[20,10]);
In general, one hidden layer with H nodes is sufficient where H is determined by trial and error. However, a linear function can be approximated with no hidden layer.
For demo purposes, ignore that fact or be more adventurous and consider y = sqrt(x) and/or y = x^2.
The lowest value of H that can be used will increase with length(x).
>net.trainParam.epochs = 50;
Delete. Just use the default.
>net = train(net,in,out); >Y = sim(net,in);
You didn't take into account that newff automatically scales the inputs and outputs to the range [-1 1].
Read the documentation to understand the defaults.
>plot(in,out,'o',in,Y,'x')
Hope this helps.
Greg

Categorie

Scopri di più su Deep Learning Toolbox in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by