Divide a 4D array into training set and validation set for CNN (regression)
Afficher commentaires plus anciens
Hi everybody, I am trying to design a CNN for regression following this Matlab example. It uses a 4D array to store the images and vector to store the values associated to every picture. I am using this code to create a 4D array called 'database' that contains my images and a vector 'labels' that contains the values.
k = 1;
%2cm
for i = 1:1000
str = sprintf('images/2cm/%d.jpg', i);
image_to_store = imread(str);
database(:,:,1,k) = (image_to_store(:,:)); % images are in grey scale
labels(k) = 2;
k = k+1;
end
%20cm
for i = 1:1000
str = sprintf('images/20cm/%d.jpg', i);
image_to_store = imread(str);
database(:,:,1,k) = (image_to_store(:,:));
labels(k) = 20;
k = k+1;
end
% ...
Now, I have my 4D array and the vector, so I am trying to divide them into a Training Set and a Validation Set as suggested in the example linked. Can anyone please help me to understand how can I do that?
Thanks
Vale
1 commentaire
Muhammad Waris
le 31 Mar 2021
hello, what was the size of image? I am trying to do the similar work, made 4Darraydata and also divided that for training and testing.But when i strat to train this code https://ch.mathworks.com/help/deeplearning/ug/train-a-convolutional-neural-network-for-regression.html i encounter with an error "Insufficient number of outputs from right hand side of equal sign to satisfy assignment".
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Object Detection dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!