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:
simple neural network question

Subject: simple neural network question

From: Marco Wu

Date: 4 Mar, 2012 21:36:12

Message: 1 of 2

Dear all,

I am new to neural network toolbox. Please help me on this questions. I actually have 2 questions. The first one is concept base. The 2nd one is syntax base.


I have 256 input channels and 10 output categories. What network should I use if I have to make sure that 1 and only 1 output category will be selected every time?




***THE SECOND QUESTION*********************************

 I got error after I run my simple code. Thanks

Here is my code

input_training_data = HandWritingData(random_list,:)'; %size = [256X788]
target_training_data = Category(random_list,:)'; %size = [10x788]

net = newff(minmax(input_training_data), [15 10], {'logsig','logsig'} , 'hardlim' ); %create a network

=====================
The ERROR is
Warning: NEWFF used in an obsolete way.
> In nntobsu at 18
  In newff at 86
  In Neural_Network_code at 19
          See help for NEWFF to update calls to the new argument list.
 
??? Error using ==> boiler_transfer at 80
Unrecognized code: 'pdefaults'

Error in ==> hardlim at 57
boiler_transfer

Error in ==> network.subsasgn>setTrainFcn at 2111
   net.trainParam = feval(trainFcn,'pdefaults');

Error in ==> network.subsasgn at 481
    [net,err]=setTrainFcn(net,trainFcn);

Error in ==> newff>new_5p0 at 254
net.trainfcn = btf;

Error in ==> newff at 87
  net = new_5p0(varargin{:});

Error in ==> Neural_Network_code at 19
net = newff(minmax(input_training_data), [15 10],
{'logsig','logsig'} , 'hardlim' ); %create a network

Subject: simple neural network question

From: Greg Heath

Date: 5 Mar, 2012 05:38:06

Message: 2 of 2

On Mar 4, 4:36 pm, "Marco Wu" <alwaysma...@hotmail.com> wrote:
> Dear all,
>
> I am new to neural network toolbox. Please help me on this questions. I actually have 2 questions. The first one is concept base. The 2nd one is syntax base.
>
> I have 256 input channels and 10 output categories.

Uh-oh: Input dimensionality reduction is probably needed.

>What network should I use if I have to make sure that 1 and only 1 output category will be selected every >time?

It depends on what version you are using. For an I-H-O (e.g., 256-
H-10) node topology

[ I N ] = size(p)
[ O N ] = size(t)
Neq = N*O % Number of training equations

1, Ancient NEWFF net = newff( minmax(p), [ H O ] ) ;
2. Old NEWFF net = newff( p, t, H ) ;
3. New PATTERNET net = patternnet( H ) ;

Details can be obtained by the commands lookfor, help and doc .

The output activation function can be PURELIN, LOGSIG, or SOFTMAX and
the outputs can be considered estimates of the input conditional
posterior class probabilities.

The key is to use columns of the 10-dimensional unit matrix eye(10) in
the target matrix t to indicate the true class index of the
corresponding input vector in p.

t = ind2vec(trueclassind)

help ind2vec
doc ind2vec

For classification, the input vector is assigned to the class
corresponding to the output node with the maximum value.

assignedclassind = vec2ind(y)

The error counts and percentages can be obtained from

Nerr = 0.5*sum(abs(t-compet(y))) % help compet,
doc compet
Pcterr = 100*Nerr/Neq


> ***THE SECOND QUESTION*********************************
>
>  I got error after I run my simple code. Thanks
>
> Here is my code
>
> input_training_data = HandWritingData(random_list,:)';      %size = [256X788]
> target_training_data = Category(random_list,:)';        %size = [10x788]

Again: The output columns are columns of eye(10)

> net = newff(minmax(input_training_data), [15 10], {'logsig','logsig'} , 'hardlim' ); %create a network

Why H = 15?

Try
rand('state',0)
Ntrials = 10
j=0
for h = Hmin:dH:Hmax % Preferrably Hmax << (Neq-O)/
(I+O+1)
     j = j+1
     H = h
    for i =1:Ntrials
        net = newff(minmax(p),[ H 10 ]);
        net.trainParam.goal = 0.01*mean(var(t')');
        [ net tr Y ] = train(net,p,t);
        Nerr(i,j) = 0.5*sum(abs(t-compet(Y)));
   end
end

% Tabulations to choose the best design

H = Hind:dH:Hmax
Pcterr = Nerr/Neq

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