Reputation: 13
I am trying to code neural network for face detection.
I have input as (1372*4096
) and target as (1372*1
). The inputs are images, each image is represented in a row. Therefore, I have 1372 images.
For each image I would like to output one value: output 1
if the image is a face and -1
if it is not a face.
I wrote this code:
[input target]=LoadImage();
net=newff(input,target,[10 5 1],{'tansig','tansig','purelin'}, 'trainrp');
net.trainParam.goal=1e-5;
net.trainParam.epochs=1000;
net.trainParam.lr=0.5;
net.trainParam.show=10;
% start training
net=train(net,input,target);
But I get this error:
Error using trainrp (line 107)
Inputs and targets have different numbers of samples.
Error in network/train (line 106)
[net,tr] = feval(net.trainFcn,net,X,T,Xi,Ai,EW,net.trainParam);
Error in train1 (line 12)
net=train(net,d,out_d);
What should I do to fix this error?
Upvotes: 1
Views: 10974
Reputation: 221
For the Neural Network Toolbox, each input must be a vector, so you will have a matrix with as many columns Q as there are different images. Then the target should be a 1xQ. So it looks like you need to reshape the inputs.
I would recommend using new function FEEDFORWARDNET over the obsolete (but still working) NEWFF.
Upvotes: 2