I have 300 images in a folder that I'm using as a data set for validation of a neural network.
Each image has a label of 1
or 0
. I converted the images to a matrix in MATLAB and the labels to a 300x1 vector of either 1
or 0
that corresponds to each row of images in the matrix.
I noticed that the labels aren't balanced, which affects the network. How can I reorder the labels with keeping the same indication of zero or one for each row of images?
This is what I tried:
I split the ones and zeros each in a vector and now I want to be able to put at least two ones and 10 zeros in 12 rows consecutively, but I didn't know how. I used this to split the ones and zeros:
ones = labels(labels(:,1)==1,:)
zeros = labels(labels(:,1)==0,:)
How can I rearrange the labels to remove the problem of unbalanced labels?