I have started using CNN in MatConvNet with basic binary classification. I have 90 images in that there are total 750 aircraft's and ground truth boxes. Using ground boxes I have extracted all the aircraft image patches as positive samples and make the variables for the input. here is the MATLAB CODE:
Npos = numel(p_regions);
Npos_train = floor(0.25*Npos);
Npos_val = floor(0.25*Npos);
Npos_test = floor(0.50*Npos);
imdb.images.set =[ ones( 1, Npos_train ) 2*ones( 1, Npos_val) 3*ones( 1, Npos_test)];
for i=1:Npos
im= imresize (double(p_regions{i,:}),[50,50]);
imdb.images.data(:,:,:, i) = im;
imdb.images.labels(i) = 1;
end
imdb.meta.sets = {'train', 'val', 'test'} ;
In case if I combine aircraft (positive) and non-aircraft (negative) image patches then code will be like this?
Npos_train = floor(0.25* (Npos+Nneg));
Npos_val = floor(0.25*(Npos+Nneg));
Npos_test = floor(0.50*(Npos+Nneg));
for i=1:Npos
im= imresize (double(p_regions{i,:}),[50,50]);
imdb.images.data(:,:,:, i) = im;
imdb.images.labels(i) = 1;
end
for i=1:Nneg
im= imresize (double(n_regions{i,:}),[50,50]);
imdb.images.data(:,:,:, I+Npos) = im;
imdb.images.labels(I+Npos) = 0;
end
imdb.images.set =[ ones( 1, Npos_train ) 2*ones( 1, Npos_val) 3*ones( 1, Npos_test)];
images.data
will be like [All Positives All Negatives ]
images.labels
will organize the data [All 1's All 0's ]
and images.set will be images.set =[ ones( 1, Npos_train ) 2*ones( 1, Npos_val) 3*ones( 1, Npos_test)];
Q: The thing which makes me confuse here is:
if we want 200 samples for the training. Then how CNN will automatically take positive and negative samples if the data is stored like in images.data
and images.labels
?