Thread Subject: how newff works in matrix?

Subject: how newff works in matrix?

From: Ning

Date: 9 Nov, 2008 09:32:02

Message: 1 of 5

newff works well in vectors, how about in matrices?
Here is the code:
%% begin
P=[linspace(0.3,0.1,5);linspace(0.4,0.2,5);linspace(0.5,0.3,5);linspace(0.6,0.4,5)];
T=meshgrid(1:5,1:4);
net = newff(minmax(P),[19,25,4],{'tansig','tansig','purelin'},'trainlm');
net.trainParam.epochs = 1000;
net.trainParam.goal = 0.0001;
net = train(net,P,T);
 y1=sim(net,P);
 Q=meshgrid(linspace(0.3,0.1,5),1:4);
 y2=sim(net,Q);
 %% end
 In this example, I thought y2(1,:) would be equal or apoximate to y1(1,:),but it's not.
 Why? How to modify the code to get it?

Subject: how newff works in matrix?

From: Ning

Date: 10 Nov, 2008 02:30:06

Message: 2 of 5

"Ning" <ning.robin@gmail.com> wrote in message <gf6ami$b39$1@fred.mathworks.com>...
> newff works well in vectors, how about in matrices?
> Here is the code:
> %% begin
> P=[linspace(0.3,0.1,5);linspace(0.4,0.2,5);linspace(0.5,0.3,5);linspace(0.6,0.4,5)];
> T=meshgrid(1:5,1:4);
> net = newff(minmax(P),[19,25,4],{'tansig','tansig','purelin'},'trainlm');
> net.trainParam.epochs = 1000;
> net.trainParam.goal = 0.0001;
> net = train(net,P,T);
> y1=sim(net,P);
> Q=meshgrid(linspace(0.3,0.1,5),1:4);
> y2=sim(net,Q);
> %% end
> In this example, I thought y2(1,:) would be equal or apoximate to y1(1,:),but it's not.
> Why? How to modify the code to made it?
anybody can help me? just run the code, you'll see the result.

Subject: how newff works in matrix?

From: Walter Roberson

Date: 10 Nov, 2008 03:57:12

Message: 3 of 5

Ning wrote:
> "Ning" <ning.robin@gmail.com> wrote in message <gf6ami$b39$1@fred.mathworks.com>...
>> newff works well in vectors, how about in matrices?
>> Here is the code:
>> %% begin
>> P=[linspace(0.3,0.1,5);linspace(0.4,0.2,5);linspace(0.5,0.3,5);linspace(0.6,0.4,5)];
>> T=meshgrid(1:5,1:4);
>> net = newff(minmax(P),[19,25,4],{'tansig','tansig','purelin'},'trainlm');
>> net.trainParam.epochs = 1000;
>> net.trainParam.goal = 0.0001;
>> net = train(net,P,T);
>> y1=sim(net,P);
>> Q=meshgrid(linspace(0.3,0.1,5),1:4);
>> y2=sim(net,Q);
>> %% end
>> In this example, I thought y2(1,:) would be equal or apoximate to y1(1,:),but it's not.
>> Why? How to modify the code to made it?

> anybody can help me? just run the code, you'll see the result.

Well here goes...

??? Undefined function or method 'minmax' for input arguments of type 'double'.

Mind you, if it hadn't failed there, it would have failed because it doesn't know what
newff is.

Looking at your call to 'train', I would suspect that you are trying to use
functions from the Neural Network Toolbox. If so... sorry, the weekend regulars
around here tend not to have the Neural Network Toolbox.

{Myself, I can't see any reason why y2 should approximate y1 any better than would
have been the case for Q = meshgrid(sort(rand(1,5)),1:4) so it is probably a good
thing that I don't do any NN work! }

--
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?

Subject: how newff works in matrix?

From: Ning

Date: 10 Nov, 2008 04:26:02

Message: 4 of 5

Walter Roberson <roberson@hushmail.com> wrote in message >
> Well here goes...
>
> ??? Undefined function or method 'minmax' for input arguments of type 'double'.
>
> Mind you, if it hadn't failed there, it would have failed because it doesn't know what
> newff is.
>
> Looking at your call to 'train', I would suspect that you are trying to use
> functions from the Neural Network Toolbox. If so... sorry, the weekend regulars
> around here tend not to have the Neural Network Toolbox.
>
> {Myself, I can't see any reason why y2 should approximate y1 any better than would
> have been the case for Q = meshgrid(sort(rand(1,5)),1:4) so it is probably a good
> thing that I don't do any NN work! }
>

As inputs, Q(1,:) = P(1,:), therefore if the net relationship was built, y1(1,:) would be equal to or approximate y2(1,:). So the wrong result probably attributed to the failed net building?

Subject: how newff works in matrix?

From: Greg Heath

Date: 12 Nov, 2008 18:09:27

Message: 5 of 5

On Nov 9, 11:26=A0pm, "Ning" <ning.ro...@gmail.com> wrote:
> Walter Roberson <rober...@hushmail.com> wrote in message >
> > Well here goes...
>
> > ??? Undefined function or method 'minmax' for input arguments of type '=
double'.
>
> > Mind you, if it hadn't failed there, it would have failed because it do=
esn't know what
> > newff is.
>
> > Looking at your call to 'train', I would suspect that you are trying to=
 use
> > functions from theNeuralNetwork Toolbox. If so... sorry, the weekend re=
gulars
> > around here tend not to have theNeuralNetwork Toolbox.
>
> > {Myself, I can't see any reason why y2 should approximate y1 any better=
 than would
> > have been the case for Q =3D meshgrid(sort(rand(1,5)),1:4) so it is pro=
bably a good
> > thing that I don't do any NN work! }
>
> As inputs, Q(1,:) =3D P(1,:), therefore if the net relationship was built=
, y1(1,:) would be equal to or approximate y2(1,:). So the wrong result pro=
bably attributed to the failed net building

The inputs to net are column vectors, not row vectors.

Also, reexamine your usage of linspace and meshgrid

help linspace
help meshgrid

Hope this helps.

Greg

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
neutral network Ning 9 Nov, 2008 04:35:04
rssFeed for this Thread

Contact us at files@mathworks.com