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:
multiple inputs in neural network toolbox

Subject: multiple inputs in neural network toolbox

From: Ahmed Abdullah

Date: 8 Jul, 2013 08:02:25

Message: 1 of 5

I know how to give one input (multidimensional) -

P=[1 2 32 2 ;
2 3 4 5] ; % 4 training sample each inputs have 2 element

T=[1 4 2 3] ; % corresponding output for 4 sample

net=feedforwardnet;
net=configure(P,T);
net=train(P,T);


So you see i know how to give 1 input (multidimensional). But I don't know how to give two? you see . I just want to know the format of input Matrix or Cell

Subject: multiple inputs in neural network toolbox

From: Greg Heath

Date: 8 Jul, 2013 15:52:09

Message: 2 of 5

"Ahmed Abdullah" <abdullah.ahmed21@yahoo.com> wrote in message <krdrmh$jmo$1@newscl01ah.mathworks.com>...
> I know how to give one input (multidimensional) -
>
> P=[1 2 32 2 ;
> 2 3 4 5] ; % 4 training sample each inputs have 2 element
>
> T=[1 4 2 3] ; % corresponding output for 4 sample

[I N ] = size(P) % [ 2 4 ]
[ O N ] = size(T) % [ 1 4 ]
Ntrn = N -2*round(0.15*N) % 2

%==>Default data division: 2 training examples, 1 validation and 1 test

Ntrneq = Ntrn*O % only 2 training equations

> net=feedforwardnet;

This will cause the net to have H=10 (the default) hidden nodes.
The number of unknown weights is

Nw = (I+1)*H+(H+1)*O % 30+11=41

You have 2 equations to solve for 41 variables.

Obviously, this is a ridiculous example.

> net=configure(P,T);

Delete. Train will automatically configure an empty net.

> net=train(P,T);

Incorrect

net = train(net,P,T);

Y = net(P);

E = T-Y;

MSE = mse(E)

NMSE = MSE/var(T,1) % Normalized MSE desired to be << 1
 
> So you see i know how to give 1 input (multidimensional). But I don't know how to give two? you see . I just want to know the format of input Matrix or Cell

Although you used a ridiculous example and an incorrect training syntax, you've
asked an excellent question.

net.numinputs = 2;

creates a net with 2 inputs. Each can have a different dimensionality. Typically they would be connected to different hidden layers (e.g. 2 in parallel and both hidden layers connected to an output layer). See the documentation section on custom networks for details.

My problem is I can construct the network but I don't know how to tell train that there
are 2 inputs.

Will try to find out.

More later.

Greg

Subject: multiple inputs in neural network toolbox

From: Ahmed Abdullah

Date: 8 Jul, 2013 16:32:07

Message: 3 of 5

>> My problem is I can construct the network but I don't know how to tell train that there
>> are 2 inputs.
>>

>I have exactly the same problem . I tried things like
>net= configure(net,'inputs',inputs,i); But doesn't work.

 Please help. Appreciate your input very much.

Subject: multiple inputs in neural network toolbox

From: Greg Heath

Date: 12 Jul, 2013 02:23:07

Message: 4 of 5

"Ahmed Abdullah" <abdullah.ahmed21@yahoo.com> wrote in message <krepi7$54b$1@newscl01ah.mathworks.com>...
> >> My problem is I can construct the network but I don't know how to tell train that there
> >> are 2 inputs.
> >>
>
> >I have exactly the same problem . I tried things like
> >net= configure(net,'inputs',inputs,i); But doesn't work.
>
> Please help. Appreciate your input very much.

So far, the only answer I have is to vertically concatenate:

P = [ P1 ; P2 ];

Hope this helps.

Greg

Subject: multiple inputs in neural network toolbox

From: Ahmed Abdullah

Date: 13 Jul, 2013 18:43:12

Message: 5 of 5

"Greg Heath" <heath@alumni.brown.edu> wrote in message <krnpab$9hp$1@newscl01ah.mathworks.com>...
> "Ahmed Abdullah" <abdullah.ahmed21@yahoo.com> wrote in message <krepi7$54b$1@newscl01ah.mathworks.com>...
> > >> My problem is I can construct the network but I don't know how to tell train that there
> > >> are 2 inputs.
> > >>
> >
> > >I have exactly the same problem . I tried things like
> > >net= configure(net,'inputs',inputs,i); But doesn't work.
> >
> > Please help. Appreciate your input very much.
>
> So far, the only answer I have is to vertically concatenate:
>
> P = [ P1 ; P2 ];
>
> Hope this helps.
>
> Greg

Thank you the idea worked, though after slight modification.P should be a Cell rather than a Matrix .. .. i.e curly bracket in the place of square bracket ( P={P2;P2}).

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