newp function… What does specifying the range do?
조회 수: 9 (최근 30일)
이전 댓글 표시
I am aware that newp has been 'obsoleted', but my course requires that we use it for this sheet. I'm having a lot of difficulty understanding what purpose the values that you might specify for a newp function actually serve. For instance, if you have:
P = [0 0 1 1; 0 1 0 1];
T = [0 1 0 1];
net = newp([-2 +2;-2 +2],1);
net = train(net,P,T);
Y = net(P)
Then what do the values
([-2 +2;-2 +2],1)
Actually do? I've searched and looked at literature but it's often explained from a position of already decent understanding. It seems to me that in this case, I can change these values to...
([4444 +5555;-444 +3333],1)
For example - and it has absolutely no effect on the number of epochs, speed, weight values or biases. I have read that they specify the range of the input, but seeing as I can use any value and it has no obvious bearing on the result, what does it mean to specify the range? What do they do, and can someone provide an example where I can see their values actually effect the outcome significantly?
댓글 수: 1
Walter Roberson
2017년 12월 1일
Such networks are discussed at https://www.mathworks.com/help/releases/R2012a/toolbox/nnet/ug/bss4hat-2.html?searchHighlight=newp
채택된 답변
Greg Heath
2017년 12월 1일
편집: Greg Heath
2017년 12월 1일
Before asking questions about any functions it is good practice to first use the MATLAB help and documentation info via, e.g.,
help newp
doc newp
type newp
Even if this doesn't answer your question, it will help you formulate a more precise question.
% "help newp" documentation example:
net1 = newp([0 1; -2 2],1);
x = [0 0 1 1; 0 1 0 1];
t = [0 1 1 1];
% Constant Model
y00 = mean(t) % 0.7500 Reference output
mse00 = mse(t- y00) % 0.1875 Reference mse
% Linear Model % y0 = A * [ ones(1,4) ; x ];
A = t /[ ones(1,4); x ] % [ 0.25 0.5 0.5 ]
y0 = A *[ ones(1,4); x ] % [ 0.25 0.75 0.75 1.25 ]
mse0 = mse(t-y0) % 0.0625
nmse0 = mse0/mse00 % 0.3333 Normalized mse
R20 = 1 - nmse0 % 0.6667 R-squared
% Now: % 1. Simulate the untrained neural network's output,
y1 = net1(x) % [ 1 1 1 1 ]
mse1 = mse(t-y1) % 0.2500
nmse1 = mse1/mse00 % 1.3333
R21 = 1 - nmse1 % -0.3333
% 2. Train the net given the target, t
[ net2 tr y2 e2 ] = train(net1,x,t);
% y2 = [ 0 1 1 1 ], e2 = [ 0 0 0 0 ]
% Double check the answers
isequal(y2,net2(x)) % logical 1
isequal(e2, t-y2) % logical 1
% Grade the trained net
mse2 = mse(e2) % 0
nmse2 = mse2/mse00 % 0
R22 = 1 - nmse2 % 1 PERFECT !!!
Now, I will let you verify that the same answer results from
net1 = newp([0.5 0.5; 0.5 0.5],1);
Which verifies your suspicion that those coordinate ranges do not affect performance.
EXCEPT THE RANGES CANNOT BE NEGATIVE!
If you are still curious, check the code via
type newp
Hope this helps
Thank you for formally accepting my answer
Greg
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!