# Neural Network will not "Learn"

3 vues (au cours des 30 derniers jours)
Gil maor le 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 commentaireAfficher -1 commentaires plus anciensMasquer -1 commentaires plus anciens
Andreas Goser le 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?

Connectez-vous pour commenter.

### Réponses (2)

Héctor Corte le 10 Jan 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.
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

Greg Heath le 11 Jan 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
##### 0 commentairesAfficher -2 commentaires plus anciensMasquer -2 commentaires plus anciens

Connectez-vous pour commenter.

### Catégories

En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by