Neural Network will not "Learn"

6 ビュー (過去 30 日間)
Gil maor
Gil maor 2011 年 3 月 8 日
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 件のコメント
Andreas Goser
Andreas Goser 2011 年 3 月 8 日
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?

サインインしてコメントする。

回答 (2 件)

Héctor Corte
Héctor Corte 2012 年 1 月 10 日
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 2012 年 1 月 11 日
>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

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by