Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
patternnet vs newff

Subject: patternnet vs newff

From: Barbara priwitzer

Date: 17 Dec, 2012 08:49:28

Message: 1 of 3

Hi

I am trying to update some of my MATLAB scripts accordimg to the new nnet-Toolbox functions, but I cannot get some things to work. For example:

old version:

 p = [0 0 1 1;
     0 1 0 1];
t = [0 1 1 0 ];

f = 'logsig';
net = newff(minmax(p),[2,1],{f,f});

net.IW{1,1}= [0.2 0.2; 0.2 0.2];
net.LW{2,1}=[0.2 0.2];
net.b{1,1} = [0 ;0];
net.b{2,1} = 0;

sim(net,p)
Warning: NEWFF used in an obsolete way.
> In obs_use at 18
  In newff>create_network at 127
  In newff at 102
          See help for NEWFF to update calls to the new argument list.
 

ans =

    0.5498 0.5548 0.5548 0.5596


new version


net = patternnet([2]);
f = 'logsig';
net.layers{2}.transferFcn = f;
net.layers{1}.transferFcn = f;
net = configure(net,p,t);

net.IW{1,1}= [0.2 0.2; 0.2 0.2];
net.LW{2,1}=[0.2 0.2];
net.b{1,1} = [0 ;0];
net.b{2,1} = 0;

net(p)

ans =

    0.7700 0.7749 0.7749 0.7798


The outputs of these two nets, which I thought should be identical are different. I do understand the output of the newff-net, but I don't see how it comes to the results in case of patternnet.

Any help would be very much appreciated

Barbara

Subject: patternnet vs newff

From: Greg Heath

Date: 20 Dec, 2012 06:46:17

Message: 2 of 3

"Barbara" wrote in message <kammao$48q$1@newscl01ah.mathworks.com>...
> Hi
> I am trying to update some of my MATLAB scripts accordimg to the new nnet-Toolbox functions, but I cannot get some things to work. For example:
> old version:
-----SNIP
> f = 'logsig';
> net = newff(minmax(p),[2,1],{f,f});
> net.IW{1,1}= [0.2 0.2; 0.2 0.2];
> net.LW{2,1}=[0.2 0.2];
> net.b{1,1} = [0 ;0];
> net.b{2,1} = 0;
> net(p)
> ans = 0.5498 0.5548 0.5548 0.5596
>
> new version
> net = patternnet([2]);
> net.layers{2}.transferFcn = f;
> net.layers{1}.transferFcn = f;
> net = configure(net,p,t);
> net.IW{1,1}= [0.2 0.2; 0.2 0.2];
> net.LW{2,1}=[0.2 0.2];
> net.b{1,1} = [0 ;0];
> net.b{2,1} = 0;
> net(p)
> ans = > 0.7700 0.7749 0.7749 0.7798
 
> The outputs of these two nets, which I thought should be identical are different. I do understand the output of the newff-net, but I don't see how it comes to the results in case of patternnet.
>
> Any help would be very much appreciated
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

There are 3 generations of the NNTBX to consider. Each has different defaults that
can be deduced, with pain, with the assistance of the commands help, doc and type

RC = Regression and Curvefitting
CP = Classification and Pattern Recognition

1. net1 =newff(minmax(p), [H O], TF*, BTF, BLF, PF ) % RC and CP
        => 'tansig' output/No IPF, OPF, or DDF
2. a. net2 =newff(p, t, H, TF*, BTF, BLF, PF, IPF*, OPF*, DDF*) % RC and CP
        ==> 'purelin' output/IPF, OPF and DDF defaults
    b. net3 =newfit(p, t, H, TF, BTF, BLF, PF, IPF, OPF, DDF) % RC (calls newff)
       ==> same as newff with an added plot
    c. net4 =newpr(p, t, H, TF*, BTF, BLF, PF, IPF, OPF, DDF) % CP (calls newff)
       ==>same as newff with 'tansig' output, 'trainscg' training and added CP plots
3. a. net5 =feedforwardnet( H, TF ) % RC and CP
    b. net6 =fitnet( H, TF ) % RC (calls feedforwardnet)
      ==> same as feedfordnet with an added plot
    c. net7 =patternnet( H, TF ) % CP (calls newff)
      ==>same as newff with 'tansig' output, 'trainscg' training and added CP plots

1. Instead of trying to compare net1 and net7, it is probably best to start with finding the differences among net1, net2 and net5.

2. Nets 2-7 have input and output normalization via MAPMINMAX defaults that results in changes in weight values. So, I don't think just assigning the same weights to the different nets will help.

3. The actual normalizations are probably performed in TRAIN. So it might be wise to override the IPF and OPF defaults and use TRAIN.

4. If TRAIN is used the DDF option should be overridden to make sure all of the data is used for training.

Please post any partial successes in understanding.

Greg

Subject: patternnet vs newff

From: Greg Heath

Date: 20 Dec, 2012 06:57:09

Message: 3 of 3

"Barbara" wrote in message <kammao$48q$1@newscl01ah.mathworks.com>...
> Hi
>
> I am trying to update some of my MATLAB scripts accordimg to the new nnet-Toolbox functions, but I cannot get some things to work. For example:
>
> old version:
___SNIP
> ans = 0.5498 0.5548 0.5548 0.5596
___SNIP
> new version
> ans = 0.7700 0.7749 0.7749 0.7798
 
> The outputs of these two nets, which I thought should be identical are different. I do understand the output of the newff-net, but I don't see how it comes to the results in case of patternnet.
>
> Any help would be very much appreciated

As stated in my previous post, there have been many changes between those versions. Some are readily apparent and some are subtle.

It may be best to just make sure that you know how to use the new functions. Then after they have been tested on data, you can see how they compare with the older versions.

Hope this helps.

Greg

Tags for this Thread

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.

Contact us