Question about "newp" function in neural network toolbox

16 次查看(过去 30 天)
net = newp([-2 2;-2 +2],1);
I'm trying to learn about neural network on my own by reading the tutorial there's one part i don't understand about 'newp' function. all the example given, they use [-2 2,-2 +2] i couldn't figure out why this combination is used.
looking at the help file, it says:
Syntax net = newp(p,t,tf,lf) where P - RxQ matrix of Q1 representative input vectors. T - SxQ matrix of Q2 representative target vectors.
isn't RxQ & SxQ suppose to be the vector size? such as 3x2 the example seems to use P as [-2 2;-2 +2] and T as 1
any clarification is deeply appreciated. Thank you.

采纳的回答

Greg Heath
Greg Heath 2015-1-14
net = newp([-2 2;-2 +2],1);
The square -2 <= x1 <= 2 , -2 <= x2 <= 2 is defined as the region where the output is supposed to be unity. Otherwise, it should be zero.
Syntax net = newp(x,t,tf,lf) where
x - IxN matrix of N representative I-dimensional input vectors.
t - OxN matrix of N corresponding representative O-dimensional output target vectors.
close all, clear all, clc
net = newp([0 1; -2 2],1) % "Ones" rectangular region, R, is defined
view(net)
x = [ 0: 0.1 : 1; -2: 0.4 : 2] % Eleven points within R
y = net(x) % y = ones(1,11)
%Now we define a problem, an OR gate, with a set of four 2-element input vectors x and the corresponding four 1-element targets t.
x = [ 0 0 1 1; ...
0 1 0 1 ]
t = [ 0 1 1 1 ] % t is one if x1 or x2 is one
% Here we simulate the network's output, train the net and then simulate it again
y = net(x) % 1 1 1 1
e = t-y % -1 0 0 0 error vector
MAE = mae(e) % 0.25 mean-absolute error
% Train the net to reduce the MAE. it will stop when converged
net = train(net,x,t);
y = net(P) % 0 1 1 1
e = t-y % 0 0 0 0
MAE = mae(e) % 0
Hope this helps
Thank you for formally accepting my answer
Greg

更多回答(1 个)

Greg Heath
Greg Heath 2015-1-14
>> help newp newp Create a perceptron.
Obsoleted in R2010b NNET 7.0. Last used in R2010a NNET 6.0.4.
I suggest you begin with something more relevant. Type doc into the command line and concentrate on learning how to use the regression and classification functions, respectively. Concentrate on
help fitnet % regression and curve-fitting
doc fitnet
help patternnet % classification and pattern-recognition
doc patternnet
You can find practice data from
help nndatasets
doc nndatasets
You can find some examples searching NEWSGROUP and ANSWERS using
greg fitnet
and
greg patternnet.
Once you feel relatively non-apprehensive, investigate the other two main categories:
clustering and time-series.
You can always post to NEWSGROUP or ANSWERS if you get stuck. Also familiarize your self with what the mathworks.com website has to offer
Hope this helps.
Greg

Community Treasure Hunt

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

Start Hunting!

Translated by