How can I construct a Neural Network in Matlab with matrix of features extracted from images?

562 views Asked by At

I have an X matrix that contains on every row some features extracted from images (one image for one row) and a Y matrix that has on every row a classification criteria for every feature vector/row in matrix X (Y is a matrix with just one column). Now I want to feed these two matrices to a Neural Networks and train it and then I want to test a new feature vector of an image (new_ft) and be able to get one of the two classification criterias built in the Neural Network model. Basically I want to see what group does a new feature vector belong to. I tried training a network in the form: net = newpr(X,Y,numHiddenNeurons) and then use [net,tr] = train(net,Xx,Y); outputs = sim(net,Xx); but I get the an error "Dimensions of matrices being concatenated are not consistent." on the first line. My matrices have the sizes: X= 46 x 25750 double and Y = 46 x 1 cell. I tried giving Y the same size 46 x 25750, but I get the same problem.

Could you let me know what could be the problem here? Thank you!

2

There are 2 answers

0
TANMANA On

Try transposing X and Y for the net: [net, tr] = train(net, X',Y')

0
vinod lahire On

Try this If your feature vector length of each image is 1*59 and you have it for 4 images ; so you feature vector length will be 4*59.And you have to classify it with in two classes.

So you train data should be (for matlab NNTOOL class) is 59*4 of vector length and train label is of 2*4 vector length

Train_label =

 1     1     0     0
 0     0     1     1

Now use

[net,tr] = train(net,trainData,trainLabel);

it will work