Divide a 4D array into training set and validation set for CNN (regression)
Mostrar comentarios más antiguos
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 comentario
Muhammad Waris
el 31 de Mzo. de 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".
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Object Detection en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!