Najeebullah Shah
Najeebullah Shah

Reputation: 3709

How to use train in neural networks for Matlab R2009b

I have input matrix as:

input = 
    1     0     0     1     1
    1     0     0     0     1
    1     0     0     0     1
    1     0     0     0     1
    0     0     1     0     0
    0     1     1     1     0
    0     1     1     1     0

and

T = [eye(10) eye(10) eye(10) eye(10)];

The neural network that I created is:

net = newff(input,T,[35], {'logsig'})
%net.performFcn = 'sse';
net.divideParam.trainRatio = 1; % training set [%]
net.divideParam.valRatio   = 0; % validation set [%]
net.divideParam.testRatio  = 0; % test set [%]
net.trainParam.goal = 0.001;

It works fine till now, but when i use train function the problem arises

[net tr] = train(net,input,T);

and the following error show up in matlab window:

??? Error using ==> network.train at 145
Targets are incorrectly sized for network.
Matrix must have 5 columns.

Error in ==> test at 103
[net tr] = train(net,input,T);

I've also tried the input' and T' as well. Any help is appreciated in advance

Upvotes: 1

Views: 4031

Answers (1)

Eitan T
Eitan T

Reputation: 32930

If you look at MATLAB's official documentaion of train, you'll notice that T must have the same amount of columns as the input matrix, which is 5 in your case. Instead, try:

T = ones(size(input, 1));

or

T = [1, size(input, 1) - 1];

and see if this works.

Upvotes: 1

Related Questions