Problems training neural network for number recogniton using Matlab

1 view (last 30 days)
Hello All,
First of all I would like to thank you for all your help in advance. I am quite new to matlab and to neural networks.
I am trying to build a neural network for handwritten number recognition. To start off I am just testing with a small network that will output a one if the input is an image of a zero.
I have a large library of handwritten numbers in pgm format (32x32) To load all the images I have made the following function:
function [input , target] = construyeinputtarget(numero)
cd train
lista = dir('.');
input=[];
target=[];
% 1 y 2 son . y ..
for i=3:3825
fichero = lista(i).name;
encontrado = findstr(lista(i).name,numero);
if (not(isempty(encontrado)))
I=imread(fichero);
I=imresize(I,0.5);
I=I(:);
for n=1:256
if I(n)==255
I(n)=1;
end
end
input=[input, I];
target=[target, 1];
end
i
end
cd ..
This function goes file by file and checks to see if the name tag of the file has the input string in it(in this case 'zero')
If the image has the appropriate tag it is resized to 16x16 converted into a column vector, then added to the input matrix. For every image loaded a 1 is added to the target vector.
After running this function I now have a matrix with as many columns as images loaded with 256 rows(16x16) each.
The next thing I do is make a neural network with an input layer with 256 neurons(one for each pixel of my resized image), a hidden layer with 8 neurons and an output layer with one neuron(I only want one output)
red0=newff([0 1;0 1...........0 1][8 1]{'logsig','logsig'});
My problem comes when I try to train my network with my input and target.
red0=train(red0,input,target)
I am getting the following error and I don't understand what I am doing wrong:
??? One or more output arguments not assigned during call to 'network/train (trainargs)'.
Error in ==> C:\MATLAB6p5\toolbox\nnet\nnet\@network\train.m
On line 169 ==> [err,P,T,Pi,Ai,Q,TS,matrixForm] = trainargs(net,P,T);
I have tried making the network with nntool but I can't import my input matrix
Can anyone help?
Phill

Answers (1)

Walter Roberson
Walter Roberson on 14 Jun 2011
You are using quite an old version of MATLAB. Are you sure that trainargs() was able to output all 8 items in your version?

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!